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
+ * .putWithTypethType ("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
+ * Custom 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
+ * Custom 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 either 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 );
@@ -256,15 +281,15 @@ static Builder builder() {
256
281
String getJson (String attributeName );
257
282
258
283
/**
259
- * Gets the {@link Boolean} value for the specified attribute.
284
+ * Gets the boolean value for the specified attribute.
260
285
*
261
286
* @param attributeName Name of the attribute.
262
287
* @return value of the specified attribute in the current document as a non-null Boolean.
263
288
* @throws RuntimeException
264
289
* if either the attribute doesn't exist or if the attribute
265
290
* value cannot be converted into a boolean value.
266
291
*/
267
- Boolean getBoolean (String attributeName );
292
+ boolean getBoolean (String attributeName );
268
293
269
294
270
295
/**
@@ -276,7 +301,7 @@ static Builder builder() {
276
301
* @param attributeName Name of the attribute.
277
302
* @return value of the specified attribute in the current document as a List of {@link AttributeValue}
278
303
*/
279
- List <AttributeValue > getUnknownTypeList (String attributeName );
304
+ List <AttributeValue > getListOfUnknownList (String attributeName );
280
305
281
306
/**
282
307
* Retrieves a Map with String keys and corresponding AttributeValue objects as values for a specified attribute in a
@@ -287,7 +312,7 @@ static Builder builder() {
287
312
* @param attributeName Name of the attribute.
288
313
* @return value of the specified attribute in the current document as a {@link AttributeValue}
289
314
*/
290
- Map <String , AttributeValue > getUnknownTypeMap (String attributeName );
315
+ Map <String , AttributeValue > getMapOfUnknownType (String attributeName );
291
316
292
317
/**
293
318
*
@@ -350,7 +375,7 @@ interface Builder {
350
375
* @param value The boolean value that needs to be set.
351
376
* @return Builder instance to construct a {@link EnhancedDocument}
352
377
*/
353
- Builder putBoolean (String attributeName , Boolean value );
378
+ Builder putBoolean (String attributeName , boolean value );
354
379
355
380
/**
356
381
* Appends an attribute of name attributeName with a null value.
@@ -414,11 +439,33 @@ interface Builder {
414
439
* provider.
415
440
* Example:
416
441
{@snippet :
417
- EnhancedDocument.builder().putWithType("customKey", customValue, EnhancedType.of(CustomClass.class));
418
- * }
442
+ * EnhancedDocument.builder().put("customKey", customValue, EnhancedType.of(CustomClass.class));
443
+ *}
444
+ * Use {@link #putString(String, String)} or {@link #putNumber(String, Number)} for inserting simple value types of
445
+ * attributes.
446
+ * Use {@link #putList(String, List, EnhancedType)} or {@link #putMap(String, Map, EnhancedType, EnhancedType)} for
447
+ * inserting collections of attribute values.
448
+ * Note that the attribute converter provider added to the DocumentBuilder must provide the converter for the class T
449
+ * that is to be inserted.
450
+ @param attributeName the name of the attribute to be added to the document.
451
+ @param value the value to set.
452
+ @param type the Enhanced type of the value to set.
453
+ @return a builder instance to construct a {@link EnhancedDocument}.
454
+ @param <T> the type of the value to set.
455
+ */
456
+ <T > Builder put (String attributeName , T value , EnhancedType <T > type );
457
+
458
+ /**
459
+ * Appends an attribute named {@code attributeName} with a value of Class type T.
460
+ * Use this method to insert attribute values of custom types that have attribute converters defined in a converter
461
+ * provider.
462
+ * Example:
463
+ {@snippet :
464
+ * EnhancedDocument.builder().put("customKey", customValue, CustomClass.class);
465
+ *}
419
466
* Use {@link #putString(String, String)} or {@link #putNumber(String, Number)} for inserting simple value types of
420
467
* attributes.
421
- * Use {@link #putList(String, List, EnhancedType)} or {@link #putMapOfType (String, Map, EnhancedType, EnhancedType)} for
468
+ * Use {@link #putList(String, List, EnhancedType)} or {@link #putMap (String, Map, EnhancedType, EnhancedType)} for
422
469
* inserting collections of attribute values.
423
470
* Note that the attribute converter provider added to the DocumentBuilder must provide the converter for the class T
424
471
* that is to be inserted.
@@ -428,7 +475,7 @@ interface Builder {
428
475
@return a builder instance to construct a {@link EnhancedDocument}.
429
476
@param <T> the type of the value to set.
430
477
*/
431
- <T > Builder putWithType (String attributeName , T value , EnhancedType <T > type );
478
+ <T > Builder put (String attributeName , T value , Class <T > type );
432
479
433
480
/**
434
481
* Appends an attribute with the specified name and a Map containing keys and values of {@link EnhancedType} K
@@ -437,14 +484,14 @@ interface Builder {
437
484
* values.
438
485
* <p>For example, to insert a map with String keys and Long values:
439
486
* {@snippet :
440
- * EnhancedDocument.builder().putMapOfType ("stringMap", mapWithStringKeyNumberValue, EnhancedType.of(String.class),
487
+ * EnhancedDocument.builder().putMap ("stringMap", mapWithStringKeyNumberValue, EnhancedType.of(String.class),
441
488
* EnhancedType.of(String.class), EnhancedType.of(Long.class))
442
- * }
489
+ *}
443
490
* <p>For example, to insert a map of String Key and Custom Values:
444
491
* {@snippet :
445
- * EnhancedDocument.builder().putMapOfType ("customMap", mapWithStringKeyCustomValue, EnhancedType.of(String.class),
492
+ * EnhancedDocument.builder().putMap ("customMap", mapWithStringKeyCustomValue, EnhancedType.of(String.class),
446
493
* EnhancedType.of(String.class), EnhancedType.of(Custom.class))
447
- * }
494
+ *}
448
495
* Note that the AttributeConverterProvider added to the DocumentBuilder should provide the converter for the classes
449
496
* K and V that
450
497
* are to be inserted.
@@ -454,7 +501,7 @@ interface Builder {
454
501
* @param valueType Enhanced type of Value class.
455
502
* @return Builder instance to construct a {@link EnhancedDocument}
456
503
*/
457
- <K , V > Builder putMapOfType (String attributeName , Map <K , V > value , EnhancedType <K > keyType , EnhancedType <V > valueType );
504
+ <K , V > Builder putMap (String attributeName , Map <K , V > value , EnhancedType <K > keyType , EnhancedType <V > valueType );
458
505
459
506
/**
460
507
Appends an attribute to the document builder with the specified name and value of a JSON document in string format.
@@ -464,6 +511,15 @@ interface Builder {
464
511
*/
465
512
Builder putJson (String attributeName , String json );
466
513
514
+
515
+ /**
516
+ * Removes a previously appended attribute.
517
+ * This can be used where a previously added attribute to the Builder is no longer needed.
518
+ * @param attributeName The attribute that needs to be removed.
519
+ * @return Builder instance to construct a {@link EnhancedDocument}
520
+ */
521
+ Builder remove (String attributeName );
522
+
467
523
/**
468
524
* Appends collection of attributeConverterProvider to the document builder. These
469
525
* AttributeConverterProvider will be used to convert any given key to custom type T.
0 commit comments