Skip to content

Commit

Permalink
Use Set to track ignored properties in BeanUtils.copyProperties()
Browse files Browse the repository at this point in the history
  • Loading branch information
liupeng authored and sbrannen committed Mar 9, 2023
1 parent 1acbc97 commit d2868f5
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -791,11 +792,11 @@ private static void copyProperties(Object source, Object target, @Nullable Class
actualEditable = editable;
}
PropertyDescriptor[] targetPds = getPropertyDescriptors(actualEditable);
List<String> ignoreList = (ignoreProperties != null ? Arrays.asList(ignoreProperties) : null);
Set<String> ignoreSet = (ignoreProperties != null ? new HashSet<>(Arrays.asList(ignoreProperties)) : null);

for (PropertyDescriptor targetPd : targetPds) {
Method writeMethod = targetPd.getWriteMethod();
if (writeMethod != null && (ignoreList == null || !ignoreList.contains(targetPd.getName()))) {
if (writeMethod != null && (ignoreSet == null || !ignoreSet.contains(targetPd.getName()))) {
PropertyDescriptor sourcePd = getPropertyDescriptor(source.getClass(), targetPd.getName());
if (sourcePd != null) {
Method readMethod = sourcePd.getReadMethod();
Expand Down

0 comments on commit d2868f5

Please sign in to comment.