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 org.opendaylight.yangtools.yang.data.api.codec.Int8Codec;
12 import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
14 class Int8StringCodec extends AbstractIntegerStringCodec<Byte, IntegerTypeDefinition> implements Int8Codec<String> {
16 protected Int8StringCodec(final Optional<IntegerTypeDefinition> typeDef) {
17 super(typeDef, extractRange(typeDef.orNull()), Byte.class);
21 public final Byte deserialize(final String stringRepresentation, final int base) {
22 return Byte.valueOf(stringRepresentation, base);
26 public String serialize(final Byte data) {
27 return data == null ? "" : data.toString();
31 protected Byte convertValue(final Number value) {
32 return value.byteValue();