@Retention(RUNTIME) @Target({FIELD,TYPE,METHOD}) public @interface BooleanFlag
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();
}
}
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/jdk.jfr/jdk/jfr/BooleanFlag.html