Replace 'while' and 'for' loop to 'foreach'

This commit is contained in:
Yuri Orlov 2018-10-27 17:41:27 +03:00
parent 2bf234caf7
commit 97bfe08d68
No known key found for this signature in database
GPG Key ID: 4F7E8749C5EB0AA2

View File

@ -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();