Class Metadata<C>


  • public class Metadata<C>
    extends Object
    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) $
    • Field Detail

      • annotatableItems

        private static Set<Item> annotatableItems
      • shareableItems

        private static Set<Item> shareableItems
      • removableItems

        private static Set<Item> removableItems
      • ownableItems

        private static Set<Item> ownableItems
      • diskConsumableItems

        private static Set<Item> diskConsumableItems
      • fileStoreEnabledItems

        private static Set<Item> fileStoreEnabledItems
      • subtypableItems

        private static Set<Item> subtypableItems
      • listableItems

        private static Set<Item> listableItems
      • nameableItems

        private static Set<Item> nameableItems
      • isInitialised

        private static boolean isInitialised
      • instances

        private static final Map<String,​Metadata<?>> instances
        Cache of Metadata instances. Only one instance for each type of item exists.
      • entityName

        private final String entityName
      • clazz

        private final Class<C> clazz
    • Method Detail

      • init

        static void init()
      • unload

        static void unload()
        Unload all settings.
      • getImplementingItems

        private static Set<Item> getImplementingItems​(Class<?> clazz)
        Get all Item:s implementing/extinding the specified interface/class.
      • getAnnotatableItems

        public static Set<Item> getAnnotatableItems()
        Get a set containing all Annotatable item types. The set cannot be modified.
      • getShareableItems

        public static Set<Item> getShareableItems()
        Get a set containing all Shareable item types. The set cannot be modified.
      • getRemovableItems

        public static Set<Item> getRemovableItems()
        Get a set containing all Removable item types. The set cannot be modified.
      • getOwnableItems

        public static Set<Item> getOwnableItems()
        Get a set containing all Ownable item types. The set cannot be modified.
      • getDiskConsumableItems

        public static Set<Item> getDiskConsumableItems()
        Get a set containing all DiskConsumable item types. The set cannot be modified.
      • getFileStoreEnabledItems

        public static Set<Item> getFileStoreEnabledItems()
        Get a set containing all FileStoreEnabled item types. The set cannot be modified.
      • getSubtypableItems

        public static Set<Item> getSubtypableItems()
        Get a set containing all Subtypable item types. The set cannot be modified.
        Since:
        3.0
      • getListableItems

        public static Set<Item> getListableItems()
        Get a set containing all Listable item types. The set cannot be modified.
        Since:
        3.5
      • getNameableItems

        public static Set<Item> getNameableItems()
        Get a set containing all Nameable item types. The set cannot be modified.
        Since:
        3.17
      • getInstance

        public static <I> Metadata<I> getInstance​(Class<I> itemClass)
                                           throws BaseException
        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

        public static <I> Metadata<I> getInstance​(Class<I> clazz,
                                                  String entityName)
                                           throws BaseException
        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 class
        entityName - The entity name for the item, normally this is clazz.getName() but some entities, for example RawData, have multiple names
        Returns:
        a new instance of this class
        Throws:
        BaseException - If a new instance could not be created.
      • getPropertyPath

        public <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 regular get 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 null
        InvalidDataException - If the path is not a valid path
        Since:
        2.15