summaryrefslogtreecommitdiff
path: root/java/src/Ice/BooleanOptional.java
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2012-07-27 16:04:43 -0700
committerMark Spruiell <mes@zeroc.com>2012-07-27 16:04:43 -0700
commit038a4b832342ccf710d7d57bad1d10c7b36af022 (patch)
tree01a1b287852cfcd1750a401e7be030c8f5e5a6b7 /java/src/Ice/BooleanOptional.java
parentadding more Java optional tests (diff)
downloadice-038a4b832342ccf710d7d57bad1d10c7b36af022.tar.bz2
ice-038a4b832342ccf710d7d57bad1d10c7b36af022.tar.xz
ice-038a4b832342ccf710d7d57bad1d10c7b36af022.zip
updating Java API
Diffstat (limited to 'java/src/Ice/BooleanOptional.java')
-rw-r--r--java/src/Ice/BooleanOptional.java106
1 files changed, 106 insertions, 0 deletions
diff --git a/java/src/Ice/BooleanOptional.java b/java/src/Ice/BooleanOptional.java
new file mode 100644
index 00000000000..724f89e7460
--- /dev/null
+++ b/java/src/Ice/BooleanOptional.java
@@ -0,0 +1,106 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package Ice;
+
+/**
+ * Manages an optional boolean parameter.
+ **/
+public class BooleanOptional
+{
+ /**
+ * The value defaults to unset.
+ **/
+ public BooleanOptional()
+ {
+ _isSet = false;
+ }
+
+ /**
+ * Sets the value to the given argument.
+ *
+ * @param v The initial value.
+ **/
+ public BooleanOptional(boolean v)
+ {
+ _value = v;
+ _isSet = true;
+ }
+
+ /**
+ * Sets the value to a shallow copy of the given optional.
+ *
+ * @param opt The source value.
+ **/
+ public BooleanOptional(BooleanOptional opt)
+ {
+ _value = opt._value;
+ _isSet = opt._isSet;
+ }
+
+ /**
+ * Obtains the current value.
+ *
+ * @return The current value.
+ * @throws IllegalStateException If the value is not set.
+ **/
+ public boolean get()
+ {
+ if(!_isSet)
+ {
+ throw new IllegalStateException("no value is set");
+ }
+ return _value;
+ }
+
+ /**
+ * Sets the value to the given argument.
+ *
+ * @param v The new value.
+ **/
+ public void set(boolean v)
+ {
+ _value = v;
+ _isSet = true;
+ }
+
+ /**
+ * If the given argument is set, this optional is set to a shallow copy of the argument,
+ * otherwise this optional is unset.
+ *
+ * @param opt The source value.
+ **/
+ public void set(BooleanOptional opt)
+ {
+ _value = opt._value;
+ _isSet = opt._isSet;
+ }
+
+ /**
+ * Determines whether the value is set.
+ *
+ * @return True if the value is set, false otherwise.
+ **/
+ public boolean isSet()
+ {
+ return _isSet;
+ }
+
+ /**
+ * Unsets this value.
+ **/
+ public void clear()
+ {
+ _isSet = false;
+ _value = false;
+ }
+
+ private boolean _value;
+ private boolean _isSet;
+}