@@ -113,7 +113,7 @@ private enum FactoryMethodType {
113113 this .config = config ;
114114 }
115115
116- public ClassCacheEntry < T > construct () {
116+ public void construct () {
117117 if (config != null ) {
118118 config .validate ();
119119 this .overrideSettings (config );
@@ -146,7 +146,6 @@ public ClassCacheEntry<T> construct() {
146146
147147 this .checkRecordSettingsAgainstSuperClasses ();
148148 constructed = true ;
149- return this ;
150149 }
151150
152151 public boolean isNotConstructed () {
@@ -378,7 +377,7 @@ private Method findConstructorFactoryMethod() {
378377 String .format ("Missing factoryClass definition when factoryMethod is specified on class %s" ,
379378 clazz .getSimpleName ()));
380379 }
381- if (StringUtils .isBlank (this .factoryClass )) {
380+ if (StringUtils .isBlank (this .factoryMethod )) {
382381 throw new AerospikeMapperException (
383382 String .format ("Missing factoryMethod definition when factoryClass is specified on class %s" ,
384383 clazz .getSimpleName ()));
@@ -806,21 +805,25 @@ private void mapField(Field thisField, BinConfig thisBin, boolean isKey) {
806805
807806 private Method findMethodWithNameAndParams (String name , Class <?>... params ) {
808807 try {
809- Method method = this .clazz .getDeclaredMethod (name , params );
810808 // TODO: Should this ascend the inheritance hierarchy using getMethod on superclasses?
811- return method ;
809+ return this . clazz . getDeclaredMethod ( name , params ) ;
812810 } catch (NoSuchMethodException nsme ) {
813811 return null ;
814812 }
815813 }
816814
817- private Method findMethodWithNameAndParamByTypeName (String name , Class <?> firstParam , String secondParamTypeName ) {
815+ /**
816+ * Searches for a 2-param setter whose second parameter is a recognized client Key or Value type, as determined by
817+ * the mapper's {@link SetterParamTypeResolver}.
818+ */
819+ private Method findSetterWithClientParamType (String setterName , Class <?> firstParam ) {
820+ SetterParamTypeResolver resolver = this .mapper .getSetterParamTypeResolver ();
818821 for (Method m : this .clazz .getDeclaredMethods ()) {
819- if (m .getName ().equals (name )) {
822+ if (m .getName ().equals (setterName )) {
820823 Class <?>[] paramTypes = m .getParameterTypes ();
821824 if (paramTypes .length == 2
822825 && paramTypes [0 ].isAssignableFrom (firstParam )
823- && secondParamTypeName . equals (paramTypes [1 ].getName ())) {
826+ && resolver . resolve (paramTypes [1 ].getName ()) != PropertyDefinition . SetterParamType . NONE ) {
824827 return m ;
825828 }
826829 }
@@ -844,10 +847,7 @@ private void validateAccessorsForField(String binName, Field thisField) {
844847
845848 Method setter = findMethodWithNameAndParams (setterName , thisField .getType ());
846849 if (setter == null ) {
847- setter = findMethodWithNameAndParamByTypeName (setterName , thisField .getType (), "com.aerospike.client.Key" );
848- }
849- if (setter == null ) {
850- setter = findMethodWithNameAndParamByTypeName (setterName , thisField .getType (), "com.aerospike.client.Value" );
850+ setter = findSetterWithClientParamType (setterName , thisField .getType ());
851851 }
852852 if (setter == null ) {
853853 throw new AerospikeMapperException (String .format (
@@ -917,11 +917,6 @@ public Integer getTtl() {
917917 return ttl ;
918918 }
919919
920- /** Returns whether the key field is stored as a regular bin (true) or only in key metadata (false). */
921- public boolean isKeyStoredAsBin () {
922- return keyAsBin ;
923- }
924-
925920 /**
926921 * Traverses the class hierarchy to find the field name of the key (may be in a superclass).
927922 * Returns null if no key field is found.
@@ -976,21 +971,6 @@ public Integer getGenerationValue(Object instance) {
976971 }
977972 }
978973
979- private boolean contains (String [] names , String thisName ) {
980- if (names == null || names .length == 0 ) {
981- return true ;
982- }
983- if (thisName == null ) {
984- return false ;
985- }
986- for (String aName : names ) {
987- if (thisName .equals (aName )) {
988- return true ;
989- }
990- }
991- return false ;
992- }
993-
994974 public Map <String , Object > getMap (Object instance , boolean needsType ) {
995975 try {
996976 Map <String , Object > results = new HashMap <>();
@@ -1023,8 +1003,8 @@ private void addDataFromValueName(String name, Object instance, ClassCacheEntry<
10231003 }
10241004 }
10251005
1026- private boolean isKeyField (String name ) {
1027- return keyName != null && keyName .equals (name );
1006+ private boolean isNotKeyField (String name ) {
1007+ return keyName == null || ! keyName .equals (name );
10281008 }
10291009
10301010 public List <Object > getList (Object instance , boolean skipKey , boolean needsType ) {
@@ -1039,14 +1019,14 @@ public List<Object> getList(Object instance, boolean skipKey, boolean needsType)
10391019 if (thisClass .ordinals != null ) {
10401020 for (int i = 1 ; i <= thisClass .ordinals .size (); i ++) {
10411021 String name = thisClass .ordinals .get (i );
1042- if (!skipKey || ! isKeyField (name )) {
1022+ if (!skipKey || isNotKeyField (name )) {
10431023 addDataFromValueName (name , instance , thisClass , results );
10441024 }
10451025 }
10461026 }
10471027 for (String name : thisClass .values .keySet ()) {
10481028 if (thisClass .fieldsWithOrdinals == null || !thisClass .fieldsWithOrdinals .contains (name )) {
1049- if (!skipKey || ! isKeyField (name )) {
1029+ if (!skipKey || isNotKeyField (name )) {
10501030 addDataFromValueName (name , instance , thisClass , results );
10511031 }
10521032 }
@@ -1237,15 +1217,15 @@ public T constructAndHydrate(List<Object> list, boolean skipKey) {
12371217 if (thisClass .ordinals != null ) {
12381218 for (int i = 1 ; i <= thisClass .ordinals .size (); i ++) {
12391219 String name = thisClass .ordinals .get (i );
1240- if (!skipKey || ! isKeyField (name )) {
1220+ if (!skipKey || isNotKeyField (name )) {
12411221 index = thisClass .setValueByField (name , objectVersion , recordVersion , null , index , list ,
12421222 valueMap );
12431223 }
12441224 }
12451225 }
12461226 for (String name : thisClass .values .keySet ()) {
12471227 if (thisClass .fieldsWithOrdinals == null || !thisClass .fieldsWithOrdinals .contains (name )) {
1248- if (!skipKey || ! isKeyField (name )) {
1228+ if (!skipKey || isNotKeyField (name )) {
12491229 index = thisClass .setValueByField (name , objectVersion , recordVersion , null , index , list ,
12501230 valueMap );
12511231 }
@@ -1286,15 +1266,15 @@ public void hydrateFromList(List<Object> list, Object instance, boolean skipKey)
12861266 if (ordinals != null ) {
12871267 for (int i = 1 ; i <= ordinals .size (); i ++) {
12881268 String name = ordinals .get (i );
1289- if (!skipKey || ! isKeyField (name )) {
1269+ if (!skipKey || isNotKeyField (name )) {
12901270 index = setValueByField (name , objectVersion , recordVersion , instance , index , list ,
12911271 null );
12921272 }
12931273 }
12941274 }
12951275 for (String name : this .values .keySet ()) {
12961276 if (this .fieldsWithOrdinals == null || !thisClass .fieldsWithOrdinals .contains (name )) {
1297- if (!skipKey || ! isKeyField (name )) {
1277+ if (!skipKey || isNotKeyField (name )) {
12981278 index = setValueByField (name , objectVersion , recordVersion , instance , index , list ,
12991279 null );
13001280 }
0 commit comments