Rename ValueTypes to LithiumValue 62/84562/3
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 20 Sep 2019 17:59:04 +0000 (19:59 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 23 Sep 2019 08:45:32 +0000 (10:45 +0200)
These constants are only used in Lithium-based streams, make sure
we reflect that in the name of the class, so they do not end up
being confused.

JIRA: CONTROLLER-1919
Change-Id: I2e880b825d82b8a9b76008248d7663eab4bc1d71
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractLithiumDataInput.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractLithiumDataOutput.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumValue.java [moved from opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/ValueTypes.java with 96% similarity]
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumWriteObjectMappingTest.java

index e263748..3ef0def 100644 (file)
@@ -339,54 +339,54 @@ abstract class AbstractLithiumDataInput extends AbstractNormalizedNodeDataInput
     private Object readObject() throws IOException {
         byte objectType = input.readByte();
         switch (objectType) {
-            case ValueTypes.BITS_TYPE:
+            case LithiumValue.BITS_TYPE:
                 return readObjSet();
 
-            case ValueTypes.BOOL_TYPE:
+            case LithiumValue.BOOL_TYPE:
                 return input.readBoolean();
 
-            case ValueTypes.BYTE_TYPE:
+            case LithiumValue.BYTE_TYPE:
                 return input.readByte();
 
-            case ValueTypes.INT_TYPE:
+            case LithiumValue.INT_TYPE:
                 return input.readInt();
 
-            case ValueTypes.LONG_TYPE:
+            case LithiumValue.LONG_TYPE:
                 return input.readLong();
 
-            case ValueTypes.QNAME_TYPE:
+            case LithiumValue.QNAME_TYPE:
                 return readQName();
 
-            case ValueTypes.SHORT_TYPE:
+            case LithiumValue.SHORT_TYPE:
                 return input.readShort();
 
-            case ValueTypes.STRING_TYPE:
+            case LithiumValue.STRING_TYPE:
                 return input.readUTF();
 
-            case ValueTypes.STRING_BYTES_TYPE:
+            case LithiumValue.STRING_BYTES_TYPE:
                 return readStringBytes();
 
-            case ValueTypes.BIG_DECIMAL_TYPE:
+            case LithiumValue.BIG_DECIMAL_TYPE:
                 return new BigDecimal(input.readUTF());
 
-            case ValueTypes.BIG_INTEGER_TYPE:
+            case LithiumValue.BIG_INTEGER_TYPE:
                 return new BigInteger(input.readUTF());
 
-            case ValueTypes.BINARY_TYPE:
+            case LithiumValue.BINARY_TYPE:
                 byte[] bytes = new byte[input.readInt()];
                 input.readFully(bytes);
                 return bytes;
 
-            case ValueTypes.YANG_IDENTIFIER_TYPE:
+            case LithiumValue.YANG_IDENTIFIER_TYPE:
                 return readYangInstanceIdentifierInternal();
 
-            case ValueTypes.EMPTY_TYPE:
+            case LithiumValue.EMPTY_TYPE:
             // Leaf nodes no longer allow null values and thus we no longer emit null values. Previously, the "empty"
             // yang type was represented as null so we translate an incoming null value to Empty. It was possible for
             // a BI user to set a string leaf to null and we're rolling the dice here but the chances for that are
             // very low. We'd have to know the yang type but, even if we did, we can't let a null value pass upstream
             // so we'd have to drop the leaf which might cause other issues.
-            case ValueTypes.NULL_TYPE:
+            case LithiumValue.NULL_TYPE:
                 return Empty.getInstance();
 
             default:
index 4708269..95c62fc 100644 (file)
@@ -58,17 +58,17 @@ abstract class AbstractLithiumDataOutput extends AbstractNormalizedNodeDataOutpu
     private static final Logger LOG = LoggerFactory.getLogger(AbstractLithiumDataOutput.class);
     private static final TransformerFactory TF = TransformerFactory.newInstance();
     private static final ImmutableMap<Class<?>, Byte> KNOWN_TYPES = ImmutableMap.<Class<?>, Byte>builder()
-            .put(String.class, ValueTypes.STRING_TYPE)
-            .put(Byte.class, ValueTypes.BYTE_TYPE)
-            .put(Integer.class, ValueTypes.INT_TYPE)
-            .put(Long.class, ValueTypes.LONG_TYPE)
-            .put(Boolean.class, ValueTypes.BOOL_TYPE)
-            .put(QName.class, ValueTypes.QNAME_TYPE)
-            .put(Short.class, ValueTypes.SHORT_TYPE)
-            .put(BigInteger.class, ValueTypes.BIG_INTEGER_TYPE)
-            .put(BigDecimal.class, ValueTypes.BIG_DECIMAL_TYPE)
-            .put(byte[].class, ValueTypes.BINARY_TYPE)
-            .put(Empty.class, ValueTypes.EMPTY_TYPE)
+            .put(String.class, LithiumValue.STRING_TYPE)
+            .put(Byte.class, LithiumValue.BYTE_TYPE)
+            .put(Integer.class, LithiumValue.INT_TYPE)
+            .put(Long.class, LithiumValue.LONG_TYPE)
+            .put(Boolean.class, LithiumValue.BOOL_TYPE)
+            .put(QName.class, LithiumValue.QNAME_TYPE)
+            .put(Short.class, LithiumValue.SHORT_TYPE)
+            .put(BigInteger.class, LithiumValue.BIG_INTEGER_TYPE)
+            .put(BigDecimal.class, LithiumValue.BIG_DECIMAL_TYPE)
+            .put(byte[].class, LithiumValue.BINARY_TYPE)
+            .put(Empty.class, LithiumValue.EMPTY_TYPE)
             .build();
 
     private final Map<String, Integer> stringCodeMap = new HashMap<>();
@@ -311,38 +311,38 @@ abstract class AbstractLithiumDataOutput extends AbstractNormalizedNodeDataOutpu
         output.writeByte(type);
 
         switch (type) {
-            case ValueTypes.BOOL_TYPE:
+            case LithiumValue.BOOL_TYPE:
                 output.writeBoolean((Boolean) value);
                 break;
-            case ValueTypes.QNAME_TYPE:
+            case LithiumValue.QNAME_TYPE:
                 writeQNameInternal((QName) value);
                 break;
-            case ValueTypes.INT_TYPE:
+            case LithiumValue.INT_TYPE:
                 output.writeInt((Integer) value);
                 break;
-            case ValueTypes.BYTE_TYPE:
+            case LithiumValue.BYTE_TYPE:
                 output.writeByte((Byte) value);
                 break;
-            case ValueTypes.LONG_TYPE:
+            case LithiumValue.LONG_TYPE:
                 output.writeLong((Long) value);
                 break;
-            case ValueTypes.SHORT_TYPE:
+            case LithiumValue.SHORT_TYPE:
                 output.writeShort((Short) value);
                 break;
-            case ValueTypes.BITS_TYPE:
+            case LithiumValue.BITS_TYPE:
                 writeObjSet((Set<?>) value);
                 break;
-            case ValueTypes.BINARY_TYPE:
+            case LithiumValue.BINARY_TYPE:
                 byte[] bytes = (byte[]) value;
                 output.writeInt(bytes.length);
                 output.write(bytes);
                 break;
-            case ValueTypes.YANG_IDENTIFIER_TYPE:
+            case LithiumValue.YANG_IDENTIFIER_TYPE:
                 writeYangInstanceIdentifierInternal((YangInstanceIdentifier) value);
                 break;
-            case ValueTypes.EMPTY_TYPE:
+            case LithiumValue.EMPTY_TYPE:
                 break;
-            case ValueTypes.STRING_BYTES_TYPE:
+            case LithiumValue.STRING_BYTES_TYPE:
                 final byte[] valueBytes = value.toString().getBytes(StandardCharsets.UTF_8);
                 output.writeInt(valueBytes.length);
                 output.write(valueBytes);
@@ -381,19 +381,19 @@ abstract class AbstractLithiumDataOutput extends AbstractNormalizedNodeDataOutpu
     static final byte getSerializableType(final Object node) {
         final Byte type = KNOWN_TYPES.get(requireNonNull(node).getClass());
         if (type != null) {
-            if (type == ValueTypes.STRING_TYPE
-                    && ((String) node).length() >= ValueTypes.STRING_BYTES_LENGTH_THRESHOLD) {
-                return ValueTypes.STRING_BYTES_TYPE;
+            if (type == LithiumValue.STRING_TYPE
+                    && ((String) node).length() >= LithiumValue.STRING_BYTES_LENGTH_THRESHOLD) {
+                return LithiumValue.STRING_BYTES_TYPE;
             }
             return type;
         }
 
         if (node instanceof Set) {
-            return ValueTypes.BITS_TYPE;
+            return LithiumValue.BITS_TYPE;
         }
 
         if (node instanceof YangInstanceIdentifier) {
-            return ValueTypes.YANG_IDENTIFIER_TYPE;
+            return LithiumValue.YANG_IDENTIFIER_TYPE;
         }
 
         throw new IllegalArgumentException("Unknown value type " + node.getClass().getSimpleName());
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.cluster.datastore.node.utils.stream;
 
-final class ValueTypes {
+final class LithiumValue {
     // The String length threshold beyond which a String should be encoded as bytes
     static final int STRING_BYTES_LENGTH_THRESHOLD = Short.MAX_VALUE / 4;
 
@@ -30,7 +30,7 @@ final class ValueTypes {
     static final byte STRING_BYTES_TYPE = 14;
     static final byte EMPTY_TYPE = 15;
 
-    private ValueTypes() {
+    private LithiumValue() {
         throw new UnsupportedOperationException("Utility class");
     }
 }
index 229ebaf..dc38471 100644 (file)
@@ -14,9 +14,9 @@ import org.junit.Test;
 public class LithiumWriteObjectMappingTest {
     @Test
     public void testStringType() {
-        assertEquals(ValueTypes.STRING_TYPE, AbstractLithiumDataOutput.getSerializableType("foobar"));
-        final String largeString = largeString(ValueTypes.STRING_BYTES_LENGTH_THRESHOLD);
-        assertEquals(ValueTypes.STRING_BYTES_TYPE, AbstractLithiumDataOutput.getSerializableType(largeString));
+        assertEquals(LithiumValue.STRING_TYPE, AbstractLithiumDataOutput.getSerializableType("foobar"));
+        final String largeString = largeString(LithiumValue.STRING_BYTES_LENGTH_THRESHOLD);
+        assertEquals(LithiumValue.STRING_BYTES_TYPE, AbstractLithiumDataOutput.getSerializableType(largeString));
     }
 
     private static String largeString(final int minSize) {

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.