Enum Item

  • All Implemented Interfaces:
    Serializable, Comparable<Item>

    public enum Item
    extends Enum<Item>
    This class defines constants for various items in BASE.
    Version:
    2.0
    Author:
    Samuel
    Last modified
    $Date: 2019-03-11 12:51:33 +0100 (mån, 11 mars 2019) $
    • Field Detail

      • MAX_VALUE

        static int MAX_VALUE
      • valueMapping

        private static final Map<Integer,​Item> valueMapping
      • aliasMapping

        private static final Map<String,​Item> aliasMapping
      • value

        private final int value
      • displayValue

        private final String displayValue
      • alias

        private final String alias
      • definedPermissions

        private final Set<Permission> definedPermissions
      • getById

        private final transient Method getById
      • getQuery

        private final transient Method getQuery
      • deletionOrder

        private final float deletionOrder
    • Method Detail

      • values

        public static Item[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Item c : Item.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Item valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • getValue

        public int getValue()
        Get the integer value that is used when storing an item to the database.
      • isBasicItem

        public boolean isBasicItem()
        Is this item representing a BasicItem object or not? Some items only have data-layer representation and require special handling.
        Since:
        3.2
      • getItemClass

        public Class<? extends BasicItem> getItemClass()
        Get the class object that is used to handle items of this type.
      • getDataClass

        public Class<? extends BasicData> getDataClass()
        Get the data object that is used to store information in the database for items of this type.
      • getDefinedPermissions

        public Set<Permission> getDefinedPermissions()
        Get the permissions which are meaningful to assign to an item if this type. This is not used internally by the core, but is can be used by client applications to dynamically display a proper input form while assigning permissions.
        Returns:
        A Set containing the permissions
      • getDeletionOrder

        public float getDeletionOrder()
        Get a value indicating the deletion order. Items with a low value should be deleted before items with a high value, to minimize the risk that the BasicItem.isUsed() method returns true.
        Returns:
        The deletion order value
        Since:
        2.4
      • getById

        public <T extends BasicItem> T getById​(DbControl dc,
                                               int id)
                                        throws ItemNotFoundException,
                                               PermissionDeniedException,
                                               BaseException
        Get the item of the type represented by this enumeration constant with the specified id. Ie. Item.SAMPLE.getById() is the same as Sample.getById.
        Parameters:
        dc - The DbControl object used for database access and permission checking
        id - The id of the item
        Returns:
        An item of the type represented by this enumeration constant
        Throws:
        ItemNotFoundException - If an item with the specified id isn't found
        PermissionDeniedException - If the logged in user hasn't read permission for the item
        BaseException - If there is another error
      • supportsGetQuery

        public boolean supportsGetQuery()
        Check if getQuery() is supported by this item type.
        Since:
        3.5
      • getQuery

        public <T extends BasicItemItemQuery<T> getQuery()
        Get a query returning items of this type. This method is supported by items that declare a static parameterless getQuery() method in their item class (eg. Sample.getQuery().
        Since:
        3.5
      • getConstructor

        <T extends BasicItemConstructor<T> getConstructor()
        Get the default constructor for new objects of this type. The default constructor is a constructor that takes a BasicData object as the only parameter. For example Sample(SampleData data).
        Returns:
        The constructor, or null if no such constructor exists
        See Also:
        DbControl.getItem(Class, BasicData, Object[])
      • fromValue

        public static Item fromValue​(int value)
        Get the Item object when you know the integer code.
        Parameters:
        value - Integer code
        Returns:
        an Item enumeration.
      • fromItemClass

        public static Item fromItemClass​(Class<? extends BasicItem> itemClass)
        Get the Item object when you know the item class.
        Parameters:
        itemClass - Item class for which Item object should be returned
        Returns:
        an Item enumeration.
      • fromDataClass

        public static Item fromDataClass​(Class<? extends BasicData> dataClass)
        Get the Item object when you know the data class.
        Parameters:
        dataClass - Data class for which the Item should be returned.
        Returns:
        an Item enumeration.
      • fromClass

        public static Item fromClass​(Class<?> anyClass)
        Get the Item object when you know either the item or data class.
        Parameters:
        anyClass - The class to get corresponding Item for.
        Returns:
        The Item object, or null if no matching item is found
      • fromDataObject

        public static Item fromDataObject​(BasicData data)
        Get the Item object when you have a data layer object. This method takes Hibernate proxies into account.
        Parameters:
        data - The data layer object for which corresponding Item should be returned.
        Returns:
        The Item object, or null if no matching item is found.