Interface Document
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
BooleanDocument
,ListDocument
,MapDocument
,NullDocument
,NumberDocument
,StringDocument
@Immutable public interface Document extends Serializable
Interface for Document Types. Document types are used to carry open content that is Data with no fixed schema, data that can't be modeled using rigid types, or data that has a schema that evolves outside the purview of a service without requiring techniques like embedding JSON inside JSON strings. Document type value is serialized using the same format as its surroundings and requires no additional encoding or escaping. This interface specifies all the methods to access a Document, also provides constructor methods for instantiating Document.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Document.ListBuilder
static interface
Document.MapBuilder
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <R> R
accept(DocumentVisitor<? extends R> visitor)
Accepts a visitor to the Document.void
accept(VoidDocumentVisitor visitor)
Accepts a visitor with the Document.boolean
asBoolean()
Gets the document as aboolean
if it is a boolean.List<Document>
asList()
Gets the document as aList
if it is a document type array.Map<String,Document>
asMap()
Gets the document as aMap
.SdkNumber
asNumber()
String
asString()
Gets the document as aString
.static Document
fromBoolean(boolean booleanValue)
CreateDocument
from a boolean.static Document
fromList(List<Document> documentList)
Create aDocument.ListBuilder
for generating aDocument
by directly allowing user add Documents.static Document
fromMap(Map<String,Document> documentMap)
Creates a Document from a Map of Documents.static Document
fromNull()
Creates a document is anull
value.static Document
fromNumber(double number)
CreateDocument
from a double.static Document
fromNumber(float number)
CreateDocument
from a float.static Document
fromNumber(int number)
CreateDocument
from a int.static Document
fromNumber(long number)
CreateDocument
from a long.static Document
fromNumber(String number)
CreateDocument
from a String.static Document
fromNumber(BigDecimal number)
CreateDocument
from a BigDecimal.static Document
fromNumber(BigInteger number)
CreateDocument
from a BigInteger.static Document
fromNumber(SdkNumber number)
static Document
fromString(String string)
CreateDocument
from a string, using the provided String.default boolean
isBoolean()
default boolean
isList()
default boolean
isMap()
default boolean
isNull()
Checks if the document is anull
value.default boolean
isNumber()
default boolean
isString()
static Document.ListBuilder
listBuilder()
Provides Builder methods ofDocument.ListBuilder
to directly create Document with List of Documentsstatic Document.MapBuilder
mapBuilder()
Create aDocument.MapBuilder
for generating aDocument
by directly allowing user to put String Keys and Document Values in the builder methods.Object
unwrap()
Gets the value of the document as a Java type that represents the document type data model:boolean
,String
for Strings and Numbers,null
,List<Object>
, orMap<String, Object>
.
-
-
-
Method Detail
-
fromString
static Document fromString(String string)
CreateDocument
from a string, using the provided String.- Parameters:
string
- String value.- Returns:
- Implementation of Document that stores a String.
-
fromBoolean
static Document fromBoolean(boolean booleanValue)
CreateDocument
from a boolean.- Parameters:
booleanValue
- Boolean value.- Returns:
- Implementation of Document that stores a Boolean.
-
fromNumber
static Document fromNumber(int number)
CreateDocument
from a int.- Parameters:
number
- int type number.- Returns:
- Implementation of Document that stores a
SdkNumber
constructedSdkNumber.fromInteger(int)
.
-
fromNumber
static Document fromNumber(long number)
CreateDocument
from a long.- Parameters:
number
- long type number.- Returns:
- Implementation of Document that stores a
SdkNumber
constructedSdkNumber.longValue()
.
-
fromNumber
static Document fromNumber(float number)
CreateDocument
from a float.- Parameters:
number
- float type number.- Returns:
- Implementation of Document that stores a
SdkNumber
constructedSdkNumber.floatValue()
-
fromNumber
static Document fromNumber(double number)
CreateDocument
from a double.- Parameters:
number
- double type number.- Returns:
- Implementation of Document that stores a
SdkNumber
constructedSdkNumber.fromDouble(double)
-
fromNumber
static Document fromNumber(BigDecimal number)
CreateDocument
from a BigDecimal.- Parameters:
number
- BigDecimal type number.- Returns:
- Implementation of Document that stores a
SdkNumber
constructedSdkNumber.fromBigDecimal(BigDecimal)
-
fromNumber
static Document fromNumber(BigInteger number)
CreateDocument
from a BigInteger.- Parameters:
number
- BigInteger type number.- Returns:
- Implementation of Document that stores a
SdkNumber
constructedSdkNumber.fromBigInteger(BigInteger)
-
fromNumber
static Document fromNumber(String number)
CreateDocument
from a String.- Parameters:
number
- String representation of a number.- Returns:
- Implementation of Document that stores a
SdkNumber
constructedSdkNumber.fromString(String)
- Throws:
ParseException
- Throws ParseException when the inputString is not of Number format.
-
fromMap
static Document fromMap(Map<String,Document> documentMap)
Creates a Document from a Map of Documents.- Parameters:
documentMap
- Map with Keys of Type Strinb and Value of Document type.- Returns:
- Implementation of Document that stores a Map with String Keys and Document Values.
-
fromList
static Document fromList(List<Document> documentList)
Create aDocument.ListBuilder
for generating aDocument
by directly allowing user add Documents.- Parameters:
documentList
- List of Documents.- Returns:
- Implementation of Document that stores a Lists of Documents.
-
mapBuilder
static Document.MapBuilder mapBuilder()
Create aDocument.MapBuilder
for generating aDocument
by directly allowing user to put String Keys and Document Values in the builder methods.- Returns:
- Builder to Construct Document with Map of Documents.
-
listBuilder
static Document.ListBuilder listBuilder()
Provides Builder methods ofDocument.ListBuilder
to directly create Document with List of Documents- Returns:
- Builder methods to Construct Document with List of Documents.
-
fromNull
static Document fromNull()
Creates a document is anull
value.- Returns:
- Implementation of a Null Document.
-
unwrap
Object unwrap()
Gets the value of the document as a Java type that represents the document type data model:boolean
,String
for Strings and Numbers,null
,List<Object>
, orMap<String, Object>
.- Returns:
- Returns the document as one of a fixed set of Java types.
-
isNull
default boolean isNull()
Checks if the document is anull
value.- Returns:
- Returns true if the document is a
null
value.
-
isBoolean
default boolean isBoolean()
- Returns:
- Returns true if this document is a boolean value.
-
asBoolean
boolean asBoolean()
Gets the document as aboolean
if it is a boolean.- Returns:
- Returns the boolean value.
- Throws:
UnsupportedOperationException
- if the document is not a boolean.
-
isString
default boolean isString()
- Returns:
- Returns true if this document is a string value.
-
asString
String asString()
Gets the document as aString
.- Returns:
- Returns the string value.
- Throws:
UnsupportedOperationException
- if the document is not a string.
-
isNumber
default boolean isNumber()
- Returns:
- Returns true if this document is a number value.
-
asNumber
SdkNumber asNumber()
- Returns:
- Returns the
SdkNumber
. - Throws:
UnsupportedOperationException
- if the document is not a number.
-
isMap
default boolean isMap()
- Returns:
- Returns true if this document is a Map.
-
asMap
Map<String,Document> asMap()
Gets the document as aMap
.Each value contained in the
Map
is the same as how the value would be represented byDocument
.- Returns:
- Returns the Document map.
- Throws:
UnsupportedOperationException
- if the document is not an Map.
-
isList
default boolean isList()
- Returns:
- Returns true if this document is a document type List.
-
asList
List<Document> asList()
Gets the document as aList
if it is a document type array.Each value contained in the
List
is the same as how the value would be represented byDocument
.- Returns:
- Returns the lists of Document.
- Throws:
UnsupportedOperationException
- if the document is not an List.
-
accept
<R> R accept(DocumentVisitor<? extends R> visitor)
Accepts a visitor to the Document.- Type Parameters:
R
- visitor return type.- Parameters:
visitor
- Visitor to dispatch to.- Returns:
- Returns the accepted result.
-
accept
void accept(VoidDocumentVisitor visitor)
Accepts a visitor with the Document.- Parameters:
visitor
- Visitor to dispatch to.
-
-