OBJECT
- The type of objectANNOTATION
- The type of annotationpublic class AnnotatedListHelper<OBJECT,ANNOTATION> extends Object
Because it might not be practical to hold all the items in the list in memory at once, the implementation only stores the index of each item, and performs an indirect lookup as required. This does mean that once you've passed the list to the constructor, you shouldn't modify it as doing so will invalidate the index. The constructor will make one single pass through all the objects in order to build the index.
Constructor and Description |
---|
AnnotatedListHelper(List<? extends Annotated<OBJECT,ANNOTATION>> list)
Construct the
AnnotatedListHelper with the given list. |
Modifier and Type | Method and Description |
---|---|
<FEATURE> List<FEATURE> |
extractFeatures(ANNOTATION annotation,
FeatureExtractor<FEATURE,OBJECT> extractor)
Extract the features corresponding to a specific annotation.
|
<FEATURE> List<FEATURE> |
extractFeaturesExclude(ANNOTATION annotation,
FeatureExtractor<FEATURE,OBJECT> extractor)
Extract the features corresponding to everything EXCEPT
the specific given annotation.
|
List<Annotated<OBJECT,ANNOTATION>> |
get(ANNOTATION annotation)
Retrieve all the items from the data that have a specific
annotation.
|
Set<ANNOTATION> |
getAnnotations()
Get the set of all known annotations
|
public AnnotatedListHelper(List<? extends Annotated<OBJECT,ANNOTATION>> list)
AnnotatedListHelper
with the given list.list
- the listpublic List<Annotated<OBJECT,ANNOTATION>> get(ANNOTATION annotation)
annotation
- the annotation to search for.public Set<ANNOTATION> getAnnotations()
public <FEATURE> List<FEATURE> extractFeatures(ANNOTATION annotation, FeatureExtractor<FEATURE,OBJECT> extractor)
List.get(int)
is called. The returned list doesn't perform
any kind of caching, so calling get multiple times on
the same object will result in the features being extracted
multiple times.
If you need to convert the list to a cached variety, you can write:
List
FEATURE
- The type of featureannotation
- the annotationextractor
- the feature extractorpublic <FEATURE> List<FEATURE> extractFeaturesExclude(ANNOTATION annotation, FeatureExtractor<FEATURE,OBJECT> extractor)
This method doesn't actually perform the extraction, rather
the returned list will perform the extraction when
List.get(int)
is called. The returned list doesn't perform
any kind of caching, so calling get multiple times on
the same object will result in the features being extracted
multiple times.
If you need to convert the list to a cached variety, you can write:
List
FEATURE
- The type of featureannotation
- the annotation to excludeextractor
- the feature extractor