Bug 2362: Added range validation as last part of deserialization.
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / codec / Uint32StringCodec.java
index f16d25e6684a5cea9f605807e44eff0e0a899343..ba305db52895a74b24a8f60caaece7c2bef93691 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
  *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
+ * This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
@@ -11,11 +11,11 @@ import com.google.common.base.Optional;
 import org.opendaylight.yangtools.yang.data.api.codec.Uint32Codec;
 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
-class Uint32StringCodec extends AbstractIntegerStringCodec<Long, UnsignedIntegerTypeDefinition>
-        implements Uint32Codec<String> {
+class Uint32StringCodec extends AbstractIntegerStringCodec<Long, UnsignedIntegerTypeDefinition> implements
+        Uint32Codec<String> {
 
     protected Uint32StringCodec(final Optional<UnsignedIntegerTypeDefinition> typeDef) {
-        super(typeDef, Long.class);
+        super(typeDef, extractRange(typeDef.orNull()), Long.class);
     }
 
     @Override
@@ -27,4 +27,9 @@ class Uint32StringCodec extends AbstractIntegerStringCodec<Long, UnsignedInteger
     public final String serialize(final Long data) {
         return data == null ? "" : data.toString();
     }
-}
\ No newline at end of file
+
+    @Override
+    protected Long convertValue(final Number value) {
+        return value.longValue();
+    }
+}