import java.io.DataInput;
import java.io.IOException;
import java.io.StringReader;
-import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.dom.DOMSource;
import org.opendaylight.yangtools.util.ImmutableOffsetMapTemplate;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
return readStringBytes();
case LithiumValue.BIG_DECIMAL_TYPE:
- return new BigDecimal(input.readUTF());
+ return Decimal64.valueOf(input.readUTF());
case LithiumValue.BIG_INTEGER_TYPE:
return new BigInteger(input.readUTF());
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
.put(Short.class, LithiumValue.SHORT_TYPE)
.put(BigInteger.class, LithiumValue.BIG_INTEGER_TYPE)
.put(BigDecimal.class, LithiumValue.BIG_DECIMAL_TYPE)
+ .put(Decimal64.class, LithiumValue.BIG_DECIMAL_TYPE)
.put(byte[].class, LithiumValue.BINARY_TYPE)
.put(Empty.class, LithiumValue.EMPTY_TYPE)
.build();
import java.io.DataInput;
import java.io.IOException;
import java.io.StringReader;
-import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.rfc8528.data.api.MountPointIdentifier;
import org.opendaylight.yangtools.util.xml.UntrustedXML;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
return Uint64.fromLongBits(input.readInt() & 0xFFFFFFFFL);
case MagnesiumValue.BIGDECIMAL:
// FIXME: use string -> BigDecimal cache
- return new BigDecimal(input.readUTF());
+ return Decimal64.valueOf(input.readUTF());
case MagnesiumValue.BIGINTEGER:
return readBigInteger();
case MagnesiumValue.STRING_EMPTY:
import javax.xml.transform.stream.StreamResult;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.rfc8528.data.api.MountPointIdentifier;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
output.writeByte(MagnesiumValue.EMPTY);
} else if (value instanceof Set) {
writeValue((Set<?>) value);
- } else if (value instanceof BigDecimal) {
- writeValue((BigDecimal) value);
+ } else if (value instanceof BigDecimal || value instanceof Decimal64) {
+ output.writeByte(MagnesiumValue.BIGDECIMAL);
+ output.writeUTF(value.toString());
} else if (value instanceof BigInteger) {
writeValue((BigInteger) value);
} else {
}
}
- private void writeValue(final BigDecimal value) throws IOException {
- output.writeByte(MagnesiumValue.BIGDECIMAL);
- output.writeUTF(value.toString());
- }
-
abstract void writeValue(BigInteger value) throws IOException;
private void writeValue(final String value) throws IOException {
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
-import java.math.BigDecimal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
.withChild(ImmutableNodes.leafNode(SHORT_LEAF_QNAME, SHORT_ID))
.withChild(ImmutableNodes.leafNode(BYTE_LEAF_QNAME, BYTE_ID))
.withChild(ImmutableNodes.leafNode(TestModel.BIGINTEGER_LEAF_QNAME, uint64.apply("100")))
- .withChild(ImmutableNodes.leafNode(TestModel.BIGDECIMAL_LEAF_QNAME, BigDecimal.valueOf(1.2)))
+ .withChild(ImmutableNodes.leafNode(TestModel.BIGDECIMAL_LEAF_QNAME, Decimal64.valueOf("1.2")))
.withChild(ImmutableNodes.leafNode(SOME_REF_QNAME, instanceID))
.withChild(ImmutableNodes.leafNode(MYIDENTITY_QNAME, DESC_QNAME))
.withChild(Builders.unkeyedListBuilder()