11package com .aerospike .mapper .tools ;
22
3- import java .lang .annotation .Annotation ;
4- import java .lang .reflect .Constructor ;
5- import java .lang .reflect .Field ;
6- import java .lang .reflect .Method ;
7- import java .lang .reflect .Modifier ;
8- import java .lang .reflect .Parameter ;
9- import java .util .ArrayList ;
10- import java .util .Arrays ;
11- import java .util .HashMap ;
12- import java .util .HashSet ;
13- import java .util .List ;
14- import java .util .Map ;
15- import java .util .Set ;
16- import java .util .TreeMap ;
17-
18- import javax .validation .constraints .NotNull ;
19-
20- import org .apache .commons .lang3 .StringUtils ;
21-
223import com .aerospike .client .AerospikeException ;
234import com .aerospike .client .Bin ;
245import com .aerospike .client .Key ;
3011import com .aerospike .client .policy .QueryPolicy ;
3112import com .aerospike .client .policy .ScanPolicy ;
3213import com .aerospike .client .policy .WritePolicy ;
33- import com .aerospike .mapper .annotations .AerospikeBin ;
34- import com .aerospike .mapper .annotations .AerospikeConstructor ;
35- import com .aerospike .mapper .annotations .AerospikeExclude ;
36- import com .aerospike .mapper .annotations .AerospikeGetter ;
37- import com .aerospike .mapper .annotations .AerospikeKey ;
38- import com .aerospike .mapper .annotations .AerospikeOrdinal ;
39- import com .aerospike .mapper .annotations .AerospikeRecord ;
40- import com .aerospike .mapper .annotations .AerospikeSetter ;
41- import com .aerospike .mapper .annotations .ParamFrom ;
14+ import com .aerospike .mapper .annotations .*;
4215import com .aerospike .mapper .exceptions .NotAnnotatedClass ;
4316import com .aerospike .mapper .tools .configuration .BinConfig ;
4417import com .aerospike .mapper .tools .configuration .ClassConfig ;
4518import com .aerospike .mapper .tools .configuration .KeyConfig ;
4619import com .aerospike .mapper .tools .utils .ParserUtils ;
4720import com .aerospike .mapper .tools .utils .TypeUtils ;
4821import com .aerospike .mapper .tools .utils .TypeUtils .AnnotatedType ;
22+ import org .apache .commons .lang3 .StringUtils ;
23+
24+ import javax .validation .constraints .NotNull ;
25+ import java .lang .annotation .Annotation ;
26+ import java .lang .reflect .Constructor ;
27+ import java .lang .reflect .Field ;
28+ import java .lang .reflect .Method ;
29+ import java .lang .reflect .Modifier ;
30+ import java .lang .reflect .Parameter ;
31+ import java .util .*;
4932
5033public class ClassCacheEntry <T > {
5134
@@ -104,7 +87,7 @@ private enum FactoryMethodType {
10487 private volatile boolean constructed ;
10588
10689 // package visibility only.
107- ClassCacheEntry (@ NotNull Class <T > clazz , IBaseAeroMapper mapper , ClassConfig config ,
90+ ClassCacheEntry (@ NotNull Class <T > clazz , IBaseAeroMapper mapper , ClassConfig config , boolean requireRecord ,
10891 @ NotNull Policy readPolicy , @ NotNull WritePolicy writePolicy ,
10992 @ NotNull BatchPolicy batchPolicy , @ NotNull QueryPolicy queryPolicy ,
11093 @ NotNull ScanPolicy scanPolicy ) {
@@ -118,8 +101,9 @@ private enum FactoryMethodType {
118101 this .queryPolicy = queryPolicy ;
119102
120103 AerospikeRecord recordDescription = clazz .getAnnotation (AerospikeRecord .class );
121- if (recordDescription == null && config == null ) {
122- throw new NotAnnotatedClass ("Class " + clazz .getName () + " is not augmented by the @AerospikeRecord annotation" );
104+ if (requireRecord && recordDescription == null && config == null ) {
105+ throw new NotAnnotatedClass (String .format ("Class %s is not augmented by the @AerospikeRecord annotation" ,
106+ clazz .getName ()));
123107 } else if (recordDescription != null ) {
124108 this .namespace = ParserUtils .getInstance ().get (recordDescription .namespace ());
125109 this .setName = ParserUtils .getInstance ().get (recordDescription .set ());
@@ -143,10 +127,11 @@ public ClassCacheEntry<T> construct() {
143127
144128 this .loadFieldsFromClass ();
145129 this .loadPropertiesFromClass ();
146- this .superClazz = ClassCache .getInstance ().loadClass (this .clazz .getSuperclass (), this .mapper );
130+ this .superClazz = ClassCache .getInstance ().loadClass (this .clazz .getSuperclass (), this .mapper , ! this . mapAll );
147131 this .binCount = this .values .size () + (superClazz != null ? superClazz .binCount : 0 );
148132 if (this .binCount == 0 ) {
149- throw new AerospikeException ("Class " + clazz .getSimpleName () + " has no values defined to be stored in the database" );
133+ throw new AerospikeException (String .format ("Class %s has no values defined to be stored in the database" ,
134+ clazz .getSimpleName ()));
150135 }
151136 this .formOrdinalsFromValues ();
152137 Method factoryConstructorMethod = findConstructorFactoryMethod ();
@@ -240,7 +225,7 @@ public boolean isChildClass() {
240225
241226 private void checkRecordSettingsAgainstSuperClasses () {
242227 if (!StringUtils .isBlank (this .namespace ) && !StringUtils .isBlank (this .setName )) {
243- // This class defines it's own namespace + set, it is only a child class if it's closest named superclass is the same as ours.
228+ // This class defines its own namespace + set, it is only a child class if its closest named superclass is the same as ours.
244229 this .isChildClass = false ;
245230 ClassCacheEntry <?> thisEntry = this .superClazz ;
246231 while (thisEntry != null ) {
0 commit comments