Package org.symphonyoss.s2.canon.runtime
Interface IModelRegistry
-
- All Known Implementing Classes:
ModelRegistry
public interface IModelRegistryA model registry holds a set of entity factories and provided methods to deserialize entities using any of those factories. To do this it looks for meta data in the _type attribute of the serialized objects to select the correct factory.- Author:
- Bruce Skingle
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IEntitynewInstance(org.symphonyoss.s2.common.dom.json.ImmutableJsonObject jsonObject)Return a new entity instance parsed from the given JSON object.IEntitynewInstance(org.symphonyoss.s2.common.dom.json.ImmutableJsonObject jsonObject, String expectedTypeId)Return a new entity instance of the given type, parsed from the given JSON object.<E extends IEntity>
EnewInstance(org.symphonyoss.s2.common.dom.json.ImmutableJsonObject jsonObject, String defaultTypeId, Class<E> type)Return a new entity instance of the given type, parsed from the given input.IEntityparseOne(Reader reader)Return a new entity instance parsed from the given input.IEntityparseOne(Reader reader, String typeId)Return a new entity instance of the given type, parsed from the given input.<E extends IEntity>
EparseOne(Reader reader, String defaultTypeId, Class<E> type)Return a new entity instance of the given type, parsed from the given input.voidparseStream(InputStream in, IEntityConsumer consumer)Parse a stream of entitied from the giben input and pass them to the given consumer.
-
-
-
Method Detail
-
newInstance
IEntity newInstance(org.symphonyoss.s2.common.dom.json.ImmutableJsonObject jsonObject)
Return a new entity instance parsed from the given JSON object.- Parameters:
jsonObject- A JSON object containing the serialized form of an entity.- Returns:
- The deserialized entity.
- Throws:
NullPointerException- if the value is null.IllegalArgumentException- if the value is otherwise invalid. This may be the case if the schema defines limits on the magnitude of the value, or if a facade has been written for the type.
-
newInstance
IEntity newInstance(org.symphonyoss.s2.common.dom.json.ImmutableJsonObject jsonObject, @Nullable String expectedTypeId)
Return a new entity instance of the given type, parsed from the given JSON object.- Parameters:
jsonObject- A JSON object containing the serialized form of an entity.expectedTypeId- The type ID of the expected type.- Returns:
- The deserialized entity.
- Throws:
NullPointerException- if the value is null.IllegalArgumentException- if the value is not of the expected type or is otherwise invalid. This may be the case if the schema defines limits on the magnitude of the value, or if a facade has been written for the type.
-
parseOne
IEntity parseOne(Reader reader)
Return a new entity instance parsed from the given input.- Parameters:
reader- A Reader containing the serialized form of an entity.- Returns:
- The deserialized entity.
- Throws:
NullPointerException- if the value is null.IllegalArgumentException- if the value is not of the expected type or is otherwise invalid. This may be the case if the schema defines limits on the magnitude of the value, or if a facade has been written for the type.
-
parseOne
IEntity parseOne(Reader reader, String typeId)
Return a new entity instance of the given type, parsed from the given input.- Parameters:
reader- A Reader containing the serialized form of an entity.typeId- The type ID of the expected type.- Returns:
- The deserialized entity.
- Throws:
NullPointerException- if the value is null.IllegalArgumentException- if the value is not of the expected type or is otherwise invalid. This may be the case if the schema defines limits on the magnitude of the value, or if a facade has been written for the type.
-
parseStream
void parseStream(InputStream in, IEntityConsumer consumer) throws IOException
Parse a stream of entitied from the giben input and pass them to the given consumer.- Parameters:
in- A input stream containing serialised entities.consumer- A sink for the parsed entities.- Throws:
IOException- If there is a read error on the given input.
-
parseOne
<E extends IEntity> E parseOne(Reader reader, String defaultTypeId, Class<E> type)
Return a new entity instance of the given type, parsed from the given input. The returned entity will be an instance of the given type, but may be a sub-class. The defaultTypeId is only used in cases where there is no type information in the serialised JSON. This enables canon generated client stubs to be used with non-canon server implementations.- Parameters:
reader- A Reader containing the serialized form of an entity.defaultTypeId- The type ID of the expected type.type- The expected type of the entity.- Returns:
- The deserialized entity.
- Throws:
NullPointerException- if the value is null.IllegalArgumentException- if the value is not of the expected type or is otherwise invalid. This may be the case if the schema defines limits on the magnitude of the value, or if a facade has been written for the type.
-
newInstance
<E extends IEntity> E newInstance(org.symphonyoss.s2.common.dom.json.ImmutableJsonObject jsonObject, String defaultTypeId, Class<E> type)
Return a new entity instance of the given type, parsed from the given input. The returned entity will be an instance of the given type, but may be a sub-class. The defaultTypeId is only used in cases where there is no type information in the serialised JSON. This enables canon generated client stubs to be used with non-canon server implementations.- Parameters:
jsonObject- A JSON object containing the serialized form of an entity.defaultTypeId- The type ID of the expected type.type- The expected type of the entity.- Returns:
- The deserialized entity.
- Throws:
NullPointerException- if the value is null.IllegalArgumentException- if the value is not of the expected type or is otherwise invalid. This may be the case if the schema defines limits on the magnitude of the value, or if a facade has been written for the type.
-
-