X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2Fstream%2FValueTypes.java;h=51ff8d35006f5fba38c6b047038965105a6408e8;hb=01d87e48543865be3d802c6b5497191623b0ae37;hp=190f5969aaf395cc6e2ce1b9706d9203f655f8d1;hpb=877dc93c690dba7b2a834e0cf585d45250eb9aa2;p=controller.git diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/ValueTypes.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/ValueTypes.java index 190f5969aa..51ff8d3500 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/ValueTypes.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/ValueTypes.java @@ -13,7 +13,9 @@ import com.google.common.collect.ImmutableMap.Builder; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Map; +import java.util.Objects; import java.util.Set; +import org.opendaylight.yangtools.yang.common.Empty; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -33,8 +35,12 @@ final class ValueTypes { public static final byte BIG_INTEGER_TYPE = 10; public static final byte BIG_DECIMAL_TYPE = 11; public static final byte BINARY_TYPE = 12; + // Leaf nodes no longer allow null values. The "empty" type is now represented as + // org.opendaylight.yangtools.yang.common.Empty. This is kept for backwards compatibility. + @Deprecated public static final byte NULL_TYPE = 13; public static final byte STRING_BYTES_TYPE = 14; + public static final byte EMPTY_TYPE = 15; private static final Map, Byte> TYPES; @@ -51,6 +57,7 @@ final class ValueTypes { b.put(BigInteger.class, BIG_INTEGER_TYPE); b.put(BigDecimal.class, BIG_DECIMAL_TYPE); b.put(byte[].class, BINARY_TYPE); + b.put(Empty.class, EMPTY_TYPE); TYPES = b.build(); } @@ -60,9 +67,7 @@ final class ValueTypes { } public static byte getSerializableType(Object node) { - if (node == null) { - return NULL_TYPE; - } + Objects.requireNonNull(node); final Byte type = TYPES.get(node.getClass()); if (type != null) {