Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion client/src/com/aerospike/client/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down