20: Use resolver in PriceAlarm
This commit is contained in:
@@ -5,8 +5,13 @@ import java.time.Instant;
|
|||||||
|
|
||||||
public final class PriceAlarm {
|
public final class PriceAlarm {
|
||||||
|
|
||||||
public PriceAlarm(PriceAlarmDefinition definition, AlarmAction action) {
|
public PriceAlarm(
|
||||||
|
PriceAlarmDefinition definition,
|
||||||
|
AlarmVariableResolver variableResolver,
|
||||||
|
AlarmAction action
|
||||||
|
) {
|
||||||
this.definition = definition;
|
this.definition = definition;
|
||||||
|
this.variableResolver = variableResolver;
|
||||||
this.action = action;
|
this.action = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,7 +22,10 @@ public final class PriceAlarm {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal target = AlarmTargetParser.parse(definition.targetExpression());
|
BigDecimal target = AlarmTargetParser.parse(
|
||||||
|
variableResolver.resolve(definition.targetExpression())
|
||||||
|
);
|
||||||
|
|
||||||
boolean reached = definition.direction().reached(
|
boolean reached = definition.direction().reached(
|
||||||
price.priceUsd(),
|
price.priceUsd(),
|
||||||
target
|
target
|
||||||
@@ -84,6 +92,7 @@ public final class PriceAlarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final PriceAlarmDefinition definition;
|
private final PriceAlarmDefinition definition;
|
||||||
|
private final AlarmVariableResolver variableResolver;
|
||||||
private final AlarmAction action;
|
private final AlarmAction action;
|
||||||
|
|
||||||
private Instant lastTriggeredAt;
|
private Instant lastTriggeredAt;
|
||||||
|
|||||||
Reference in New Issue
Block a user