Event field annotation, specifies that the value is a boolean flag, a
true
or false
value.
The following example shows how the BooleanFlag
annotation can be
used to describe that a setting is a boolean value. This information can be
used by a graphical user interface to display the setting as a checkbox.
@BooleanFlag
@Name("example.Rollback")
@Label("Rollback")
@Description("Include transactions that are rollbacked")
public static class RollbackSetting extends SettingControl {
private boolean value = true;
@Override
public String combine(Set<String> values) {
return values.contains("true") ? "true" : "false";
}
@Override
public void setValue(String settingValue) {
value = "true".equals(settingValue);
}
@Override
public String getValue() {
return Boolean.toString(value);
}
public boolean shouldEmit() {
return value;
}
}
@Name("example.Transaction")
public static class TransactionEvent extends Event {
@Label("Context")
String context;
@Label("Rollback")
boolean rollback;
@SettingDefinition
@Name("rollback")
public boolean rollback(RollbackSetting rollbackSetting) {
return rollback && rollbackSetting.shouldEmit();
}
}
- Since:
- 9