public class SegmentListConfiguration extends SegmentConfiguration
SegmentList. This stores a collection of the configurations of all the
segments in the SegmentList.
The segment configurations are mutable objects that store all of the editable settings that a
SegmentPropagator needs to run. The configurations should be designed to be able to easily get
to and modify the data you need to. When a
SegmentPropagator is propagated, the updated configuration will be passed into the method, and it
is the responsibility of the
SegmentPropagator.PropagateSegment#PropagateSegment(SegmentListResults,SegmentConfiguration,ITrackCalculationProgress)
method to use the data in the configuration properly.
| Modifier | Constructor and Description |
|---|---|
|
SegmentListConfiguration()
Initializes a new instance.
|
protected |
SegmentListConfiguration(SegmentListConfiguration existingInstance,
CopyContext context)
Initializes a new instance as a copy of an existing instance.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
clone(CopyContext context)
Clones this object using the specified context.
|
boolean |
containsSegmentConfiguration(SegmentDefinition segment)
Checks to see if the
segment has a configuration stored in this configuration. |
boolean |
containsSegmentConfiguration(String segmentName)
Checks to see if a segment configuration with the
segmentName exists in this configuration. |
boolean |
getIsNonNominalRunDifferent()
Gets a value indicating whether the associated
SegmentPropagator will behave differently if it is
being run nominally or not. |
boolean |
getNominalRun()
Gets a value indicating whether this segment is being run normally and as such its results should be
included as the final results, or if this segment is being run as part of some other
operation (commonly this is set to
false to indicate if the segment is being run in a
TargetedSegmentListOperator). |
SegmentConfiguration |
getSegmentsConfiguration(SegmentDefinition segment)
Gets the segment configuration for the
segment, or null if there is no
configuration for the segment in this. |
SegmentConfiguration |
getSegmentsConfiguration(String segmentName)
Gets the segment configuration for the
segment with the
segmentName, or null if there is no
configuration in this for such a SegmentPropagator. |
boolean |
removeSegmentConfiguration(SegmentDefinition segment)
Removes the configuration of the
segment from this configuration. |
void |
setNominalRun(boolean value)
Sets a value indicating whether this segment is being run normally and as such its results should be
included as the final results, or if this segment is being run as part of some other
operation (commonly this is set to
false to indicate if the segment is being run in a
TargetedSegmentListOperator). |
void |
setSegmentConfiguration(SegmentDefinition segment,
SegmentConfiguration configuration)
Stores the configuration of the
segment. |
getDefaultInitialState, setDefaultInitialStatepublic SegmentListConfiguration()
protected SegmentListConfiguration(@Nonnull SegmentListConfiguration existingInstance, @Nonnull CopyContext context)
See ICloneWithContext.clone(CopyContext) for more information about how to implement this constructor
in a derived class.
existingInstance - The existing instance to copy.context - A CopyContext that controls the depth of the copy.ArgumentNullException - Thrown when existingInstance or context is null.public Object clone(CopyContext context)
This method should be implemented to call a copy constructor on the class of the
object being cloned. The copy constructor should take the CopyContext as a parameter
in addition to the existing instance to copy. The copy constructor should first call
CopyContext.addObjectMapping(T, T) to identify the newly constructed instance
as a copy of the existing instance. It should then copy all fields, using
CopyContext.updateReference(T) to copy any reference fields.
A typical implementation of ICloneWithContext:
public static class MyClass implements ICloneWithContext {
public MyClass(MyClass existingInstance, CopyContext context) {
context.addObjectMapping(existingInstance, this);
someReference = context.updateReference(existingInstance.someReference);
}
@Override
public final Object clone(CopyContext context) {
return new MyClass(this, context);
}
private Object someReference;
}
In general, all fields that are reference types should be copied with a call to
CopyContext.updateReference(T). There are a couple of exceptions:
If one of these exceptions applies, the CopyContext should be given an opportunity
to update the reference before the reference is copied explicitly. Use
CopyContext.updateReference(T) to update the reference. If CopyContext.updateReference(T) returns
the original object, indicating that the context does not have a replacement registered,
then copy the object manually by invoking a Clone method, a copy constructor, or by manually
constructing a new instance and copying the values.
alwaysCopy = context.updateReference(existingInstance.alwaysCopy);
if (existingInstance.alwaysCopy != null && alwaysCopy == existingInstance.alwaysCopy) {
alwaysCopy = (AlwaysCopy) existingInstance.alwaysCopy.clone(context);
}
If you are implementing an evaluator (a class that implements IEvaluator), the
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext) method shares some responsibilities with the
copy context constructor. Code duplication can be avoided by doing the following:
CopyContext.updateReference(T). You should still call CopyContext.updateReference(T) on any references to
non-evaluators.
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext) as the last line in the constructor and pass it the
same CopyContext passed to the constructor.
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext) as normal. See the reference documentation for
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext) for more information on implementing that method.
public MyClass(MyClass existingInstance, CopyContext context) {
super(existingInstance, context);
someReference = context.updateReference(existingInstance.someReference);
evaluatorReference = existingInstance.evaluatorReference;
updateEvaluatorReferences(context);
}
@Override
public void updateEvaluatorReferences(CopyContext context) {
evaluatorReference = context.updateReference(evaluatorReference);
}
@Override
public Object clone(CopyContext context) {
return new MyClass(this, context);
}
private Object someReference;
private IEvaluator evaluatorReference;clone in interface ICloneWithContextclone in class SegmentConfigurationcontext - The context to use to perform the copy.public final void setSegmentConfiguration(SegmentDefinition segment, SegmentConfiguration configuration)
segment. When attempting to add the
segment that happens to be stored in a nested SegmentList, this
method will drill down to the SegmentListConfiguration of the segment
immediate parent SegmentList.segment - The segment whose configuration we are storing.configuration - The configuration of the segment.public final boolean removeSegmentConfiguration(SegmentDefinition segment)
segment from this configuration.segment - The segment whose configuration we are removing.true if the segments' configuration was removed successfully; otherwise false.public final boolean containsSegmentConfiguration(SegmentDefinition segment)
segment has a configuration stored in this configuration.segment - The SegmentDefinition to check for.true if the segment has a configuration
stored in this configuration; otherwise false.public final boolean containsSegmentConfiguration(String segmentName)
segmentName exists in this configuration.
This will search recursively through all
SegmentListConfigurations that are stored in this configuration.segmentName - The name of the SegmentDefinition to check for.true if the SegmentDefinition with the
segmentName has a configuration stored in this configuration; otherwise false.public SegmentConfiguration getSegmentsConfiguration(SegmentDefinition segment)
segment, or null if there is no
configuration for the segment in this.segment - Which segments configuration to return.segment.public final SegmentConfiguration getSegmentsConfiguration(String segmentName)
segment with the
segmentName, or null if there is no
configuration in this for such a SegmentPropagator.segmentName - The name of the segment whose configuration is desired.SegmentPropagator with the segmentName.public boolean getNominalRun()
false to indicate if the segment is being run in a
TargetedSegmentListOperator). By default this is true. Override this
property when one SegmentConfiguration manages another SegmentConfiguration
(as in the case of a SegmentList) and have the overridden setter set the property on all
wrapped configuration.getNominalRun in class SegmentConfigurationpublic void setNominalRun(boolean value)
false to indicate if the segment is being run in a
TargetedSegmentListOperator). By default this is true. Override this
property when one SegmentConfiguration manages another SegmentConfiguration
(as in the case of a SegmentList) and have the overridden setter set the property on all
wrapped configuration.setNominalRun in class SegmentConfigurationpublic boolean getIsNonNominalRunDifferent()
SegmentPropagator will behave differently if it is
being run nominally or not. You should overload
this property to return true if the specific segment type might behave differently in
an unofficial propagation. By default this returns false indicating
that there is no difference.getIsNonNominalRunDifferent in class SegmentConfigurationtrue if the SegmentPropagator will behave differently
based on the NominalRun (get / set) settings; otherwise false.