Skip to content

Commit ec53a43

Browse files
committed
Adding javadoc
1 parent 6c65c71 commit ec53a43

32 files changed

Lines changed: 444 additions & 1 deletion

client-java/controller/src/main/java/org/evomaster/client/java/controller/dynamodb/DynamoDbAttributeValueHelper.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,18 @@ public final class DynamoDbAttributeValueHelper {
3333
private static final String SCIENTIFIC_NOTATION_E_LOWER = "e";
3434
private static final String SCIENTIFIC_NOTATION_E_UPPER = "E";
3535

36+
/**
37+
* Utility class, no instances.
38+
*/
3639
private DynamoDbAttributeValueHelper() {
3740
}
3841

42+
/**
43+
* Converts a map of DynamoDB attribute values into plain Java values.
44+
*
45+
* @param source input object expected to be a map
46+
* @return normalized map or empty map when input is not a map
47+
*/
3948
public static Map<String, Object> toPlainMap(Object source) {
4049
if (!(source instanceof Map<?, ?>)) {
4150
return Collections.emptyMap();
@@ -50,6 +59,12 @@ public static Map<String, Object> toPlainMap(Object source) {
5059
return result;
5160
}
5261

62+
/**
63+
* Converts one DynamoDB attribute value object into a plain Java value.
64+
*
65+
* @param value attribute value object
66+
* @return normalized Java value
67+
*/
5368
@SuppressWarnings("unchecked")
5469
public static Object toPlainValue(Object value) {
5570
if (value == null) {
@@ -119,6 +134,12 @@ public static Object toPlainValue(Object value) {
119134
return value;
120135
}
121136

137+
/**
138+
* Converts binary payloads into plain byte arrays when backed by ByteBuffer.
139+
*
140+
* @param value binary payload object
141+
* @return byte array or original value when conversion is not needed
142+
*/
122143
private static Object toPlainBinary(Object value) {
123144
if (value instanceof ByteBuffer) {
124145
ByteBuffer bb = ((ByteBuffer) value).asReadOnlyBuffer();
@@ -130,13 +151,27 @@ private static Object toPlainBinary(Object value) {
130151
return value;
131152
}
132153

154+
/**
155+
* Reads a reflected value only when its corresponding {@code hasX} accessor is true.
156+
*
157+
* @param target target object
158+
* @param hasMethod presence-check method name
159+
* @param valueMethod value accessor method name
160+
* @return reflected value or {@code null}
161+
*/
133162
private static Object readIfPresent(Object target, String hasMethod, String valueMethod) {
134163
if (Boolean.TRUE.equals(DynamoDbReflectionHelper.invokeBooleanNoArg(target, hasMethod))) {
135164
return DynamoDbReflectionHelper.invokeNoArg(target, valueMethod);
136165
}
137166
return null;
138167
}
139168

169+
/**
170+
* Converts a collection of attribute values into plain Java values.
171+
*
172+
* @param source source collection
173+
* @return normalized list
174+
*/
140175
private static List<Object> toPlainList(Collection<Object> source) {
141176
List<Object> converted = new ArrayList<>(source.size());
142177
for (Object element : source) {
@@ -145,6 +180,12 @@ private static List<Object> toPlainList(Collection<Object> source) {
145180
return converted;
146181
}
147182

183+
/**
184+
* Converts a collection of numeric tokens into parsed numeric values.
185+
*
186+
* @param source source numeric collection
187+
* @return normalized number set
188+
*/
148189
private static Set<Object> toNumberSet(Collection<?> source) {
149190
LinkedHashSet<Object> numbers = new LinkedHashSet<>();
150191
for (Object number : source) {
@@ -155,6 +196,12 @@ private static Set<Object> toNumberSet(Collection<?> source) {
155196
return numbers;
156197
}
157198

199+
/**
200+
* Converts a collection of binary payloads into plain binary values.
201+
*
202+
* @param source source binary collection
203+
* @return normalized binary set
204+
*/
158205
private static Set<Object> toBinarySet(Collection<?> source) {
159206
LinkedHashSet<Object> binaries = new LinkedHashSet<>();
160207
for (Object binary : source) {
@@ -163,6 +210,12 @@ private static Set<Object> toBinarySet(Collection<?> source) {
163210
return binaries;
164211
}
165212

213+
/**
214+
* Parses a numeric token into {@link Long} or {@link Double}.
215+
*
216+
* @param text numeric token
217+
* @return parsed number or {@link Double#NaN} when parsing fails
218+
*/
166219
private static Object parseNumber(String text) {
167220
try {
168221
if (text.contains(DECIMAL_SEPARATOR)

client-java/controller/src/main/java/org/evomaster/client/java/controller/dynamodb/DynamoDbComparisonType.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ public enum DynamoDbComparisonType {
1313
LESS_THAN,
1414
LESS_THAN_EQUALS;
1515

16+
/**
17+
* Maps a DynamoDB comparator token to a normalized comparison type.
18+
*
19+
* @param token comparator token from parsed expression
20+
* @return normalized comparison type
21+
*/
1622
public static DynamoDbComparisonType fromToken(String token) {
1723
if ("=".equals(token)) {
1824
return EQUALS;
@@ -35,6 +41,13 @@ public static DynamoDbComparisonType fromToken(String token) {
3541
throw new IllegalArgumentException("Unsupported comparator token: " + token);
3642
}
3743

44+
/**
45+
* Creates a comparison operation instance for this comparison type.
46+
*
47+
* @param fieldName compared field name/path
48+
* @param value comparison value
49+
* @return concrete comparison operation
50+
*/
3851
public ComparisonOperation<?> toOperation(String fieldName, Object value) {
3952
switch (this) {
4053
case EQUALS:

client-java/controller/src/main/java/org/evomaster/client/java/controller/dynamodb/DynamoDbExpressionParser.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ private QueryOperation mergeOr(QueryOperation left, QueryOperation right) {
171171
return new OrOperation(Arrays.asList(left, right));
172172
}
173173

174+
/**
175+
* Visitor that converts grammar value nodes into Java values.
176+
*/
174177
private class ValueVisitor extends DynamoDbConditionExpressionBaseVisitor<Object> {
175178

176179
/** {@inheritDoc} */
@@ -211,6 +214,9 @@ public Object visitIdentifierValue(DynamoDbConditionExpressionParser.IdentifierV
211214
}
212215
}
213216

217+
/**
218+
* Visitor that converts grammar predicate nodes into query operations.
219+
*/
214220
private class OperationVisitor extends DynamoDbConditionExpressionBaseVisitor<QueryOperation> {
215221

216222
/** {@inheritDoc} */

client-java/controller/src/main/java/org/evomaster/client/java/controller/dynamodb/DynamoDbReflectionHelper.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,19 @@
77
*/
88
public final class DynamoDbReflectionHelper {
99

10+
/**
11+
* Utility class, no instances.
12+
*/
1013
private DynamoDbReflectionHelper() {
1114
}
1215

16+
/**
17+
* Invokes a no-argument method on the target object.
18+
*
19+
* @param target target object
20+
* @param methodName method name to invoke
21+
* @return invocation result or {@code null} on errors
22+
*/
1323
public static Object invokeNoArg(Object target, String methodName) {
1424
if (target == null) {
1525
return null;
@@ -22,6 +32,13 @@ public static Object invokeNoArg(Object target, String methodName) {
2232
}
2333
}
2434

35+
/**
36+
* Invokes a no-argument method and returns it only when boolean.
37+
*
38+
* @param target target object
39+
* @param methodName method name to invoke
40+
* @return boolean result or {@code null}
41+
*/
2542
public static Boolean invokeBooleanNoArg(Object target, String methodName) {
2643
Object value = invokeNoArg(target, methodName);
2744
return value instanceof Boolean ? (Boolean) value : null;

client-java/controller/src/main/java/org/evomaster/client/java/controller/dynamodb/DynamoDbRequestParser.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public class DynamoDbRequestParser {
1515

1616
private final Map<DynamoDbOperationNames, DynamoDbApiMethodParser> parsersByApiMethod;
1717

18+
/**
19+
* Creates a request parser and registers supported DynamoDB API method parsers.
20+
*/
1821
public DynamoDbRequestParser() {
1922
Map<DynamoDbOperationNames, DynamoDbApiMethodParser> map = new LinkedHashMap<>();
2023
registerParser(map, new QueryApiMethodParser());
@@ -28,7 +31,7 @@ public DynamoDbRequestParser() {
2831
}
2932

3033
/**
31-
* Entry-point parser used by the handler.
34+
* Entry-point parser used by a future handler.
3235
* It routes a DynamoDB SDK request to the API-method parser and returns
3336
* one parsed condition tree per table name.
3437
* Unsupported operations intentionally yield an empty map.
@@ -47,6 +50,12 @@ public Map<String, QueryOperation> parseByTable(Object request, DynamoDbOperatio
4750
return parsed == null ? Collections.emptyMap() : parsed;
4851
}
4952

53+
/**
54+
* Registers one API-method parser and rejects duplicates.
55+
*
56+
* @param parsersByApiMethod parser registry by API method name
57+
* @param parser parser instance to register
58+
*/
5059
private static void registerParser(Map<DynamoDbOperationNames, DynamoDbApiMethodParser> parsersByApiMethod,
5160
DynamoDbApiMethodParser parser) {
5261
DynamoDbOperationNames apiMethodName = parser.apiMethodName();

client-java/controller/src/main/java/org/evomaster/client/java/controller/dynamodb/operations/AndOperation.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,27 @@
22

33
import java.util.List;
44

5+
/**
6+
* Logical AND operation over multiple DynamoDB query conditions.
7+
*/
58
public class AndOperation extends QueryOperation {
69

710
private final List<QueryOperation> conditions;
811

12+
/**
13+
* Creates an AND operation.
14+
*
15+
* @param conditions conditions to combine
16+
*/
917
public AndOperation(List<QueryOperation> conditions) {
1018
this.conditions = conditions;
1119
}
1220

21+
/**
22+
* Returns the conditions combined by this AND operation.
23+
*
24+
* @return combined conditions
25+
*/
1326
public List<QueryOperation> getConditions() {
1427
return conditions;
1528
}

client-java/controller/src/main/java/org/evomaster/client/java/controller/dynamodb/operations/BeginsWithOperation.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
package org.evomaster.client.java.controller.dynamodb.operations;
22

3+
/**
4+
* DynamoDB {@code begins_with(path, value)} predicate operation.
5+
*/
36
public class BeginsWithOperation extends QueryOperation {
47

58
private final String fieldName;
69
private final Object prefix;
710

11+
/**
12+
* Creates a begins-with operation.
13+
*
14+
* @param fieldName attribute path
15+
* @param prefix expected prefix
16+
*/
817
public BeginsWithOperation(String fieldName, Object prefix) {
918
this.fieldName = fieldName;
1019
this.prefix = prefix;

client-java/controller/src/main/java/org/evomaster/client/java/controller/dynamodb/operations/BetweenOperation.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
package org.evomaster.client.java.controller.dynamodb.operations;
22

3+
/**
4+
* DynamoDB {@code path BETWEEN lower AND upper} predicate operation.
5+
*/
36
public class BetweenOperation extends QueryOperation {
47

58
private final String fieldName;
69
private final Object lowerBound;
710
private final Object upperBound;
811

12+
/**
13+
* Creates a BETWEEN operation.
14+
*
15+
* @param fieldName attribute path
16+
* @param lowerBound lower bound value
17+
* @param upperBound upper bound value
18+
*/
919
public BetweenOperation(String fieldName, Object lowerBound, Object upperBound) {
1020
this.fieldName = fieldName;
1121
this.lowerBound = lowerBound;

client-java/controller/src/main/java/org/evomaster/client/java/controller/dynamodb/operations/ContainsOperation.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
package org.evomaster.client.java.controller.dynamodb.operations;
22

3+
/**
4+
* DynamoDB {@code contains(path, value)} predicate operation.
5+
*/
36
public class ContainsOperation extends QueryOperation {
47

58
private final String fieldName;
69
private final Object expectedValue;
710

11+
/**
12+
* Creates a contains operation.
13+
*
14+
* @param fieldName attribute path
15+
* @param expectedValue expected contained value
16+
*/
817
public ContainsOperation(String fieldName, Object expectedValue) {
918
this.fieldName = fieldName;
1019
this.expectedValue = expectedValue;

client-java/controller/src/main/java/org/evomaster/client/java/controller/dynamodb/operations/ExistsOperation.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
package org.evomaster.client.java.controller.dynamodb.operations;
22

3+
/**
4+
* DynamoDB existence predicate operation for {@code attribute_exists} and
5+
* {@code attribute_not_exists}.
6+
*/
37
public class ExistsOperation extends QueryOperation {
48

59
private final String fieldName;
610
//true = exists, false = not exists
711
private final boolean exists;
812

13+
/**
14+
* Creates an existence operation.
15+
*
16+
* @param fieldName attribute path
17+
* @param exists {@code true} for exists, {@code false} for not-exists
18+
*/
919
public ExistsOperation(String fieldName, boolean exists) {
1020
this.fieldName = fieldName;
1121
this.exists = exists;

0 commit comments

Comments
 (0)