Class PredicatePeriodCounterRTIndicator
java.lang.Object
com.wualabs.qtsurfer.engine.indicators.core.AbstractRTIndicator
com.wualabs.qtsurfer.engine.indicators.core.AbstractDecorableRTIndicator
com.wualabs.qtsurfer.engine.indicators.helpers.PredicatePeriodCounterRTIndicator
- All Implemented Interfaces:
PeriodCounter, Resettable, RTIndicator
public class PredicatePeriodCounterRTIndicator
extends AbstractDecorableRTIndicator
implements PeriodCounter
Allow count/reset based on a predicate
-
Constructor Summary
ConstructorsConstructorDescriptionPredicatePeriodCounterRTIndicator(@NonNull RTIndicator indicator, @NonNull Predicate<Double> predicate) -
Method Summary
Modifier and TypeMethodDescriptionequal(RTIndicator indicator, @NonNull Number coefficient) longgreatOrEqual(RTIndicator indicator, @NonNull Number coefficient) greatThan(RTIndicator indicator, @NonNull Number coefficient) lessOrEqual(RTIndicator indicator, @NonNull Number coefficient) lessThan(RTIndicator indicator, @NonNull Number coefficient) notEqual(RTIndicator indicator, @NonNull Number coefficient) voidfinal doubleupdate(double newValue) Updates the decorated indicator and tests the result against the predicate.Methods inherited from class AbstractDecorableRTIndicator
getIndicator, getIndicatorValueMethods inherited from class AbstractRTIndicator
equals, getDisplayHint, getMeta, getValue, hashCode, hide, isPoison, reset, setValue, toString, toString, withDisplayHint, withMeta
-
Constructor Details
-
PredicatePeriodCounterRTIndicator
public PredicatePeriodCounterRTIndicator(@NonNull @NonNull RTIndicator indicator, @NonNull @NonNull Predicate<Double> predicate)
-
-
Method Details
-
resetPeriods
public void resetPeriods()- Specified by:
resetPeriodsin interfacePeriodCounter
-
update
public final double update(double newValue) Updates the decorated indicator and tests the result against the predicate. Increments the consecutive period count while the predicate holds true; resets the count to zero as soon as the predicate fails. The indicator's value tracks the decorated indicator regardless of the predicate result.- Specified by:
updatein interfaceRTIndicator- Overrides:
updatein classAbstractRTIndicator- Parameters:
newValue- the new input value- Returns:
- the decorated indicator's computed value
-
equal
public static PredicatePeriodCounterRTIndicator equal(RTIndicator indicator, @NonNull @NonNull Number coefficient) -
notEqual
public static PredicatePeriodCounterRTIndicator notEqual(RTIndicator indicator, @NonNull @NonNull Number coefficient) -
lessThan
public static PredicatePeriodCounterRTIndicator lessThan(RTIndicator indicator, @NonNull @NonNull Number coefficient) -
lessOrEqual
public static PredicatePeriodCounterRTIndicator lessOrEqual(RTIndicator indicator, @NonNull @NonNull Number coefficient) -
greatThan
public static PredicatePeriodCounterRTIndicator greatThan(RTIndicator indicator, @NonNull @NonNull Number coefficient) -
greatOrEqual
public static PredicatePeriodCounterRTIndicator greatOrEqual(RTIndicator indicator, @NonNull @NonNull Number coefficient) -
getPeriodCount
public long getPeriodCount()- Specified by:
getPeriodCountin interfacePeriodCounter
-