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