T
- input type of features contained in the listpublic class FeatureList<T extends FeatureInput> extends AnchorBean<FeatureList<T>> implements Iterable<Feature<T>>
for the preferred means of creating instances.
Constructor and Description |
---|
FeatureList()
Creates with an empty list.
|
FeatureList(Feature<T> feature)
Creates with a single
Feature . |
FeatureList(int capacity)
Creates with an empty list of particular capacity.
|
FeatureList(List<Feature<T>> list)
Wraps an existing list.
|
FeatureList(java.util.stream.Stream<Feature<T>> stream)
Creates from a stream of
Feature s. |
Modifier and Type | Method and Description |
---|---|
void |
add(Feature<? extends T> feature)
Adds a feature to the current list.
|
void |
addAll(FeatureList<? extends T> toAdd)
Add all the features in
other to the current list. |
FeatureList<T> |
append(Optional<FeatureList<T>> featureList)
Appends the features one or more (optional) feature-lists to the existing list.
|
List<Feature<T>> |
asList()
Exposes the underlying list of features in this data-structure.
|
void |
clear()
Removes all of the elements from this list.
|
FeatureNameList |
deriveNames()
Derives the names of the features.
|
String |
describeBean()
A (maybe longer) description identifying the bean and perhaps its key parameters.
|
<S extends FeatureInput,E extends Exception> |
filterAndMap(java.util.function.Predicate<Feature<T>> predicate,
CheckedFunction<Feature<T>,Feature<S>,E> mappingFunction)
|
Feature<T> |
get(int index)
Returns the element at the specified position in this list.
|
List<Feature<T>> |
getList()
The list of features.
|
void |
initializeRecursive(FeatureInitialization initialization,
Logger logger)
Initializes all features in the list, and recursively any features they contain.
|
boolean |
isEmpty()
Returns
true if this list contains no elements. |
Iterator<Feature<T>> |
iterator() |
<S extends FeatureInput,E extends Exception> |
map(CheckedFunction<Feature<T>,Feature<S>,E> mapFunc)
Creates a new feature-list where each feature is the result of applying a map-function to an
existing feature.
|
void |
setList(List<Feature<T>> list)
The list of features.
|
FeatureList<T> |
shallowDuplicate()
Creates a new feature-list which contains identical elements.
|
int |
size()
Returns the number of elements in this list.
|
FeatureList<T> |
sort(Comparator<Feature<T>> comparator)
Creates a new feature-list sorted in a particular order.
|
checkMisconfigured, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public FeatureList()
public FeatureList(int capacity)
capacity
- initial capacity of the created empty list.public FeatureList(Feature<T> feature)
Feature
.feature
- the feature.public FeatureList(java.util.stream.Stream<Feature<T>> stream)
Feature
s.stream
- the stream of features.public void initializeRecursive(FeatureInitialization initialization, Logger logger) throws InitializeException
A feature must be initialized before being used for calculation.
initialization
- the initialization parameters.logger
- the logger.InitializeException
- if any feature cannot be successfully initialized.public <S extends FeatureInput,E extends Exception> FeatureList<S> map(CheckedFunction<Feature<T>,Feature<S>,E> mapFunc) throws E extends Exception
S
- input-type of feature to be created as result of mappingE
- exception that can be thrown during mappingmapFunc
- function to perform the mapping of each item.E
- if the mapping-function throws this exception.E extends Exception
public <S extends FeatureInput,E extends Exception> FeatureList<S> filterAndMap(java.util.function.Predicate<Feature<T>> predicate, CheckedFunction<Feature<T>,Feature<S>,E> mappingFunction) throws E extends Exception
map(org.anchoranalysis.core.functional.checked.CheckedFunction<org.anchoranalysis.feature.bean.Feature<T>, org.anchoranalysis.feature.bean.Feature<S>, E>)
.
This is an immutable operation.
S
- input-type of feature to be created as result of mappingE
- exception that can be thrown during mappingmappingFunction
- the function that performs the mapping.predicate
- iff true object is included, otherwise excluded.E
- if the mapping-function throws this exception.E extends Exception
public FeatureList<T> append(Optional<FeatureList<T>> featureList)
This is an immutable operation and the existing list is not altered.
featureList
- the optional feature-lists to append.public FeatureNameList deriveNames()
public FeatureList<T> sort(Comparator<Feature<T>> comparator)
comparator
- used to determine the order of elements when sorting.public FeatureList<T> shallowDuplicate()
public void add(Feature<? extends T> feature)
feature
- the feature to add.public boolean isEmpty()
true
if this list contains no elements.true
if this list contains no elements.public Iterator<Feature<T>> iterator()
iterator
in interface Iterable<Feature<T extends FeatureInput>>
public int size()
public List<Feature<T>> asList()
Changing this list, will change the current instance.
public String describeBean()
AnchorBean
By default, it returns the same as AnchorBean.getBeanName()
but beans can optionally override
it
describeBean
in class AnchorBean<FeatureList<T extends FeatureInput>>
public Feature<T> get(int index)
index
- the index.index
in the list.public void clear()
The list will be empty after this call returns.
public void addAll(FeatureList<? extends T> toAdd)
other
to the current list.toAdd
- the features to add.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.