diff --git a/client/src/com/aerospike/client/Value.java b/client/src/com/aerospike/client/Value.java index 0dc598846..3a33ab87e 100644 --- a/client/src/com/aerospike/client/Value.java +++ b/client/src/com/aerospike/client/Value.java @@ -1139,6 +1139,9 @@ public long toLong() { * Boolean value. */ public static final class BooleanValue extends Value { + public static final BooleanValue TRUE = new BooleanValue(true); + public static final BooleanValue FALSE = new BooleanValue(false); + private final boolean value; public BooleanValue(boolean value) { @@ -1207,7 +1210,21 @@ public int toInteger() { public long toLong() { return value? 1L : 0L; } - } + + /** + * Return the primitive boolean held by this Value. + */ + public boolean getValue() { + return value; + } + /** + * Factory method that returns a cached instance for true/false. + * This improves performance by reducing object allocations in hot paths. + */ + public static BooleanValue of(boolean v) { + return v ? TRUE : FALSE; + } +} /** * Boolean value that converts to integer when sending a bin to the server.