Skip to content

Commit a5d91bb

Browse files
committed
more cleanup and refactoring
1 parent ef2382f commit a5d91bb

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/util/CustomClassMapper.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -661,18 +661,10 @@ private static class BeanMapper<T> {
661661
+ method.getName());
662662
}
663663

664-
// OK to add since existingPropertyName == propertyName.
665-
properties.put(propertyName.toLowerCase(Locale.US), propertyName);
666-
667-
// Handle `setter` update.
668664
Method existingSetter = setters.get(propertyName);
669-
if (existingSetter == null) {
670-
method.setAccessible(true);
671-
setters.put(propertyName, method);
672-
applySetterAnnotations(method);
673-
} else if (!isSetterOverride(method, existingSetter)) {
674-
// We require that setters with conflicting property names are
675-
// overrides from a base class
665+
666+
// Raise exception if a conflict between setters is found.
667+
if (existingSetter != null && !isSetterOverride(method, existingSetter)) {
676668
if (currentClass == clazz) {
677669
// TODO: Should we support overloads?
678670
throw new RuntimeException(
@@ -692,6 +684,13 @@ private static class BeanMapper<T> {
692684
+ ")");
693685
}
694686
}
687+
688+
// Make it accessible and process annotations if not yet.
689+
if (existingSetter == null) {
690+
method.setAccessible(true);
691+
setters.put(propertyName, method);
692+
applySetterAnnotations(method);
693+
}
695694
}
696695

697696
for (Field field : currentClass.getDeclaredFields()) {

0 commit comments

Comments
 (0)