aboutsummaryrefslogtreecommitdiffstats
path: root/config-lib/src/main/java/com/yahoo/config/LongNode.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /config-lib/src/main/java/com/yahoo/config/LongNode.java
Publish
Diffstat (limited to 'config-lib/src/main/java/com/yahoo/config/LongNode.java')
-rwxr-xr-xconfig-lib/src/main/java/com/yahoo/config/LongNode.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/config-lib/src/main/java/com/yahoo/config/LongNode.java b/config-lib/src/main/java/com/yahoo/config/LongNode.java
new file mode 100755
index 00000000000..7a3b29c1101
--- /dev/null
+++ b/config-lib/src/main/java/com/yahoo/config/LongNode.java
@@ -0,0 +1,53 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.config;
+
+import edu.umd.cs.findbugs.annotations.NonNull;
+
+/**
+ * Represents a long in a configuration tree.
+ * @author gjoranv
+ */
+public class LongNode extends LeafNode<Long> {
+
+ public LongNode() {
+ }
+
+ public LongNode(long value) {
+ super(true);
+ this.value = value;
+ }
+
+ public Long value() {
+ return value;
+ }
+
+ @Override
+ public String getValue() {
+ return "" + value;
+ }
+
+ @Override
+ public String toString() {
+ return getValue();
+ }
+
+ @Override
+ protected boolean doSetValue(@NonNull String value) {
+ try {
+ this.value = Long.parseLong(value);
+ return true;
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ }
+
+ @Override
+ void serialize(String name, Serializer serializer) {
+ serializer.serialize(name, value);
+ }
+
+ @Override
+ void serialize(Serializer serializer) {
+ serializer.serialize(value);
+ }
+}