X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager-facade-xml%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Ffacade%2Fxml%2Fmapping%2Fattributes%2FAttributeIfcSwitchStatement.java;fp=opendaylight%2Fconfig%2Fconfig-manager-facade-xml%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Ffacade%2Fxml%2Fmapping%2Fattributes%2FAttributeIfcSwitchStatement.java;h=0000000000000000000000000000000000000000;hb=ac6f2699cd0c1e340cc32e8f0d0ca94c8e9c0cc0;hp=36a41d04419bb779c31f90cd14e800aace728525;hpb=f43b01b81319959b1907e3e04537f5169e7f33d8;p=controller.git diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/AttributeIfcSwitchStatement.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/AttributeIfcSwitchStatement.java deleted file mode 100644 index 36a41d0441..0000000000 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/AttributeIfcSwitchStatement.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2015, 2017 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.controller.config.facade.xml.mapping.attributes; - -import javax.management.openmbean.ArrayType; -import javax.management.openmbean.CompositeType; -import javax.management.openmbean.OpenType; -import javax.management.openmbean.SimpleType; -import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc; -import org.opendaylight.controller.config.yangjmxgenerator.attribute.DependencyAttribute; -import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute; -import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribute; -import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListDependenciesAttribute; -import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute; -import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition; - -public abstract class AttributeIfcSwitchStatement { - - private AttributeIfc lastAttribute; - - @SuppressWarnings("checkstyle:avoidHidingCauseException") - public T switchAttribute(final AttributeIfc attributeIfc) { - - this.lastAttribute = attributeIfc; - - OpenType openType = attributeIfc.getOpenType(); - - if (attributeIfc instanceof JavaAttribute) { - try { - if (((JavaAttribute) attributeIfc).getTypeDefinition() instanceof BinaryTypeDefinition) { - return caseJavaBinaryAttribute(openType); - } else if (((JavaAttribute) attributeIfc).isUnion()) { - return caseJavaUnionAttribute(openType); - } else if (((JavaAttribute) attributeIfc).isIdentityRef()) { - return caseJavaIdentityRefAttribute(openType); - } else if (((JavaAttribute) attributeIfc).isEnum()) { - return caseJavaEnumAttribute(openType); - } else { - return caseJavaAttribute(openType); - } - } catch (final UnknownOpenTypeException e) { - throw getIllegalArgumentException(attributeIfc); - } - - } else if (attributeIfc instanceof DependencyAttribute) { - return caseDependencyAttribute(((DependencyAttribute) attributeIfc).getOpenType()); - } else if (attributeIfc instanceof ListAttribute) { - return caseListAttribute((ArrayType) openType); - } else if (attributeIfc instanceof ListDependenciesAttribute) { - return caseListDependeciesAttribute((ArrayType) openType); - } else if (attributeIfc instanceof TOAttribute) { - return caseTOAttribute(((TOAttribute) attributeIfc).getOpenType()); - } - - throw getIllegalArgumentException(attributeIfc); - } - - public AttributeIfc getLastAttribute() { - return lastAttribute; - } - - protected T caseJavaIdentityRefAttribute(final OpenType openType) { - return caseJavaAttribute(openType); - } - - protected T caseJavaUnionAttribute(final OpenType openType) { - return caseJavaAttribute(openType); - } - - protected T caseJavaEnumAttribute(final OpenType openType) { - return caseJavaAttribute(openType); - } - - protected T caseJavaBinaryAttribute(final OpenType openType) { - return caseJavaAttribute(openType); - } - - private IllegalArgumentException getIllegalArgumentException(final AttributeIfc attributeIfc) { - return new IllegalArgumentException("Unknown attribute type " + attributeIfc.getClass() + ", " + attributeIfc - + " with open type:" + attributeIfc.getOpenType()); - } - - public final T caseJavaAttribute(final OpenType openType) { - if (openType instanceof SimpleType) { - return caseJavaSimpleAttribute((SimpleType) openType); - } else if (openType instanceof ArrayType) { - return caseJavaArrayAttribute((ArrayType) openType); - } else if (openType instanceof CompositeType) { - return caseJavaCompositeAttribute((CompositeType) openType); - } - - throw new UnknownOpenTypeException("Unknown attribute open type " + openType); - } - - protected abstract T caseJavaSimpleAttribute(SimpleType openType); - - protected abstract T caseJavaArrayAttribute(ArrayType openType); - - protected abstract T caseJavaCompositeAttribute(CompositeType openType); - - protected abstract T caseDependencyAttribute(SimpleType attributeIfc); - - protected abstract T caseTOAttribute(CompositeType openType); - - protected abstract T caseListAttribute(ArrayType openType); - - protected abstract T caseListDependeciesAttribute(ArrayType openType); - - private static class UnknownOpenTypeException extends RuntimeException { - private static final long serialVersionUID = 1L; - - UnknownOpenTypeException(final String message) { - super(message); - } - } -}