Class FeatureSession
Object
FeatureSession
A single-point in the code for creating feature-sessions (a factory).
A feature session is a context needed to calculate one or more parameters (inputs to features) on one or more features.
Within this context, caching of intermediate results and other efficiencies are implemented beneath the hood.
- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends FeatureInput>
doublecalculateWith
(Feature<T> feature, T input, Logger logger) Starts a feature-session for a single feature - and performs a calculation.static <T extends FeatureInput>
FeatureCalculatorSingle<T> Starts a feature-session for a single feature.static <T extends FeatureInput>
FeatureCalculatorSingle<T> with
(Feature<T> feature, FeatureInitialization initialization, SharedFeatures sharedFeatures, Logger logger) Starts a feature-session for a single feature, with specific initialization.static <T extends FeatureInput>
FeatureCalculatorSingle<T> with
(Feature<T> feature, SharedFeatures sharedFeatures, Logger logger) Starts a feature-session for a single feature, with default initialization.static <T extends FeatureInput>
FeatureCalculatorMulti<T> with
(FeatureList<T> features, Logger logger) Starts a feature-session for a list of features, with default initialization.static <T extends FeatureInput>
FeatureCalculatorMulti<T> with
(FeatureList<T> features, FeatureInitialization initialization, Optional<SharedFeatures> sharedFeatures, Logger logger, BoundReplaceStrategy<T, ? extends ReplaceStrategy<T>> replaceStrategy) Starts a feature-session for a list of features, with particular initialization, and areplaceStrategy
.static <T extends FeatureInput>
FeatureCalculatorMulti<T> with
(FeatureList<T> features, FeatureInitialization initialization, SharedFeatures sharedFeatures, Logger logger) Starts a feature-session for a list of features, with particular initialization.
-
Method Details
-
with
public static <T extends FeatureInput> FeatureCalculatorSingle<T> with(Feature<T> feature, Logger logger) throws InitializeException Starts a feature-session for a single feature.- Type Parameters:
T
- type of parameters- Parameters:
feature
- the feature.logger
- a logger.- Returns:
- a calculator that will calculate just this feature for each parameter.
- Throws:
InitializeException
-
with
public static <T extends FeatureInput> FeatureCalculatorMulti<T> with(FeatureList<T> features, Logger logger) throws InitializeException Starts a feature-session for a list of features, with default initialization.- Type Parameters:
T
- type of parameters for all features.- Parameters:
features
- a list of features accepting uniform type.logger
- a logger.- Returns:
- a calculator that will call calculate all the features in the list for each parameter.
- Throws:
InitializeException
- if the session cannot be successfully initialized.
-
with
public static <T extends FeatureInput> FeatureCalculatorMulti<T> with(FeatureList<T> features, FeatureInitialization initialization, Optional<SharedFeatures> sharedFeatures, Logger logger, BoundReplaceStrategy<T, ? extends ReplaceStrategy<T>> replaceStrategy) throws InitializeExceptionStarts a feature-session for a list of features, with particular initialization, and areplaceStrategy
.- Type Parameters:
T
- type of parameters for all features.- Parameters:
features
- a list of features accepting uniform type.initialization
- the particular initialization.sharedFeatures
- the particular shared-features to use for initialization.logger
- a logger.replaceStrategy
- binds a specificReplaceStrategy
to newly created caches.- Returns:
- a calculator that will call calculate all the features in the list for each parameter.
- Throws:
InitializeException
- if the session cannot be successfully initialized.
-
calculateWith
public static <T extends FeatureInput> double calculateWith(Feature<T> feature, T input, Logger logger) throws FeatureCalculationException Starts a feature-session for a single feature - and performs a calculation.- Type Parameters:
T
- type of input- Parameters:
feature
- the feature.input
- for features.logger
- a logger.- Returns:
- the calculated result.
- Throws:
FeatureCalculationException
- if the feature cannot be initialized or cannot be calculated.
-