Package org.hcjf.utils.bson
Interface BsonParcelable
-
- All Known Subinterfaces:
DistributedEvent,Queryable
- All Known Implementing Classes:
AckMessage,BsonParcelableMap,BusyNodeMessage,EncryptedMessage,EvaluateQueryableMessage,EventMessage,ExecuteMessage,GetMetadataMessage,Grants.Grant,HidePathMessage,InvokeMessage,JoinableMap,KeepAliveMessage,LayerInvokeMessage,LoadPluginMessage,LockMessage,LoginMessage,Message,MessageCollection,MethodInvokeMessage,MethodResponseMessage,NetworkComponent,Node,NodeIdentificationMessage,ParameterizedQuery,PublishLayerMessage,PublishObjectMessage,PublishObjectMessage.Path,PublishPathMessage,PublishPluginMessage,Query,ResponseMessage,ServerMetadata,ServiceDefinitionMessage,ServiceDefinitionResponseMessage,ServiceEndPoint,SessionMetadata,ShutdownMessage,SignalAllMessage,SignalMessage,TestNodeMessage,UnlockMessage
public interface BsonParcelableThis interface provides the default method to create a bson document of the instance and recreate the instance from bson document.- Author:
- javaito.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classBsonParcelable.BuilderInternal class to create and populate the instance serialized into the bson document.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringMAP_KEYS_FIELD_NAMEstatic java.lang.StringMAP_VALUES_FIELD_NAMEstatic java.lang.StringPARCELABLE_CLASS_NAME
-
Method Summary
Modifier and Type Method Description default java.lang.ObjectfromBson(java.lang.Class expectedDataType, java.lang.Class keyType, java.lang.Class collectionDataType, org.hcjf.bson.BsonElement element)Creates a instance using the expected data type and bson element.default java.util.MapfromBson(java.lang.Class expectedKeyType, java.lang.Class expectedValueType, org.hcjf.bson.BsonDocument document)Returns a map instance from a bson document.default java.util.CollectionfromBson(java.lang.Class expectedCollectionType, org.hcjf.bson.BsonArray array)Returns a collection instance from a bson array.default <P extends BsonParcelable>
Ppopulate(org.hcjf.bson.BsonDocument document)Populate the current instance of parcelable with all the information into the bson document.default org.hcjf.bson.BsonDocumenttoBson()Returns the bson representation of the instance.default org.hcjf.bson.BsonElementtoBson(java.lang.String name, java.lang.Object value)Returns a bson representation of a object.default org.hcjf.bson.BsonArraytoBson(java.lang.String name, java.util.Collection collection)Returns a bson representation of a collection.default org.hcjf.bson.BsonDocumenttoBson(java.lang.String name, java.util.Map map)Returns a bson representation of a map.default java.lang.ClasstypeFromBson(java.lang.Class expectedType, org.hcjf.bson.BsonElement element)This method verify if the expected data type is valid, if it is not valid then trying to deduct the data type from information into the bson element.
-
-
-
Field Detail
-
MAP_KEYS_FIELD_NAME
static final java.lang.String MAP_KEYS_FIELD_NAME
- See Also:
- Constant Field Values
-
MAP_VALUES_FIELD_NAME
static final java.lang.String MAP_VALUES_FIELD_NAME
- See Also:
- Constant Field Values
-
PARCELABLE_CLASS_NAME
static final java.lang.String PARCELABLE_CLASS_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
toBson
default org.hcjf.bson.BsonDocument toBson()
Returns the bson representation of the instance.- Returns:
- Bson representation.
-
toBson
default org.hcjf.bson.BsonDocument toBson(java.lang.String name, java.util.Map map)Returns a bson representation of a map.- Parameters:
name- Name of the map.map- Map instance.- Returns:
- Bson representation.
-
toBson
default org.hcjf.bson.BsonArray toBson(java.lang.String name, java.util.Collection collection)Returns a bson representation of a collection.- Parameters:
name- Name of the collection.collection- Collection instance.- Returns:
- Bson representation.
-
toBson
default org.hcjf.bson.BsonElement toBson(java.lang.String name, java.lang.Object value)Returns a bson representation of a object.- Parameters:
name- Name of the object.value- Object instance.- Returns:
- Bson representation.
-
populate
default <P extends BsonParcelable> P populate(org.hcjf.bson.BsonDocument document)
Populate the current instance of parcelable with all the information into the bson document.- Type Parameters:
P- Expected parcelable type.- Parameters:
document- Bson document to populate the parcelable.- Returns:
- Return the same instance that was populated.
-
fromBson
default java.util.Map fromBson(java.lang.Class expectedKeyType, java.lang.Class expectedValueType, org.hcjf.bson.BsonDocument document)Returns a map instance from a bson document.- Parameters:
document- Bson document to create the map instance.expectedKeyType- Expected key type.expectedValueType- Expected value type.- Returns:
- Map instance.
-
fromBson
default java.util.Collection fromBson(java.lang.Class expectedCollectionType, org.hcjf.bson.BsonArray array)Returns a collection instance from a bson array.- Parameters:
array- Bson array to create the collection instance.expectedCollectionType- Expected data type for map's or collection's values.- Returns:
- Collection instance.
-
fromBson
default java.lang.Object fromBson(java.lang.Class expectedDataType, java.lang.Class keyType, java.lang.Class collectionDataType, org.hcjf.bson.BsonElement element)Creates a instance using the expected data type and bson element.- Parameters:
expectedDataType- Expected result data type.element- Bson element.keyType- Expected data type for map's key.collectionDataType- Expected data type for map's or collection's values.- Returns:
- Object instance.
-
typeFromBson
default java.lang.Class typeFromBson(java.lang.Class expectedType, org.hcjf.bson.BsonElement element)This method verify if the expected data type is valid, if it is not valid then trying to deduct the data type from information into the bson element.- Parameters:
expectedType- Expected data type.element- Bson element.- Returns:
- Valid data type.
-
-