51
51
* {@snippet :
52
52
* // CustomAttributeConverterProvider.create() is an example for some Custom converter provider
53
53
* EnhancedDocument enhancedDocumentWithCustomConverter = EnhancedDocument.builder().attributeConverterProviders
54
- * (CustomAttributeConverterProvider.create(), AttributeConverterProvide.defaultProvider())
55
- * .putWithType ("customObject", customObject, EnhancedType.of(CustomClass.class))
54
+ * (CustomAttributeConverterProvider.create(), AttributeConverterProvide.defaultProvider()
55
+ * .put ("customObject", customObject, EnhancedType.of(CustomClass.class))
56
56
* .build();
57
57
*}
58
58
* <p>Enhanced Document can be created with Json as input using Static factory method.In this case it used
@@ -143,7 +143,7 @@ static Builder builder() {
143
143
* <p>
144
144
* <b>Retrieving String Type for a document</b>
145
145
* {@snippet :
146
- * Custom resultCustom = document.get("key", EnhancedType.of(Custom .class));
146
+ * String resultCustom = document.get("key", EnhancedType.of(String .class));
147
147
* }
148
148
* <b>Retrieving Custom Type for which Convertor Provider was defined while creating the document</b>
149
149
* {@snippet :
@@ -166,6 +166,31 @@ static Builder builder() {
166
166
*/
167
167
<T > T get (String attributeName , EnhancedType <T > type );
168
168
169
+ /**
170
+ * Returns the value of the specified attribute in the current document as a specified class type; or null if the
171
+ * attribute either doesn't exist or the attribute value is null.
172
+ * <p>
173
+ * <b>Retrieving String Type for a document</b>
174
+ * {@snippet :
175
+ * String resultCustom = document.get("key", String.class);
176
+ * }
177
+ * <b>Retrieving Custom Type for which Convertor Provider was defined while creating the document</b>
178
+ * {@snippet :
179
+ * Custom resultCustom = document.get("key", Custom.class);
180
+ * }
181
+ * <p>
182
+ * Note :
183
+ * This API should not be used to retrieve values of List and Map types.
184
+ * Instead, getList and getMap APIs should be used to retrieve attributes of type List and Map, respectively.
185
+ * </p>
186
+ * @param attributeName Name of the attribute.
187
+ * @param clazz Class type of value.
188
+ * @param <T> The type of the attribute value.
189
+ * @return Attribute value of type T
190
+ * }
191
+ */
192
+ <T > T get (String attributeName , Class <T > clazz );
193
+
169
194
/**
170
195
* Gets the String value of specified attribute in the document.
171
196
*
@@ -212,8 +237,8 @@ static Builder builder() {
212
237
/**
213
238
* Gets the Set of String values of the given attribute in the current document.
214
239
* @param attributeName Name of the attribute.
215
- * @return value of the specified attribute in the current document as a set of SdkBytes; or null if the attribute either
216
- * doesn't exist or the attribute value is null .
240
+ * @return value of the specified attribute in the current document as a set of SdkBytes;
241
+ * or null if the attribute doesn't exist .
217
242
*/
218
243
Set <SdkBytes > getBytesSet (String attributeName );
219
244
@@ -223,8 +248,8 @@ static Builder builder() {
223
248
* @param attributeName Name of the attribute.
224
249
* @param type {@link EnhancedType} of Type T.
225
250
* @param <T> Type T of List elements
226
- * @return value of the specified attribute in the current document as a list of type T; or null if the
227
- * attribute either doesn't exist or the attribute value is null .
251
+ * @return value of the specified attribute in the current document as a list of type T,
252
+ * or null if the attribute does not exist .
228
253
*/
229
254
230
255
<T > List <T > getList (String attributeName , EnhancedType <T > type );
@@ -259,10 +284,13 @@ static Builder builder() {
259
284
* Gets the {@link Boolean} value for the specified attribute.
260
285
*
261
286
* @param attributeName Name of the attribute.
262
- * @return value of the specified attribute in the current document as a non-null Boolean.
287
+ * @return value of the specified attribute in the current document as a Boolean representation; or null if the attribute
288
+ * either doesn't exist or the attribute value is null.
263
289
* @throws RuntimeException
264
- * if either the attribute doesn't exist or if the attribute
265
- * value cannot be converted into a boolean value.
290
+ * if the attribute value cannot be converted to a Boolean representation.
291
+ * Note that the Boolean representation of 0 and 1 in Numbers and "0" and "1" in Strings is false and true,
292
+ * respectively.
293
+ *
266
294
*/
267
295
Boolean getBoolean (String attributeName );
268
296
@@ -276,7 +304,7 @@ static Builder builder() {
276
304
* @param attributeName Name of the attribute.
277
305
* @return value of the specified attribute in the current document as a List of {@link AttributeValue}
278
306
*/
279
- List <AttributeValue > getUnknownTypeList (String attributeName );
307
+ List <AttributeValue > getListOfUnknownType (String attributeName );
280
308
281
309
/**
282
310
* Retrieves a Map with String keys and corresponding AttributeValue objects as values for a specified attribute in a
@@ -287,7 +315,7 @@ static Builder builder() {
287
315
* @param attributeName Name of the attribute.
288
316
* @return value of the specified attribute in the current document as a {@link AttributeValue}
289
317
*/
290
- Map <String , AttributeValue > getUnknownTypeMap (String attributeName );
318
+ Map <String , AttributeValue > getMapOfUnknownType (String attributeName );
291
319
292
320
/**
293
321
*
@@ -350,7 +378,7 @@ interface Builder {
350
378
* @param value The boolean value that needs to be set.
351
379
* @return Builder instance to construct a {@link EnhancedDocument}
352
380
*/
353
- Builder putBoolean (String attributeName , Boolean value );
381
+ Builder putBoolean (String attributeName , boolean value );
354
382
355
383
/**
356
384
* Appends an attribute of name attributeName with a null value.
@@ -414,11 +442,33 @@ interface Builder {
414
442
* provider.
415
443
* Example:
416
444
{@snippet :
417
- EnhancedDocument.builder().putWithType ("customKey", customValue, EnhancedType.of(CustomClass.class));
418
- * }
445
+ * EnhancedDocument.builder().put ("customKey", customValue, EnhancedType.of(CustomClass.class));
446
+ * }
419
447
* Use {@link #putString(String, String)} or {@link #putNumber(String, Number)} for inserting simple value types of
420
448
* attributes.
421
- * Use {@link #putList(String, List, EnhancedType)} or {@link #putMapOfType(String, Map, EnhancedType, EnhancedType)} for
449
+ * Use {@link #putList(String, List, EnhancedType)} or {@link #putMap(String, Map, EnhancedType, EnhancedType)} for
450
+ * inserting collections of attribute values.
451
+ * Note that the attribute converter provider added to the DocumentBuilder must provide the converter for the class T
452
+ * that is to be inserted.
453
+ @param attributeName the name of the attribute to be added to the document.
454
+ @param value the value to set.
455
+ @param type the Enhanced type of the value to set.
456
+ @return a builder instance to construct a {@link EnhancedDocument}.
457
+ @param <T> the type of the value to set.
458
+ */
459
+ <T > Builder put (String attributeName , T value , EnhancedType <T > type );
460
+
461
+ /**
462
+ * Appends an attribute named {@code attributeName} with a value of Class type T.
463
+ * Use this method to insert attribute values of custom types that have attribute converters defined in a converter
464
+ * provider.
465
+ * Example:
466
+ {@snippet :
467
+ * EnhancedDocument.builder().put("customKey", customValue, CustomClass.class);
468
+ *}
469
+ * Use {@link #putString(String, String)} or {@link #putNumber(String, Number)} for inserting simple value types of
470
+ * attributes.
471
+ * Use {@link #putList(String, List, EnhancedType)} or {@link #putMap(String, Map, EnhancedType, EnhancedType)} for
422
472
* inserting collections of attribute values.
423
473
* Note that the attribute converter provider added to the DocumentBuilder must provide the converter for the class T
424
474
* that is to be inserted.
@@ -428,7 +478,7 @@ interface Builder {
428
478
@return a builder instance to construct a {@link EnhancedDocument}.
429
479
@param <T> the type of the value to set.
430
480
*/
431
- <T > Builder putWithType (String attributeName , T value , EnhancedType <T > type );
481
+ <T > Builder put (String attributeName , T value , Class <T > type );
432
482
433
483
/**
434
484
* Appends an attribute with the specified name and a Map containing keys and values of {@link EnhancedType} K
@@ -437,14 +487,14 @@ interface Builder {
437
487
* values.
438
488
* <p>For example, to insert a map with String keys and Long values:
439
489
* {@snippet :
440
- * EnhancedDocument.builder().putMapOfType ("stringMap", mapWithStringKeyNumberValue, EnhancedType.of(String.class),
490
+ * EnhancedDocument.builder().putMap ("stringMap", mapWithStringKeyNumberValue, EnhancedType.of(String.class),
441
491
* EnhancedType.of(String.class), EnhancedType.of(Long.class))
442
- * }
492
+ *}
443
493
* <p>For example, to insert a map of String Key and Custom Values:
444
494
* {@snippet :
445
- * EnhancedDocument.builder().putMapOfType ("customMap", mapWithStringKeyCustomValue, EnhancedType.of(String.class),
495
+ * EnhancedDocument.builder().putMap ("customMap", mapWithStringKeyCustomValue, EnhancedType.of(String.class),
446
496
* EnhancedType.of(String.class), EnhancedType.of(Custom.class))
447
- * }
497
+ *}
448
498
* Note that the AttributeConverterProvider added to the DocumentBuilder should provide the converter for the classes
449
499
* K and V that
450
500
* are to be inserted.
@@ -454,7 +504,7 @@ interface Builder {
454
504
* @param valueType Enhanced type of Value class.
455
505
* @return Builder instance to construct a {@link EnhancedDocument}
456
506
*/
457
- <K , V > Builder putMapOfType (String attributeName , Map <K , V > value , EnhancedType <K > keyType , EnhancedType <V > valueType );
507
+ <K , V > Builder putMap (String attributeName , Map <K , V > value , EnhancedType <K > keyType , EnhancedType <V > valueType );
458
508
459
509
/**
460
510
Appends an attribute to the document builder with the specified name and value of a JSON document in string format.
@@ -464,6 +514,15 @@ interface Builder {
464
514
*/
465
515
Builder putJson (String attributeName , String json );
466
516
517
+
518
+ /**
519
+ * Removes a previously appended attribute.
520
+ * This can be used where a previously added attribute to the Builder is no longer needed.
521
+ * @param attributeName The attribute that needs to be removed.
522
+ * @return Builder instance to construct a {@link EnhancedDocument}
523
+ */
524
+ Builder remove (String attributeName );
525
+
467
526
/**
468
527
* Appends collection of attributeConverterProvider to the document builder. These
469
528
* AttributeConverterProvider will be used to convert any given key to custom type T.
0 commit comments