Class AnnotationIdMethod

  • All Implemented Interfaces:
    IdMethod

    public class AnnotationIdMethod
    extends Object
    implements IdMethod
    Identification method implementation that can use an annotation for identifying items.
    Since:
    3.15
    Author:
    nicklas
    • Constructor Detail

      • AnnotationIdMethod

        public AnnotationIdMethod​(AnnotationType annotationType)
        Create a new id method.
    • Method Detail

      • getIdMethods

        public static List<IdMethod> getIdMethods​(DbControl dc,
                                                  Item itemType)
        Get identification methods that are based on annotations. It will make a query for all annotation types that are suitable as identifiers: The value type must be one of STRING, INT or LONG It must not be an enumeration The 'identifier' flag must be set
        Parameters:
        itemType - Either a specified item or null to return all possible annotation id methods
      • getMethod

        public String getMethod()
        Description copied from interface: IdMethod
        The name of this method, which should be unique among the methods that can be used at a given time.
        Specified by:
        getMethod in interface IdMethod
        Returns:
        The method name
      • getTitle

        public String getTitle()
        Description copied from interface: IdMethod
        The display title of the method.
        Specified by:
        getTitle in interface IdMethod
      • prepareQuery

        public <I extends BasicItemItemQuery<I> prepareQuery​(DbControl dc,
                                                               ItemQuery<I> query)
        Adds a restriction to the query: property = :identifier
        Specified by:
        prepareQuery in interface IdMethod
        query - The query to prepare
        Returns:
        The query that is used for item lookup
      • setIdentifierOnNewItem

        public <I extends BasicItem> boolean setIdentifierOnNewItem​(DbControl dc,
                                                                    I item,
                                                                    String identifier)
        Set the annotation on a newly created item.
        Specified by:
        setIdentifierOnNewItem in interface IdMethod
        Returns:
        TRUE if the identifier was set, FALSE if not