Enum Item

  • All Implemented Interfaces:
    Serializable, Comparable<Item>

    public enum Item
    extends Enum<Item>
    This class defines constants for various items in BASE.
    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())
        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.)
        name - the name of the enum constant to be returned.
        the enum constant with the specified name
        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.
      • 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.
        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.
        The deletion order value
      • getById

        public <T extends BasicItem> T getById​(DbControl dc,
                                               int id)
                                        throws ItemNotFoundException,
        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.
        dc - The DbControl object used for database access and permission checking
        id - The id of the item
        An item of the type represented by this enumeration constant
        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.
      • 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().
      • 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).
        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.
        value - Integer code
        an Item enumeration.
      • fromItemClass

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

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

        public static Item fromClass​(Class<?> anyClass)
        Get the Item object when you know either the item or data class.
        anyClass - The class to get corresponding Item for.
        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.
        data - The data layer object for which corresponding Item should be returned.
        The Item object, or null if no matching item is found.