Fix license header violations in yang-data-impl
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / codec / Uint32StringCodec.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.yangtools.yang.data.impl.codec;
10
11 import com.google.common.base.Optional;
12 import org.opendaylight.yangtools.yang.data.api.codec.Uint32Codec;
13 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
14
15 class Uint32StringCodec extends AbstractIntegerStringCodec<Long, UnsignedIntegerTypeDefinition> implements
16         Uint32Codec<String> {
17
18     protected Uint32StringCodec(final Optional<UnsignedIntegerTypeDefinition> typeDef) {
19         super(typeDef, extractRange(typeDef.orNull()), Long.class);
20     }
21
22     @Override
23     public final Long deserialize(final String stringRepresentation, final int base) {
24         return Long.valueOf(stringRepresentation, base);
25     }
26
27     @Override
28     public final String serialize(final Long data) {
29         return data == null ? "" : data.toString();
30     }
31
32     @Override
33     protected Long convertValue(final Number value) {
34         return value.longValue();
35     }
36 }