@Component(value="cuba_DatatypeRegistry") public class DatatypeRegistryImpl extends java.lang.Object implements DatatypeRegistry
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.Class<?>,Datatype> |
datatypeByClass |
protected java.util.Map<java.lang.String,Datatype> |
datatypeById |
NAME
Constructor and Description |
---|
DatatypeRegistryImpl() |
Modifier and Type | Method and Description |
---|---|
<T> Datatype<T> |
get(java.lang.Class<T> javaClass)
Get Datatype instance by the corresponding Java class.
|
Datatype |
get(java.lang.String id)
Get Datatype instance by its unique id
|
java.lang.String |
getId(Datatype datatype)
Returns an ID of the given datatype in the registry.
|
java.lang.String |
getIdByJavaClass(java.lang.Class<?> javaClass)
Returns an ID of a default datatype handling the given Java class.
|
java.lang.String |
getIdOrNull(Datatype datatype)
Returns an ID of the given datatype in the registry or null if
datatype is not registered |
java.util.Set<java.lang.String> |
getIds() |
<T> Datatype<T> |
getNN(java.lang.Class<T> javaClass)
Get Datatype instance by the corresponding Java class.
|
void |
register(Datatype datatype,
java.lang.String id,
boolean defaultForJavaClass)
Register a datatype instance
|
protected java.util.Map<java.lang.Class<?>,Datatype> datatypeByClass
protected java.util.Map<java.lang.String,Datatype> datatypeById
public Datatype get(java.lang.String id)
DatatypeRegistry
get
in interface DatatypeRegistry
@Nullable public <T> Datatype<T> get(java.lang.Class<T> javaClass)
DatatypeRegistry
get
in interface DatatypeRegistry
public <T> Datatype<T> getNN(java.lang.Class<T> javaClass)
getNN
in interface DatatypeRegistry
java.lang.IllegalArgumentException
- if no datatype suitable for the given type foundpublic java.lang.String getId(Datatype datatype)
DatatypeRegistry
getId
in interface DatatypeRegistry
@Nullable public java.lang.String getIdOrNull(Datatype datatype)
DatatypeRegistry
datatype
is not registeredgetIdOrNull
in interface DatatypeRegistry
public java.lang.String getIdByJavaClass(java.lang.Class<?> javaClass)
DatatypeRegistry
getIdByJavaClass
in interface DatatypeRegistry
public java.util.Set<java.lang.String> getIds()
getIds
in interface DatatypeRegistry
public void register(Datatype datatype, java.lang.String id, boolean defaultForJavaClass)
DatatypeRegistry
register
in interface DatatypeRegistry
datatype
- datatype instanceid
- unique registration iddefaultForJavaClass
- true if the datatype should be default for a Java class handled by this datatype