Skip to content

Commit

Permalink
Rely on HashSet for uniqueness of mapped names
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Feb 6, 2024
1 parent 8ff1021 commit 341ac76
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ public ConversionService getConversionService() {
/**
* Initialize the mapping meta-data for the given class.
* @param mappedClass the mapped class
* @see #setMappedClass
* @see BeanUtils#getPropertyDescriptors
* @see #mappedNames(PropertyDescriptor)
*/
protected void initialize(Class<T> mappedClass) {
this.mappedClass = mappedClass;
Expand Down Expand Up @@ -280,17 +283,14 @@ protected void suppressProperty(String propertyName) {
* @param pd the property descriptor discovered on initialization
* @return a set of mapped names
* @since 6.1.4
* @see #initialize
* @see #lowerCaseName
* @see #underscoreName
*/
protected Set<String> mappedNames(PropertyDescriptor pd) {
Set<String> mappedNames = new HashSet<>(4);
String lowerCaseName = lowerCaseName(pd.getName());
mappedNames.add(lowerCaseName);
String underscoreName = underscoreName(pd.getName());
if (!lowerCaseName.equals(underscoreName)) {
mappedNames.add(underscoreName);
}
mappedNames.add(lowerCaseName(pd.getName()));
mappedNames.add(underscoreName(pd.getName()));
return mappedNames;
}

Expand Down

0 comments on commit 341ac76

Please sign in to comment.