Interface IdMethod
- All Known Implementing Classes:
AnnotationIdMethod
,FallbackIdMethod
,FileImporter.PathIdMethod
,InternalIdMethod
,MultiPropertyIdMethod
,PropertyIdMethod
public interface IdMethod
Represents an 'identification method', eg. a way to find an item among
the items that already exists in the database. This can, for example, be done
by checking the name or the internal id of the item.
- Version:
- 2.8
- Author:
- nicklas
- Last modified
- $Date: 2019-02-18 13:19:56 +0100 (mån, 18 feb. 2019) $
-
Method Summary
Modifier and TypeMethodDescriptionTry to find items with this query method.The name of this method, which should be unique among the methods that can be used at a given time.getTitle()
The display title of the method.boolean
If the identification method is truly unique or not.prepareQuery
(DbControl dc, ItemQuery<I> query) Initialise a query to be used by this identification method.default <I extends BasicItem>
booleansetIdentifierOnNewItem
(DbControl dc, I item, String identifier) Set the ID on a newly created item when this is not done by other regular column mappers.
-
Method Details
-
getMethod
String getMethod()The name of this method, which should be unique among the methods that can be used at a given time.- Returns:
- The method name
-
getTitle
String getTitle()The display title of the method. -
isTrulyUnique
boolean isTrulyUnique()If the identification method is truly unique or not. If this method returns true, thefind(DbControl, ItemQuery, String)
method will never ever return a list with more than one item. -
getColumnMappingParameterName
String getColumnMappingParameterName() -
prepareQuery
Initialise a query to be used by this identification method. The query should be a fresh query without any previous restrictions or other modifications.- Parameters:
query
- The query to prepare- Returns:
- The query that is used for item lookup
-
find
Try to find items with this query method.- Parameters:
query
- The query to use, which should have been prepared usingprepareQuery(DbControl, ItemQuery)
identifier
- The identifier of the item- Returns:
- A list with the found items, if
isTrulyUnique()
return true the list is guaranteed to have at most one item
-
setIdentifierOnNewItem
default <I extends BasicItem> boolean setIdentifierOnNewItem(DbControl dc, I item, String identifier) Set the ID on a newly created item when this is not done by other regular column mappers. The default implementation of this method does nothing.- Returns:
- TRUE if the identifier was set, FALSE if not
- Since:
- 3.15
-