final ComputationTargetTypeMap<Function1<ComputationTarget, ValueProperties>> map = new ComputationTargetTypeMap<>();
map.put(ComputationTargetType.POSITION, new Function1<ComputationTarget, ValueProperties>() {
@Override
public ValueProperties execute(final ComputationTarget target) {
final Security security = target.getPosition().getSecurity();
final Currency ccy = getCurrency(security);
if (ccy != null) {
return ValueProperties.with(ValuePropertyNames.CURRENCY, ccy.getCode()).get();
} else {
return ValueProperties.none();
}
}
});
map.put(ComputationTargetType.SECURITY, new Function1<ComputationTarget, ValueProperties>() {
@Override
public ValueProperties execute(final ComputationTarget target) {
final Security security = target.getSecurity();
final Currency ccy = getCurrency(security);
if (ccy != null) {
return ValueProperties.with(ValuePropertyNames.CURRENCY, ccy.getCode()).get();
} else {
return ValueProperties.none();
}
}
});
map.put(ComputationTargetType.TRADE, new Function1<ComputationTarget, ValueProperties>() {
@Override
public ValueProperties execute(final ComputationTarget target) {
final Security security = target.getTrade().getSecurity();
final Currency ccy = getCurrency(security);
if (ccy != null) {
return ValueProperties.with(ValuePropertyNames.CURRENCY, ccy.getCode()).get();
} else {
return ValueProperties.none();
}
}
});