X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=code-generator%2Fbinding-generator-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fsal%2Fbinding%2Fgenerator%2Fimpl%2FCodecMapping.java;fp=code-generator%2Fbinding-generator-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fsal%2Fbinding%2Fgenerator%2Fimpl%2FCodecMapping.java;h=0000000000000000000000000000000000000000;hb=1dd5250b6e133fcdc0044608b9e01a7891977351;hp=4622ab737d6626d9dc9a6c0ba32779c7ef0f5d1d;hpb=7e94c3ee1a8b45978f9b9d7c3291d9f85008cca2;p=yangtools.git diff --git a/code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/CodecMapping.java b/code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/CodecMapping.java deleted file mode 100644 index 4622ab737d..0000000000 --- a/code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/CodecMapping.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.sal.binding.generator.impl; - -import java.lang.reflect.Field; -import java.util.Map; -import org.opendaylight.yangtools.yang.binding.BindingCodec; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.impl.codec.IdentityCodec; -import org.opendaylight.yangtools.yang.data.impl.codec.InstanceIdentifierCodec; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public final class CodecMapping { - - private static final Logger LOG = LoggerFactory.getLogger(CodecMapping.class); - - public static final String INSTANCE_IDENTIFIER_CODEC = "INSTANCE_IDENTIFIER_CODEC"; - public static final String IDENTITYREF_CODEC = "IDENTITYREF_CODEC"; - - public static final String CLASS_TO_CASE_MAP = "CLASS_TO_CASE"; - public static final String COMPOSITE_TO_CASE = "COMPOSITE_TO_CASE"; - public static final String AUGMENTATION_CODEC = "AUGMENTATION_CODEC"; - public static final String DISPATCH_CODEC = "DISPATCH_CODEC"; - - private CodecMapping() { - throw new UnsupportedOperationException("Utility class should not be instantiated"); - } - - public static void setIdentifierCodec(Class obj,InstanceIdentifierCodec codec) { - Field instanceIdField; - try { - instanceIdField = obj.getField(INSTANCE_IDENTIFIER_CODEC); - if (instanceIdField != null) { - instanceIdField.set(null, codec); - } - } catch (NoSuchFieldException e) { - LOG.trace("Instance identifier codec is not needed for {}",obj.getName(),e); - } catch (SecurityException | IllegalAccessException e) { - LOG.error("Instance identifier could not be set for {}",obj.getName(),e); - } - } - - public static void setIdentityRefCodec(Class obj,IdentityCodec codec) { - Field instanceIdField; - try { - instanceIdField = obj.getField(IDENTITYREF_CODEC); - if (instanceIdField != null) { - instanceIdField.set(null, codec); - } - } catch (NoSuchFieldException e) { - LOG.trace("Instance identifier codec is not needed for {}",obj.getName(),e); - } catch (SecurityException | IllegalAccessException e) { - LOG.error("Instance identifier could not be set for {}",obj.getName(),e); - } - } - - public static void setClassToCaseMap(Class> codec, - Map,BindingCodec> classToCaseRawCodec) { - Field instanceIdField; - try { - instanceIdField = codec.getField(CLASS_TO_CASE_MAP); - instanceIdField.set(null, classToCaseRawCodec); - } catch (NoSuchFieldException e) { - LOG.debug("BUG: Class to case mappping is not needed for {}",codec.getName(),e); - } catch (SecurityException | IllegalAccessException e) { - LOG.error("Class to case mappping could not be set for {}",codec.getName(),e); - } - } - - public static void setCompositeNodeToCaseMap(Class> codec, - Map> compositeToCase) { - Field instanceIdField; - try { - instanceIdField = codec.getField(COMPOSITE_TO_CASE); - instanceIdField.set(null, compositeToCase); - } catch (NoSuchFieldException e) { - LOG.debug("BUG: Class to case mappping is not needed for {}",codec.getName(),e); - } catch (SecurityException | IllegalAccessException e) { - LOG.error("Composite node to case mappping could not be set for {}",codec.getName(),e); - } - } - - public static void setDispatchCodec(Class> codec, - BindingCodec dispatchCodec) { - Field instanceIdField; - try { - instanceIdField = codec.getField(DISPATCH_CODEC); - instanceIdField.set(null, dispatchCodec); - } catch (NoSuchFieldException e) { - LOG.debug("BUG: dispatch codec is not needed for {}",codec.getName(),e); - } catch (SecurityException | IllegalAccessException e) { - LOG.error("Dispatch codec could not be set for {}",codec.getName(),e); - } - } - - public static void setAugmentationCodec(Class> dataCodec, - BindingCodec augmentableCodec) { - Field instanceIdField; - try { - instanceIdField = dataCodec.getField(AUGMENTATION_CODEC); - instanceIdField.set(null, augmentableCodec); - } catch (NoSuchFieldException e) { - LOG.debug("BUG: Augmentation codec is not needed for {}",dataCodec.getName(),e); - } catch (SecurityException | IllegalAccessException e) { - LOG.error("Augmentation codec could not be set for {}",dataCodec.getName(),e); - } - } - - - public static BindingCodec getAugmentationCodec(Class> dataCodec) { - Field instanceIdField; - try { - instanceIdField = dataCodec.getField(AUGMENTATION_CODEC); - return (BindingCodec) instanceIdField.get(null); - } catch (NoSuchFieldException e) { - LOG.debug("BUG: Augmentation codec is not needed for {}",dataCodec.getName(),e); - } catch (SecurityException | IllegalAccessException e) { - LOG.error("Augmentation codec could not be set for {}",dataCodec.getName(),e); - } - return null; - } -}