Package net.sf.basedb.core
Class Metadata<C>
java.lang.Object
net.sf.basedb.core.Metadata<C>
Utility methods for retreiving metadata about items.
- Version:
- 2.0
- Author:
- Nicklas
- Last modified
- $Date: 2020-10-13 14:31:34 +0200 (Tue, 13 Oct 2020) $
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
Metadata.BasicData2ItemPropertyPath<C extends BasicData,
V extends BasicItem> Property path implementation that converts a BasicData object to a BasicItem.(package private) static class
Metadata.BasicItem2DataPropertyPath<C extends BasicItem,
V extends BasicData> Property path implementation that converts a BasicItem to a BasicData object.(package private) static class
Property path implementation which wraps a collection inside an unmodifiable collection.(package private) static class
Property path implementation that combines a list of property paths to create a long chain.(package private) static class
Property path implementation which gets a value from a component.(package private) static class
Property path implementation clones a Date.(package private) static class
Property path implementation which gets a value from an entity.(package private) static class
Property path implementation that evicts the selected item from the Hibernate first-level cache.(package private) static class
Property path implementation which gets the id from an entity.(package private) static class
Property path implementation which wraps a map inside an unmodifiable map.(package private) static class
Property path implementation that does nothing.static interface
Contract for getting the value of a specific property for an item.(package private) static class
Property path implementation that converts a ReporterScore to a ReporterListScoreData object. -
Field Summary
Modifier and TypeFieldDescriptionprivate final Map<String,
Metadata.PropertyPath> private final ClassMetadata
private final String
Cache of Metadata instances.private static boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet a set containing allAnnotatable
item types.Get a set containing allDiskConsumable
item types.Get a set containing allFileStoreEnabled
item types.getImplementingItems
(Class<?> clazz) Get allItem
:s implementing/extinding the specified interface/class.private int
getIndex
(String s, String[] list, Comparator<String> check) static <I> Metadata<I>
getInstance
(Class<I> itemClass) Get the metadata instance for the specified type of item.static <I> Metadata<I>
getInstance
(Class<I> clazz, String entityName) Get the metadata instance for the item with the specified entity name.Get a set containing allListable
item types.Get a set containing allNameable
item types.Get a set containing allOwnable
item types.<V> Metadata.PropertyPath<C,
V> getPropertyPath
(String path, boolean ignoreCase) Get a property path that can be used to retrieve a value from an item instead of using the regularget
methods.Get a set containing allRemovable
item types.Get a set containing allShareable
item types.Get a set containing allSubtypable
item types.(package private) static void
init()
toString()
(package private) static void
unload()
Unload all settings.
-
Field Details
-
annotatableItems
-
removableItems
-
ownableItems
-
diskConsumableItems
-
fileStoreEnabledItems
-
subtypableItems
-
listableItems
-
nameableItems
-
isInitialised
private static boolean isInitialised -
instances
Cache of Metadata instances. Only one instance for each type of item exists. -
classMetadata
-
entityName
-
clazz
-
cachedPaths
-
-
Constructor Details
-
Metadata
- Throws:
BaseException
-
-
Method Details
-
init
static void init() -
unload
static void unload()Unload all settings. -
getImplementingItems
Get allItem
:s implementing/extinding the specified interface/class. -
getAnnotatableItems
Get a set containing allAnnotatable
item types. The set cannot be modified. -
getRemovableItems
Get a set containing allRemovable
item types. The set cannot be modified. -
getOwnableItems
Get a set containing allOwnable
item types. The set cannot be modified. -
getDiskConsumableItems
Get a set containing allDiskConsumable
item types. The set cannot be modified. -
getFileStoreEnabledItems
Get a set containing allFileStoreEnabled
item types. The set cannot be modified. -
getSubtypableItems
Get a set containing allSubtypable
item types. The set cannot be modified.- Since:
- 3.0
-
getListableItems
Get a set containing allListable
item types. The set cannot be modified.- Since:
- 3.5
-
getNameableItems
Get a set containing allNameable
item types. The set cannot be modified.- Since:
- 3.17
-
getInstance
Get the metadata instance for the specified type of item.- Parameters:
itemClass
- The class of the item- Returns:
- a new instance of this class.
- Throws:
BaseException
- If a new instance could not be created.
-
getInstance
Get the metadata instance for the item with the specified entity name. Use this method where one class is mapped to several entities, for example RawData.- Parameters:
clazz
- The class of the item, should be either a BasicItem or BasicData classentityName
- The entity name for the item, normally this isclazz.getName()
but some entities, for exampleRawData
, have multiple names- Returns:
- a new instance of this class
- Throws:
BaseException
- If a new instance could not be created.
-
getPropertyPath
Get a property path that can be used to retrieve a value from an item instead of using the regularget
methods. The following method calls are equivalent:// Using getter method String name = item.getName(); // Using PropertyPath PropertyPath path = metadata.getPropertyPath("name"); String name = (String)path.getValue(dc, item);
You can even use dot notation to navigate to associated items:// Using getter methods String quota = item.getOwner().getQuota().getName(); // Using PropertyPath PropertyPath path = metadata.getPropertyPath("owner.quota.name"); String quota = (String)path.getValue(dc, item);
- Type Parameters:
V
- The class of the returned values- Parameters:
path
- The name of the property to get. Null is not allowed. Use . or # as a separator between property and association names- Returns:
- A property path object
- Throws:
NullPointerException
- If the path is nullInvalidDataException
- If the path is not a valid path- Since:
- 2.15
-
getIndex
-
toString
-