Package org.rapidcontext.core.type
Class Type
java.lang.Object
org.rapidcontext.core.storage.StorableObject
org.rapidcontext.core.type.Type
The object type initializer. This class maps type and Java class
mappings found in the storage to the actual storage type registry.
Since this type mapping class is itself uses the storage object
initialization feature, it will register itself twice (once for
bootstrapping and once from the proper storage file).
- Version:
- 1.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The dictionary key for the optional legacy type id.static final String
The dictionary key for the description text.static final String
The dictionary key for the initializer class name.static final String
The dictionary key for the property array.static final String
The dictionary key for the remote-only flag.static final Path
The connection object storage path.Fields inherited from class org.rapidcontext.core.storage.StorableObject
dict, KEY_ACTIVATED_TIME, KEY_CLASSNAME, KEY_ID, KEY_TYPE, PREFIX_COMPUTED, PREFIX_HIDDEN
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionalias()
Returns the optional legacy type id (or alias).Returns a stream of all types found in the storage.static Class
<?> Returns the initializer class for creating a Java object.static Constructor
<?> constructorFor
(Storage storage, Dict dict) Returns the constructor for creating a Java object.Returns the type description.static Type
Searches for a specific type in the storage.protected void
init()
Initializes this type mapping by registering it via the methods in the Storage class.Class
<?> Returns the type initializer class.protected static Class
<?> Loads and returns a specified class.parentType
(Storage storage) Searches for the parent type in the type hierarchy.Returns an array of type properties.boolean
remote()
Returns the remote-only flag.Methods inherited from class org.rapidcontext.core.storage.StorableObject
activate, activatedTime, destroy, id, isActive, isModified, passivate, path, serialize, sterilize, toString, type
-
Field Details
-
KEY_ALIAS
The dictionary key for the optional legacy type id.- See Also:
-
KEY_DESCRIPTION
The dictionary key for the description text.- See Also:
-
KEY_REMOTE
The dictionary key for the remote-only flag.- See Also:
-
KEY_INITIALIZER
The dictionary key for the initializer class name.- See Also:
-
KEY_PROPERTY
The dictionary key for the property array.- See Also:
-
PATH
The connection object storage path.
-
-
Constructor Details
-
Type
Creates a new type mapping from a serialized representation.- Parameters:
id
- the object identifiertype
- the object type namedict
- the serialized representation
-
-
Method Details
-
all
Returns a stream of all types found in the storage.- Parameters:
storage
- the storage to search- Returns:
- a stream of type instances found
-
find
Searches for a specific type in the storage.- Parameters:
storage
- the storage to search inid
- the type identifier- Returns:
- the type found, or null if not found
-
classFor
Returns the initializer class for creating a Java object. If no object type, initializer or className property was found, null is returned. This method will lookup the corresponding type in storage before checking for a 'className' property in the object dictionary data.- Parameters:
storage
- the storage to use for type lookupsdict
- the object dictionary data- Returns:
- the Java object class, or null if not found
-
constructorFor
Returns the constructor for creating a Java object. If no Java class was found or the constructor signature isn't correct, null is returned.- Parameters:
storage
- the storage to use for type lookupsdict
- the object dictionary data- Returns:
- the Java object constructor, or null if not found
- See Also:
-
loadClass
Loads and returns a specified class.- Parameters:
className
- the fully qualified class name to loadobjId
- the object identifier for logging- Returns:
- the class found in the class loader, or null if not found
-
init
Initializes this type mapping by registering it via the methods in the Storage class.- Overrides:
init
in classStorableObject
- Throws:
StorageException
- if the initialization failed
-
alias
Returns the optional legacy type id (or alias).- Returns:
- the type alias, or an empty string
-
description
Returns the type description.- Returns:
- the type description
-
remote
public boolean remote()Returns the remote-only flag. Remote objects are only initialized client-side, so no corresponding Java class exist.- Returns:
- true if objects are remote-only, or false otherwise (default)
-
initializer
Returns the type initializer class.- Returns:
- the type initializer class
-
properties
Returns an array of type properties. Each property should be a dictionary object containing property information. Note that parent type properties are normally also applicable, but must be retrieved separately.- Returns:
- the array of type properties, or an empty array if it didn't exist
-
parentType
Searches for the parent type in the type hierarchy. A parent type normally declares additional properties that may or may not be applicable also for this type.- Parameters:
storage
- the storage to search in- Returns:
- the parent type, or null if not found
-