import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
-class EnumerationCodec extends ReflectionBasedCodec implements SchemaUnawareCodec {
+final class EnumerationCodec extends ReflectionBasedCodec implements SchemaUnawareCodec {
- ImmutableBiMap<String, Enum<?>> yangValueToBinding;
+ private final ImmutableBiMap<String, Enum<?>> yangValueToBinding;
public EnumerationCodec(final Class<? extends Enum<?>> enumeration, final Map<String, Enum<?>> schema) {
super(enumeration);
yangValueToBinding = ImmutableBiMap.copyOf(schema);
}
-
static Callable<EnumerationCodec> loader(final Class<?> returnType,
final EnumTypeDefinition enumSchema) {
Preconditions.checkArgument(Enum.class.isAssignableFrom(returnType));
};
}
-
@Override
public Object deserialize(final Object input) {
Enum<?> value = yangValueToBinding.get(input);
package org.opendaylight.yangtools.binding.data.codec.impl;
import com.google.common.collect.ImmutableSet;
-
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.Callable;
-
import org.opendaylight.yangtools.concepts.Codec;
import org.opendaylight.yangtools.yang.binding.BindingMapping;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
final class UnionTypeCodec extends ReflectionBasedCodec {
- private Constructor<?> charConstructor;
- private ImmutableSet<UnionValueOptionContext> typeCodecs;
+ private final ImmutableSet<UnionValueOptionContext> typeCodecs;
+ private final Constructor<?> charConstructor;
private UnionTypeCodec(final Class<?> unionCls,final Set<UnionValueOptionContext> codecs) {
super(unionCls);
}
}
- static final Callable<UnionTypeCodec> loader(final Class<?> unionCls, final UnionTypeDefinition unionType) {
+ static Callable<UnionTypeCodec> loader(final Class<?> unionCls, final UnionTypeDefinition unionType) {
return new Callable<UnionTypeCodec>() {
@Override
public UnionTypeCodec call() throws NoSuchMethodException, SecurityException {
};
}
- private static Codec<Object, Object> getCodecForType(Class valueType, TypeDefinition subtype) {
+ private static Codec<Object, Object> getCodecForType(final Class<?> valueType, final TypeDefinition<?> subtype) {
if (subtype.getBaseType() instanceof UnionType) {
try {
return UnionTypeCodec.loader(valueType, (UnionType) subtype.getBaseType()).call();
@Override
public Object serialize(final Object input) {
- if(input != null) {
- for(UnionValueOptionContext valCtx : typeCodecs) {
+ if (input != null) {
+ for (UnionValueOptionContext valCtx : typeCodecs) {
Object domValue = valCtx.serialize(input);
- if(domValue != null) {
+ if (domValue != null) {
return domValue;
}
}