2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.yangtools.yang.data.impl.codec;
11 import com.google.common.base.Optional;
12 import java.math.BigInteger;
13 import org.opendaylight.yangtools.yang.data.api.codec.Uint64Codec;
14 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
16 class Uint64StringCodec extends AbstractIntegerStringCodec<BigInteger, UnsignedIntegerTypeDefinition> implements
19 protected Uint64StringCodec(final Optional<UnsignedIntegerTypeDefinition> typeDef) {
20 super(typeDef, extractRange(typeDef.orNull()), BigInteger.class);
24 public final BigInteger deserialize(final String stringRepresentation, final int base) {
25 return new BigInteger(stringRepresentation, base);
29 public final String serialize(final BigInteger data) {
30 return data == null ? "" : data.toString();
34 protected BigInteger convertValue(final Number value) {
35 if (value instanceof BigInteger) {
36 return (BigInteger) value;
38 return BigInteger.valueOf(value.longValue());