Package net.sf.basedb.core.snapshot
Class AnnotationLoaderUtil
java.lang.Object
net.sf.basedb.core.snapshot.AnnotationLoaderUtil
- All Implemented Interfaces:
Filter<AnnotationSnapshot>
Utility implementation for simple loading of primary annotations
via
SnapshotManager
.- Since:
- 3.4
- Author:
- Nicklas
-
Field Summary
Modifier and TypeFieldDescriptionprivate final AnnotationType
private final int
private UnitConverter
private final DbControl
private final Unit
private Filter<AnnotationSnapshot>
private final SnapshotManager
private final boolean
private final boolean
private List<AnnotationSnapshot>
private Unit
private String
private final Type
-
Constructor Summary
ConstructorDescriptionAnnotationLoaderUtil
(DbControl dc, SnapshotManager manager, AnnotationType at) Create a loder that uses the given snapshot manager to load annotations for a single annotation type.AnnotationLoaderUtil
(DbControl dc, SnapshotManager manager, AnnotationType at, boolean searchPrimary, boolean searchInherited) Create a loder that uses the given snapshot manager to load annotations for a single annotation type. -
Method Summary
Modifier and TypeMethodDescriptionboolean
evaluate
(AnnotationSnapshot snapshot) Evaluate if the given object should pass the filter or not.boolean
find
(AnnotationSetSnapshot setSnapshot) Same as findAll but only return a boolean instead of the number of snapshots found.boolean
find
(AnnotationSetSnapshot setSnapshot, Filter<AnnotationSnapshot> filter) Same as findAll but only return a boolean instead of the number of snapshots found.int
findAll
(AnnotationSetSnapshot setSnapshot) Find and load annotations from the given annotation set snapshot.int
findAll
(AnnotationSetSnapshot setSnapshot, Filter<AnnotationSnapshot> filter) Find and load annotations from the given annotation set snapshot using an optional extra filter.The annotation type that this loader load annotations from.int
getId()
The ID of the annotation type that this loader load annotations from.Get the snapshot for the last annotation found when callingfindAll(AnnotationSetSnapshot)
.Get all snapshots found by the lastfindAll(AnnotationSetSnapshot)
call.getUnit()
Get the unit of the last annotation values that was found byfind(AnnotationSetSnapshot)
.Get the unit symbol of the last annotation values that was found byfind(AnnotationSetSnapshot)
.List<? extends Serializable>
Get the values from the last annotation found when callingfind(AnnotationSetSnapshot)
boolean
isInCategoryOrSubtype
(AnnotationTypeCategory category, ItemSubtype subtype) Checks if this annotation type is related to the given category or subtype.boolean
Is this loader searching for inherited annotations?boolean
Is this loader searching for primary annotations?boolean
When displaying annotations with multiple values, should use a bullet list be used or a simple comma-separated list.
-
Field Details
-
dc
-
manager
-
at
-
atId
private final int atId -
valueType
-
defultUnit
-
searchPrimary
private final boolean searchPrimary -
searchInherited
private final boolean searchInherited -
extraFilter
-
snapshots
-
converter
-
unit
-
unitSymbol
-
-
Constructor Details
-
AnnotationLoaderUtil
Create a loder that uses the given snapshot manager to load annotations for a single annotation type. The loader will load only primary annotations. -
AnnotationLoaderUtil
public AnnotationLoaderUtil(DbControl dc, SnapshotManager manager, AnnotationType at, boolean searchPrimary, boolean searchInherited) Create a loder that uses the given snapshot manager to load annotations for a single annotation type. The loader can be configured to load primary and/or inherited annotations.- Since:
- 3.5
-
-
Method Details
-
evaluate
Description copied from interface:Filter
Evaluate if the given object should pass the filter or not.- Specified by:
evaluate
in interfaceFilter<AnnotationSnapshot>
- Parameters:
snapshot
- The object to evaluate- Returns:
- TRUE if the object passes the filter, FALSE otherwise
-
getId
public int getId()The ID of the annotation type that this loader load annotations from. -
getAnnotationType
The annotation type that this loader load annotations from. -
useBulletList
public boolean useBulletList()When displaying annotations with multiple values, should use a bullet list be used or a simple comma-separated list. Bullet lists are used for text annotation that are not enumerations.- Since:
- 3.19.9
-
isSearchingPrimaryAnnotations
public boolean isSearchingPrimaryAnnotations()Is this loader searching for primary annotations?- Since:
- 3.5
-
isSearchingInheritedAnnotations
public boolean isSearchingInheritedAnnotations()Is this loader searching for inherited annotations?- Since:
- 3.5
-
find
Same as findAll but only return a boolean instead of the number of snapshots found.- Returns:
- TRUE if an annotation was found, FALSE if not
- See Also:
-
find
Same as findAll but only return a boolean instead of the number of snapshots found.- Returns:
- TRUE if an annotation was found, FALSE if not
- Since:
- 3.11
- See Also:
-
findAll
Find and load annotations from the given annotation set snapshot.- Returns:
- The number of snapshots found
- Since:
- 3.5
-
findAll
Find and load annotations from the given annotation set snapshot using an optional extra filter.- Returns:
- The number of snapshots found
- Since:
- 3.11
-
getSnapshot
Get the snapshot for the last annotation found when callingfindAll(AnnotationSetSnapshot)
. Note! If multiple annotation snapshots were found, this will only return the first hit.- Returns:
- A snapshot or null if no annotations are found
-
getSnapshots
Get all snapshots found by the lastfindAll(AnnotationSetSnapshot)
call.- Returns:
- A list with AnnotationSnapshot objects
-
getValues
Get the values from the last annotation found when callingfind(AnnotationSetSnapshot)
- Returns:
- A list of annotation values or null if no annotations are found
-
getUnit
Get the unit of the last annotation values that was found byfind(AnnotationSetSnapshot)
. Note that if multiple annotations was found with different units the default unit of the annotation type is used.- Returns:
- A string or null if the annotation doesn't use units
-
getUnitSymbol
Get the unit symbol of the last annotation values that was found byfind(AnnotationSetSnapshot)
.- Returns:
- A string or null if the annotation doesn't use units
-
isInCategoryOrSubtype
Checks if this annotation type is related to the given category or subtype. Both parameters may be null in which case TRUE is returned. If the category is not null onlyAnnotationTypeCategory.isInCategory(AnnotationType)
is checked. If the category is null thenItemSubtype.isInRelatedCategory(AnnotationType)
is checked.- Parameters:
category
- An annotation type category or nullsubtype
- An item subtype or null- Since:
- 3.20
-