Skip to content

Commit 67abcc3

Browse files
authored
1. Javadoc standardization. (#72)
1. Javadoc standardization. 2. Reorder methods to align with interfaces at the "right order" 3. Add SuppressWarning("unchecked")/assertions at relevant places.
1 parent eb7d33c commit 67abcc3

12 files changed

+1770
-1508
lines changed

src/main/java/com/aerospike/mapper/tools/AeroMapper.java

Lines changed: 20 additions & 279 deletions
Large diffs are not rendered by default.

src/main/java/com/aerospike/mapper/tools/IAeroMapper.java

Lines changed: 263 additions & 9 deletions
Large diffs are not rendered by default.

src/main/java/com/aerospike/mapper/tools/IBaseAeroMapper.java

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,48 @@
88
import com.aerospike.mapper.tools.converters.MappingConverter;
99

1010
public interface IBaseAeroMapper {
11+
12+
MappingConverter getMappingConverter();
13+
14+
IAeroMapper asMapper();
15+
16+
/**
17+
* Return the read policy to be used for the passed class. This is a convenience method only and should rarely be needed
18+
*
19+
* @param clazz - the class to return the read policy for.
20+
* @return - the appropriate read policy. If none is set, the client's readPolicyDefault is returned.
21+
*/
1122
Policy getReadPolicy(Class<?> clazz);
1223

24+
/**
25+
* Return the write policy to be used for the passed class. This is a convenience method only and should rarely be needed
26+
*
27+
* @param clazz - the class to return the write policy for.
28+
* @return - the appropriate write policy. If none is set, the client's writePolicyDefault is returned.
29+
*/
1330
WritePolicy getWritePolicy(Class<?> clazz);
1431

32+
/**
33+
* Return the batch policy to be used for the passed class. This is a convenience method only and should rarely be needed
34+
*
35+
* @param clazz - the class to return the batch policy for.
36+
* @return - the appropriate batch policy. If none is set, the client's batchPolicyDefault is returned.
37+
*/
1538
BatchPolicy getBatchPolicy(Class<?> clazz);
1639

40+
/**
41+
* Return the scan policy to be used for the passed class. This is a convenience method only and should rarely be needed
42+
*
43+
* @param clazz - the class to return the scan policy for.
44+
* @return - the appropriate scan policy. If none is set, the client's scanPolicyDefault is returned.
45+
*/
1746
ScanPolicy getScanPolicy(Class<?> clazz);
1847

48+
/**
49+
* Return the query policy to be used for the passed class. This is a convenience method only and should rarely be needed
50+
*
51+
* @param clazz - the class to return the query policy for.
52+
* @return - the appropriate query policy. If none is set, the client's queryPolicyDefault is returned.
53+
*/
1954
QueryPolicy getQueryPolicy(Class<?> clazz);
20-
21-
IAeroMapper asMapper();
22-
23-
MappingConverter getMappingConverter();
2455
}

src/main/java/com/aerospike/mapper/tools/IReactiveAeroMapper.java

Lines changed: 237 additions & 9 deletions
Large diffs are not rendered by default.

src/main/java/com/aerospike/mapper/tools/ReactiveAeroMapper.java

Lines changed: 93 additions & 328 deletions
Large diffs are not rendered by default.

src/main/java/com/aerospike/mapper/tools/converters/MappingConverter.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public MappingConverter(IBaseAeroMapper mapper, IAerospikeClient aerospikeClient
3737
/**
3838
* Translate a Java object to an Aerospike format object. Note that this could potentially have performance issues as
3939
* the type information of the passed object must be determined on every call.
40+
*
4041
* @param obj A given Java object.
4142
* @return An Aerospike format object.
4243
*/
@@ -51,6 +52,7 @@ public Object translateToAerospike(Object obj) {
5152
/**
5253
* Translate an Aerospike object to a Java object. Note that this could potentially have performance issues as
5354
* the type information of the passed object must be determined on every call.
55+
*
5456
* @param obj A given Java object.
5557
* @return An Aerospike format object.
5658
*/
@@ -66,10 +68,12 @@ public <T> T translateFromAerospike(@NotNull Object obj, @NotNull Class<T> expec
6668
// The following are convenience methods to convert objects to / from lists / maps / records in case
6769
// it is needed to perform this operation manually. They will not be needed in most use cases.
6870
// --------------------------------------------------------------------------------------------------
71+
6972
/**
7073
* Given a record loaded from Aerospike and a class type, attempt to convert the record to
7174
* an instance of the passed class.
72-
* @param clazz The class type to convert the Aerospike record to.
75+
*
76+
* @param clazz The class type to convert the Aerospike record to.
7377
* @param record The Aerospike record to convert.
7478
* @return A virtual list.
7579
* @throws AerospikeException an AerospikeException will be thrown in case of an encountering a ReflectiveOperationException.
@@ -85,9 +89,10 @@ public <T> T convertToObject(Class<T> clazz, Record record) {
8589
/**
8690
* Given a record loaded from Aerospike and a class type, attempt to convert the record to
8791
* an instance of the passed class.
88-
* @param clazz The class type to convert the Aerospike record to.
92+
*
93+
* @param clazz The class type to convert the Aerospike record to.
8994
* @param record The Aerospike record to convert.
90-
* @param entry The entry that holds information on how to store the provided class.
95+
* @param entry The entry that holds information on how to store the provided class.
9196
* @return A virtual list.
9297
* @throws AerospikeException an AerospikeException will be thrown in case of an encountering a ReflectiveOperationException.
9398
*/
@@ -112,7 +117,8 @@ public <T> T convertToObject(Class<T> clazz, Record record, ClassCacheEntry<T> e
112117
/**
113118
* Given a list of records loaded from Aerospike and a class type, attempt to convert the records to
114119
* an instance of the passed class.
115-
* @param clazz The class type to convert the Aerospike record to.
120+
*
121+
* @param clazz The class type to convert the Aerospike record to.
116122
* @param record The Aerospike records to convert.
117123
* @return A virtual list.
118124
* @throws AerospikeException an AerospikeException will be thrown in case of an encountering a ReflectiveOperationException.
@@ -142,7 +148,8 @@ public <T> T convertToObject(Class<T> clazz, List<Object> record, boolean resolv
142148
/**
143149
* Given a map of records loaded from Aerospike and a class type, attempt to convert the records to
144150
* an instance of the passed class.
145-
* @param clazz The class type to convert the Aerospike record to.
151+
*
152+
* @param clazz The class type to convert the Aerospike record to.
146153
* @param record The Aerospike records to convert.
147154
* @return A virtual list.
148155
* @throws AerospikeException an AerospikeException will be thrown in case of an encountering a ReflectiveOperationException.
@@ -154,9 +161,11 @@ public <T> T convertToObject(Class<T> clazz, Map<String, Object> record) {
154161

155162
/**
156163
* Given an instance of a class (of any type), convert its properties to a list
164+
*
157165
* @param instance The instance of a class (of any type).
158166
* @return a List of the properties of the given instance.
159167
*/
168+
@SuppressWarnings("unchecked")
160169
public <T> List<Object> convertToList(@NotNull T instance) {
161170
ClassCacheEntry<T> entry = (ClassCacheEntry<T>) ClassCache.getInstance().loadClass(instance.getClass(), mapper);
162171
return entry.getList(instance, false, false);
@@ -165,9 +174,11 @@ public <T> List<Object> convertToList(@NotNull T instance) {
165174
/**
166175
* Given an instance of a class (of any type), convert its properties to a map, properties names will use as the
167176
* key and properties values will be the values.
177+
*
168178
* @param instance The instance of a class (of any type).
169179
* @return the properties {@link Map} of the given instance.
170180
*/
181+
@SuppressWarnings("unchecked")
171182
public <T> Map<String, Object> convertToMap(@NotNull T instance) {
172183
ClassCacheEntry<T> entry = (ClassCacheEntry<T>) ClassCache.getInstance().loadClass(instance.getClass(), mapper);
173184
return entry.getMap(instance, false);
@@ -180,6 +191,7 @@ private Key createKey(ClassCacheEntry<?> entry, DeferredObjectLoader.DeferredObj
180191
return new Key(entry.getNamespace(), entry.getSetName(), Value.get(entry.translateKeyToAerospikeKey(deferredObject.getKey())));
181192
}
182193
}
194+
183195
/**
184196
* If an object refers to other objects (eg A has a list of B via references), then reading the object will populate the
185197
* ids. If configured to do so, these objects can be loaded via a batch load and populated back into the references which
@@ -190,6 +202,7 @@ private Key createKey(ClassCacheEntry<?> entry, DeferredObjectLoader.DeferredObj
190202
* the list of deferred objects is empty. The deferred objects are stored in a <pre>ThreadLocalData<pre> list, so are thread safe
191203
* @param parentEntity - the ClassCacheEntry of the parent entity. This is used to get the batch policy to use.
192204
*/
205+
@SuppressWarnings("unchecked")
193206
public void resolveDependencies(ClassCacheEntry<?> parentEntity) {
194207
List<DeferredObjectLoader.DeferredObjectSetter> deferredObjects = DeferredObjectLoader.getAndClear();
195208

0 commit comments

Comments
 (0)