Replace 'while' and 'for' loop to 'foreach'
@@ -194,9 +194,7 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
// copy only properties that are readable and writable. If its
// not readable, we can't get the value from the old map. If
// its not writable, we can't write a value into the new map.
- Iterator<String> readableKeys = readMethods.keySet().iterator();
- while (readableKeys.hasNext()) {
- String key = readableKeys.next();
+ for (String key : readMethods.keySet()) {
if (getWriteMethod(key) != null) {
newMap.put(key, get(key));
}
@@ -215,9 +213,7 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
* @param map the BeanMap whose properties to put
*/
public void putAllWriteable(BeanMap map) {
- Iterator<String> readableKeys = map.readMethods.keySet().iterator();
- while (readableKeys.hasNext()) {
- String key = readableKeys.next();
+ for (String key : map.readMethods.keySet()) {
if (getWriteMethod(key) != null) {
this.put(key, map.get(key));
}
@@ -542,8 +538,7 @@ public class BeanMap extends AbstractMap<String, Object> implements Cloneable {
BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
if (propertyDescriptors != null) {
- for (int i = 0; i < propertyDescriptors.length; i++) {
- PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
+ for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
if (propertyDescriptor != null) {
String name = propertyDescriptor.getName();
Method readMethod = propertyDescriptor.getReadMethod();
