Package net.sf.basedb.core.snapshot
Class AnnotationLoaderUtil
- java.lang.Object
-
- net.sf.basedb.core.snapshot.AnnotationLoaderUtil
-
- All Implemented Interfaces:
Filter<AnnotationSnapshot>
public class AnnotationLoaderUtil extends Object implements Filter<AnnotationSnapshot>
Utility implementation for simple loading of primary annotations viaSnapshotManager
.- Since:
- 3.4
- Author:
- Nicklas
-
-
Field Summary
Fields Modifier and Type Field Description private AnnotationType
at
private int
atId
private UnitConverter
converter
private DbControl
dc
private Unit
defultUnit
private Filter<AnnotationSnapshot>
extraFilter
private SnapshotManager
manager
private boolean
searchInherited
private boolean
searchPrimary
private List<AnnotationSnapshot>
snapshots
private Unit
unit
private String
unitSymbol
private Type
valueType
-
Constructor Summary
Constructors Constructor Description AnnotationLoaderUtil(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
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.AnnotationType
getAnnotationType()
The annotation type that this loader load annotations from.int
getId()
The ID of the annotation type that this loader load annotations from.AnnotationSnapshot
getSnapshot()
Get the snapshot for the last annotation found when callingfindAll(AnnotationSetSnapshot)
.List<AnnotationSnapshot>
getSnapshots()
Get all snapshots found by the lastfindAll(AnnotationSetSnapshot)
call.Unit
getUnit()
Get the unit of the last annotation values that was found byfind(AnnotationSetSnapshot)
.String
getUnitSymbol()
Get the unit symbol of the last annotation values that was found byfind(AnnotationSetSnapshot)
.List<? extends Serializable>
getValues()
Get the values from the last annotation found when callingfind(AnnotationSetSnapshot)
boolean
isSearchingInheritedAnnotations()
Is this loader searching for inherited annotations?boolean
isSearchingPrimaryAnnotations()
Is this loader searching for primary annotations?
-
-
-
Field Detail
-
dc
private final DbControl dc
-
manager
private final SnapshotManager manager
-
at
private final AnnotationType at
-
atId
private final int atId
-
valueType
private final Type valueType
-
defultUnit
private final Unit defultUnit
-
searchPrimary
private final boolean searchPrimary
-
searchInherited
private final boolean searchInherited
-
extraFilter
private Filter<AnnotationSnapshot> extraFilter
-
snapshots
private List<AnnotationSnapshot> snapshots
-
converter
private UnitConverter converter
-
unit
private Unit unit
-
unitSymbol
private String unitSymbol
-
-
Constructor Detail
-
AnnotationLoaderUtil
public AnnotationLoaderUtil(DbControl dc, SnapshotManager manager, AnnotationType at)
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 Detail
-
evaluate
public boolean evaluate(AnnotationSnapshot snapshot)
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
public AnnotationType getAnnotationType()
The annotation type that this loader load annotations from.
-
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
public boolean find(AnnotationSetSnapshot setSnapshot)
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:
findAll(AnnotationSetSnapshot)
-
find
public boolean find(AnnotationSetSnapshot setSnapshot, Filter<AnnotationSnapshot> filter)
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(AnnotationSetSnapshot, Filter)
-
findAll
public int findAll(AnnotationSetSnapshot setSnapshot)
Find and load annotations from the given annotation set snapshot.- Returns:
- The number of snapshots found
- Since:
- 3.5
-
findAll
public int findAll(AnnotationSetSnapshot setSnapshot, Filter<AnnotationSnapshot> filter)
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
public AnnotationSnapshot 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
public List<AnnotationSnapshot> getSnapshots()
Get all snapshots found by the lastfindAll(AnnotationSetSnapshot)
call.- Returns:
- A list with AnnotationSnapshot objects
-
getValues
public List<? extends Serializable> 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
public Unit 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
public String 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
-
-