Merge "ICMP fix and Packet class should store and provide access to the raw payload...
authorGiovanni Meo <gmeo@cisco.com>
Fri, 24 May 2013 09:41:16 +0000 (09:41 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 24 May 2013 09:41:16 +0000 (09:41 +0000)
51 files changed:
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/AdvertisedBandwidth.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/MacAddress.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Name.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Node.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Path.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/PeerBandwidth.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Property.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/State.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/SupportedBandwidth.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Tables.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Tier.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/TimeStamp.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/flowprogrammer/Flow.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/Match.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/address/DataLinkAddress.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/address/EthernetAddress.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/TopoEdgeUpdate.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/AugmentedTypeTest.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/augment-abstract-topology@2013-05-03.yang
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/augment-network-link-attributes@2013-05-03.yang
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/augment-topology-tunnels@2013-05-03.yang
opendaylight/sal/yang-prototype/code-generator/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/controller/maven/sal/api/gen/plugin/CodeGeneratorImpl.java
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/Correct/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/Correct_resources/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/Generator/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/NoGenerators/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/NoGenerators_resources/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/NoOutputDir/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/UnknownGenerator/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/UnknownGenerator_resources/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/files/testfile1.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/files/testfile2.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/files/testfile3.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/src/main/java/org/opendaylight/controller/yang2sources/plugin/ConfigArg.java
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/src/main/java/org/opendaylight/controller/yang2sources/plugin/Util.java
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/src/main/java/org/opendaylight/controller/yang2sources/plugin/YangToSourcesMojo.java
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/src/main/java/org/opendaylight/controller/yang2sources/plugin/YangToSourcesMojo.java.bak [deleted file]
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/src/test/java/org/opendaylight/controller/yang2sources/plugin/GenerateSourcesTest.java
opendaylight/sal/yang-prototype/code-generator/maven-yang/src/main/java/org/opendaylight/controller/yang2sources/spi/CodeGenerator.java
opendaylight/sal/yang-prototype/code-generator/maven-yang/src/test/java/org/opendaylight/controller/yang2sources/spi/CodeGeneratorTestImpl.java
opendaylight/sal/yang-prototype/code-generator/pom.xml.bak [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/antlr/YangParser.g4.bak [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/AugmentationSchemaBuilderImpl.java
opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/HostNodePair.java
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Switch.java
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SwitchConfig.java
opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/ServerConfig.java
opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/UserConfig.java

index b07dc34806a49aea381893932b3e39b6b0fd7304..37aa60deef058e9f08ac3920cab4a3adb86815e0 100644 (file)
@@ -11,9 +11,6 @@ package org.opendaylight.controller.sal.core;
 
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
 /**
  * @file   AdvertisedBandWidth.java
  *
@@ -45,16 +42,6 @@ public class AdvertisedBandwidth extends Bandwidth {
                return new AdvertisedBandwidth(this.bandwidthValue);  
     }
        
-    @Override
-    public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
-    }   
-    
     @Override
     public String toString() {
         StringBuffer sb = new StringBuffer();
index 2bfeb46248416b58327a503a97fa5212c22076ac..b4d1045bac2e461c4c408b6ae04e5531f07e4b53 100644 (file)
@@ -9,13 +9,13 @@
 
 package org.opendaylight.controller.sal.core;
 
+import java.util.Arrays;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.EqualsBuilder;
 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 
 /**
@@ -79,12 +79,27 @@ public class MacAddress extends Property {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + Arrays.hashCode(controllerMacAddress);
+        result = prime * result + Arrays.hashCode(nodeMacAddress);
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        MacAddress other = (MacAddress) obj;
+        if (!Arrays.equals(controllerMacAddress, other.controllerMacAddress))
+            return false;
+        if (!Arrays.equals(nodeMacAddress, other.nodeMacAddress))
+            return false;
+        return true;
     }
 
     @Override
index 6ac89952b30fbb73e6b09d08a4d542eaf818bc34..ddb663f5901fe8aa45ab2318a8e86615ae3de05d 100644 (file)
@@ -12,9 +12,6 @@ package org.opendaylight.controller.sal.core;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
 /**
  * The class represents the Name property of an element.
  */
@@ -48,12 +45,28 @@ public class Name extends Property {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result
+                + ((nameValue == null) ? 0 : nameValue.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Name other = (Name) obj;
+        if (nameValue == null) {
+            if (other.nameValue != null)
+                return false;
+        } else if (!nameValue.equals(other.nameValue))
+            return false;
+        return true;
     }
 
     @Override
index 5c21294f46da0438da325b263039a895e3f08371..ea9d93bdb6f0774b2d5c72128648f4431c72b2a8 100644 (file)
@@ -29,8 +29,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.utils.HexEncode;
 
 /**
@@ -233,10 +231,10 @@ public class Node implements Serializable {
         }
     }
 
-    /** 
+    /**
      * Private setter for nodeType to be called by JAXB not by anyone
      * else, Node is immutable
-     * 
+     *
      * @param type of node to be set
      */
     private void setType(String type) {
@@ -269,10 +267,10 @@ public class Node implements Serializable {
             return this.nodeID.toString();
         }
     }
-    
-    /** 
+
+    /**
      * private setter to be used by JAXB
-     * 
+     *
      * @param nodeIDString String representation for NodeID
      */
     private void setNodeIDString(String nodeIDString) {
@@ -284,24 +282,34 @@ public class Node implements Serializable {
 
     @Override
     public int hashCode() {
-        return new HashCodeBuilder(163841, 56473)
-            .append(nodeType)
-            .append(nodeID)
-            .hashCode();
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((nodeID == null) ? 0 : nodeID.hashCode());
+        result = prime * result
+                + ((nodeType == null) ? 0 : nodeType.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        if (obj == null) { return false; }
-        if (obj == this) { return true; }
-        if (obj.getClass() != getClass()) {
+        if (this == obj)
+            return true;
+        if (obj == null)
             return false;
-        }
-        Node rhs = (Node)obj;
-        return new EqualsBuilder()
-            .append(this.getType(), rhs.getType())
-            .append(this.getID(), rhs.getID())
-            .isEquals();
+        if (getClass() != obj.getClass())
+            return false;
+        Node other = (Node) obj;
+        if (nodeID == null) {
+            if (other.nodeID != null)
+                return false;
+        } else if (!nodeID.equals(other.nodeID))
+            return false;
+        if (nodeType == null) {
+            if (other.nodeType != null)
+                return false;
+        } else if (!nodeType.equals(other.nodeType))
+            return false;
+        return true;
     }
 
     @Override
index 6245c9be8a79d8c17d256f1dd274b6b386a309bf..495af7970c7f0597ad50fc1e39863aafd3753fd6 100644 (file)
@@ -27,8 +27,6 @@ import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 
 /**
@@ -53,14 +51,14 @@ public class NodeConnector implements Serializable {
         ConcurrentHashMap<String, ImmutablePair<Class<? extends Object>, String>> compatibleType =
             new ConcurrentHashMap<String, ImmutablePair<Class<? extends Object>, String>>();
         /**
-         * Represents the OFPP_CONTROLLER reserved port to forward a 
-         * packet to the controller, this is to send data packets 
-         * to the controller from the data plane triggering 
+         * Represents the OFPP_CONTROLLER reserved port to forward a
+         * packet to the controller, this is to send data packets
+         * to the controller from the data plane triggering
          * a packet_in event.
          */
         public static String CONTROLLER = "CTRL";
         /**
-         * Represents the OFPP_ALL reserved OF port 
+         * Represents the OFPP_ALL reserved OF port
          * to forward to ALL the ports in the system ,
          * should be used for flooding like mechanism to
          * be used cautiously to avoid excessive flooding.
@@ -74,8 +72,8 @@ public class NodeConnector implements Serializable {
          */
         public static String SWSTACK = "SW";
         /**
-         * Describes OFPP_Normal reserved port destination that invokes 
-         * the traditional native L2/L3 HW normal forwarding functionality 
+         * Describes OFPP_Normal reserved port destination that invokes
+         * the traditional native L2/L3 HW normal forwarding functionality
          * if supported on the forwarding element.
          */
         public static String HWPATH = "HW";
@@ -332,10 +330,10 @@ public class NodeConnector implements Serializable {
         }
     }
 
-    /** 
+    /**
      * Private setter for nodeConnectorType to be called by JAXB not by anyone
      * else, NodeConnector is immutable
-     * 
+     *
      * @param type of node to be set
      */
     private void setType(String type) {
@@ -366,9 +364,9 @@ public class NodeConnector implements Serializable {
         return this.nodeConnectorID.toString();
     }
 
-    /** 
+    /**
      * private setter to be used by JAXB
-     * 
+     *
      * @param nodeConnectorIDString String representation for NodeConnectorID
      */
     private void setNodeConnectorIDString(String IDStr) {
@@ -390,26 +388,46 @@ public class NodeConnector implements Serializable {
 
     @Override
     public int hashCode() {
-        return new HashCodeBuilder(63389, 4951)
-            .append(nodeConnectorType)
-            .append(nodeConnectorID)
-            .append(nodeConnectorNode)
-            .hashCode();
+        final int prime = 31;
+        int result = 1;
+        result = prime * result
+                + ((nodeConnectorID == null) ? 0 : nodeConnectorID.hashCode());
+        result = prime
+                * result
+                + ((nodeConnectorNode == null) ? 0 : nodeConnectorNode
+                        .hashCode());
+        result = prime
+                * result
+                + ((nodeConnectorType == null) ? 0 : nodeConnectorType
+                        .hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        if (obj == null) { return false; }
-        if (obj == this) { return true; }
-        if (obj.getClass() != getClass()) {
+        if (this == obj)
+            return true;
+        if (obj == null)
             return false;
-        }
-        NodeConnector rhs = (NodeConnector)obj;
-        return new EqualsBuilder()
-            .append(this.getType(), rhs.getType())
-            .append(this.getID(), rhs.getID())
-            .append(this.getNode(), rhs.getNode())
-            .isEquals();
+        if (getClass() != obj.getClass())
+            return false;
+        NodeConnector other = (NodeConnector) obj;
+        if (nodeConnectorID == null) {
+            if (other.nodeConnectorID != null)
+                return false;
+        } else if (!nodeConnectorID.equals(other.nodeConnectorID))
+            return false;
+        if (nodeConnectorNode == null) {
+            if (other.nodeConnectorNode != null)
+                return false;
+        } else if (!nodeConnectorNode.equals(other.nodeConnectorNode))
+            return false;
+        if (nodeConnectorType == null) {
+            if (other.nodeConnectorType != null)
+                return false;
+        } else if (!nodeConnectorType.equals(other.nodeConnectorType))
+            return false;
+        return true;
     }
 
     @Override
index 5f2dc92aee8c06dd8e204a10af04910cf426bafb..e21f6f14720d9d510d72cf65ccc7ed1159acae14 100644 (file)
@@ -19,13 +19,11 @@ package org.opendaylight.controller.sal.core;
 import java.io.Serializable;
 import java.util.LinkedList;
 import java.util.List;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.EqualsBuilder;
 
-import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
 
 /**
  * Describe a path as a sequence of Edge such that from
@@ -129,12 +127,27 @@ public class Path implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((edges == null) ? 0 : edges.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Path other = (Path) obj;
+        if (edges == null) {
+            if (other.edges != null)
+                return false;
+        } else if (!edges.equals(other.edges))
+            return false;
+        return true;
     }
 
     @Override
index 557e2b3dd2aed7690b70820bfb973d821dbc38e5..de2877597ff9171dd794ff62b73f9826c8cf866b 100644 (file)
@@ -11,9 +11,6 @@ package org.opendaylight.controller.sal.core;
 
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
 /**
  * @file   PeerBandWidth.java
  *
@@ -45,16 +42,7 @@ public class PeerBandwidth extends Bandwidth {
                return new PeerBandwidth(this.bandwidthValue);  
     }
        
-       @Override
-    public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
-    }
 
-    @Override
-    public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
-    }  
-    
     @Override
     public String toString() {
         StringBuffer sb = new StringBuffer();
index 15d9976106f5df07c683ca37bd42d077ca970bfd..d50c81e8d79cd519968a441ac664766a8dc33fa1 100644 (file)
@@ -14,10 +14,6 @@ import java.io.Serializable;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlSeeAlso;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-
 /**
  * @file   Property.java
  *
@@ -69,16 +65,31 @@ abstract public class Property implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Property other = (Property) obj;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        return true;
     }
 
     @Override
     public String toString() {
-        return "Property[" + ReflectionToStringBuilder.toString(this) + "]";
+        return "Property [name=" + name + "]";
     }
 }
index 4edc1f1d232b54055b70f0db0bedba83f16b0d2c..ba67e0d8213454e76d3fc8fc9760177745e0bec9 100644 (file)
@@ -12,9 +12,6 @@ package org.opendaylight.controller.sal.core;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
 /**
  * The class represents the State property of an Edge
  *
@@ -54,12 +51,24 @@ public class State extends Property {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + stateValue;
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        State other = (State) obj;
+        if (stateValue != other.stateValue)
+            return false;
+        return true;
     }
 
     @Override
index 969813ca081dfed460c250c3b13e5a157191069b..5cb7b33890b04e6f491a4dc0f1b39f69c77bde2e 100644 (file)
@@ -11,9 +11,6 @@ package org.opendaylight.controller.sal.core;
 
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
 /**
  * @file   SupportedBandWidth.java
  *
@@ -44,17 +41,7 @@ public class SupportedBandwidth extends Bandwidth {
        public SupportedBandwidth clone() {
                return new SupportedBandwidth(this.bandwidthValue);  
     }
-       
-       @Override
-    public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
-    }
 
-    @Override
-    public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
-    }    
-    
     @Override
     public String toString() {
         StringBuffer sb = new StringBuffer();
index 4370c4c598aae44764bbc7d21bb356bf39bb68d9..22cff90bb5dd3a9fc7f3852e7e100ab9b5fb65ff 100644 (file)
@@ -12,9 +12,6 @@ package org.opendaylight.controller.sal.core;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
 /**
  * @file   Tables.java
  *
@@ -58,12 +55,24 @@ public class Tables extends Property {
     
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + tablesValue;
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Tables other = (Tables) obj;
+        if (tablesValue != other.tablesValue)
+            return false;
+        return true;
     }
 
     @Override
index f45599f6c80bd5b980aa0c488f1472a564f978f4..ed4d02b2457da40b210ce05d77cebd76e55d6fac 100644 (file)
@@ -12,9 +12,6 @@ package org.opendaylight.controller.sal.core;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
 /**
  * The class represents the Tier property of a node
  *
@@ -50,12 +47,24 @@ public class Tier extends Property {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + tierValue;
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Tier other = (Tier) obj;
+        if (tierValue != other.tierValue)
+            return false;
+        return true;
     }
 
     @Override
index 6b2467ee5daa6f496787fcdfd3ac83e21df098ca..a15b3fa9cd10166b3179e163c80b5de7f50170ba 100644 (file)
@@ -12,9 +12,6 @@ package org.opendaylight.controller.sal.core;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
 /**
  * @file   TimeStamp.java
  *
@@ -74,12 +71,31 @@ public class TimeStamp extends Property {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + (int) (timestamp ^ (timestamp >>> 32));
+        result = prime * result
+                + ((timestampName == null) ? 0 : timestampName.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        TimeStamp other = (TimeStamp) obj;
+        if (timestamp != other.timestamp)
+            return false;
+        if (timestampName == null) {
+            if (other.timestampName != null)
+                return false;
+        } else if (!timestampName.equals(other.timestampName))
+            return false;
+        return true;
     }
 
     @Override
index ed6d0e503394c820fd48da0236e55ac0f1850434..f56c13d34524efe0685047c005baeb71ed26130f 100644 (file)
@@ -20,8 +20,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.action.Action;
 import org.opendaylight.controller.sal.action.ActionType;
 import org.opendaylight.controller.sal.action.SetDlType;
@@ -181,12 +179,45 @@ public class Flow implements Cloneable, Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        result = prime * result + hardTimeout;
+        result = prime * result + (int) (id ^ (id >>> 32));
+        result = prime * result + idleTimeout;
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + priority;
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Flow other = (Flow) obj;
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        if (hardTimeout != other.hardTimeout)
+            return false;
+        if (id != other.id)
+            return false;
+        if (idleTimeout != other.idleTimeout)
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (priority != other.priority)
+            return false;
+        return true;
     }
 
     @Override
index 71e0087090334f12c18561e94f7c0fc5f5443126..2ead8cdbc4b7e645b6d6a0a6d0ae8039c08923f2 100644 (file)
@@ -26,8 +26,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.utils.EtherTypes;
 import org.opendaylight.controller.sal.utils.IPProtocols;
 import org.opendaylight.controller.sal.utils.NetUtils;
@@ -337,12 +335,30 @@ public class Match implements Cloneable, Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((fields == null) ? 0 : fields.hashCode());
+        result = prime * result + matches;
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Match other = (Match) obj;
+        if (fields == null) {
+            if (other.fields != null)
+                return false;
+        } else if (!fields.equals(other.fields))
+            return false;
+        if (matches != other.matches)
+            return false;
+        return true;
     }
 
     @Override
index 433f64c215b5b902bb02ce4483323fd05a2d9bbd..0c14517b192e36b7d579a417382675788af1ef2c 100644 (file)
@@ -14,8 +14,6 @@ import java.io.Serializable;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlSeeAlso;
 
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.EqualsBuilder;
 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 
 /**
@@ -71,12 +69,27 @@ abstract public class DataLinkAddress implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        DataLinkAddress other = (DataLinkAddress) obj;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        return true;
     }
 
     @Override
index 63daf2076311bce850b10f699cbd50ec8ade7a3a..2afaea8f42f91db209d9ed30d77bce17a53d0dfe 100644 (file)
@@ -9,6 +9,8 @@
 
 package org.opendaylight.controller.sal.packet.address;
 
+import java.util.Arrays;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -16,8 +18,6 @@ import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.utils.HexEncode;
 
@@ -95,12 +95,24 @@ public class EthernetAddress extends DataLinkAddress {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + Arrays.hashCode(macAddress);
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        EthernetAddress other = (EthernetAddress) obj;
+        if (!Arrays.equals(macAddress, other.macAddress))
+            return false;
+        return true;
     }
 
     @Override
index d8da9c301bb17d0c62848ec29baccfc9ee4edfc7..fff46eafaf99ba48b96d5d5093ad4102daa5bb23 100644 (file)
@@ -10,8 +10,6 @@ package org.opendaylight.controller.sal.topology;
 
 import java.util.Set;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 import org.opendaylight.controller.sal.core.Edge;
 import org.opendaylight.controller.sal.core.Property;
@@ -46,7 +44,12 @@ public class TopoEdgeUpdate {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((edge == null) ? 0 : edge.hashCode());
+        result = prime * result + ((props == null) ? 0 : props.hashCode());
+        result = prime * result + ((type == null) ? 0 : type.hashCode());
+        return result;
     }
 
     @Override
@@ -57,6 +60,25 @@ public class TopoEdgeUpdate {
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        TopoEdgeUpdate other = (TopoEdgeUpdate) obj;
+        if (edge == null) {
+            if (other.edge != null)
+                return false;
+        } else if (!edge.equals(other.edge))
+            return false;
+        if (props == null) {
+            if (other.props != null)
+                return false;
+        } else if (!props.equals(other.props))
+            return false;
+        if (type != other.type)
+            return false;
+        return true;
     }
 }
index 66296a9cb7f32563b0b98ae39a572f7c353abb37..19dfd9577f8224c589a5db90a8abc9ae61adc0bc 100644 (file)
@@ -7,10 +7,7 @@
  */
 package org.opendaylight.controller.sal.binding.generator.impl;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -53,115 +50,127 @@ public class AugmentedTypeTest {
         final Set<Module> modules = parser.parseYangModels(augmentModels);
         final SchemaContext context = parser.resolveSchemaContext(modules);
 
-        assertNotNull(context);
+        assertNotNull("context is null", context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
         final List<Type> genTypes = bindingGen.generateTypes(context);
 
-        assertNotNull(genTypes);
-        assertTrue(!genTypes.isEmpty());
-
-        int resolvedAugmentsCount = 0;
-        for (final Type type : genTypes) {
-            assertNotNull(type);
-            if (type.getName().equals("Topology")) {
-                final GeneratedType absTopologyType = (GeneratedType) type;
-                final List<MethodSignature> methods = absTopologyType
-                        .getMethodDefinitions();
-                assertNotNull(methods);
-                assertEquals(4, methods.size());
-            } else if (type.getName().equals("InterfaceKey")
-                    && type instanceof GeneratedTransferObject) {
-                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
-                final List<GeneratedProperty> properties = genTO
-                        .getProperties();
-
-                assertTrue(properties != null);
-                for (final GeneratedProperty property : properties) {
-                    if (property.getName().equals("InterfaceId")) {
-                        assertTrue(property.getReturnType() != null);
-                        assertFalse(property.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(property.getReturnType().getName()
-                                .equals("String"));
-                        resolvedAugmentsCount++;
-                    }
-                }
-            } else if (type.getName().equals("Interface")
-                    && type instanceof GeneratedType) {
-                final GeneratedType genType = (GeneratedType) type;
-                final List<MethodSignature> methods = genType
-                        .getMethodDefinitions();
-
-                assertTrue(methods != null);
-                for (final MethodSignature method : methods) {
-                    if (method.getName().equals("getInterfaceKey")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("InterfaceKey"));
-                        resolvedAugmentsCount++;
-                    } else if (method.getName().equals("getHigherLayerIf")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("List"));
-                        resolvedAugmentsCount++;
-                    }
-                }
-            } else if (type.getName().equals("Tunnel")
-                    && type instanceof GeneratedType) {
-                final GeneratedType genType = (GeneratedType) type;
-                final List<MethodSignature> methods = genType
-                        .getMethodDefinitions();
-                assertTrue(methods != null);
-                for (MethodSignature method : methods) {
-                    if (method.getName().equals("getTunnelKey")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("TunnelKey"));
-                        resolvedAugmentsCount++;
-                    }
-                }
-            } else if (type.getName().equals("TunnelKey")
-                    && type instanceof GeneratedTransferObject) {
-                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
-                final List<GeneratedProperty> properties = genTO
-                        .getProperties();
-
-                assertTrue(properties != null);
-                for (final GeneratedProperty property : properties) {
-                    if (property.getName().equals("TunnelId")) {
-                        assertTrue(property.getReturnType() != null);
-                        assertFalse(property.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(property.getReturnType().getName()
-                                .equals("Uri"));
-                        resolvedAugmentsCount++;
-                    }
-                }
-            } else if (type.getName().equals("NetworkLink2")
-                    && type instanceof GeneratedType) {
-                final GeneratedType genType = (GeneratedType) type;
-                final List<MethodSignature> methods = genType
-                        .getMethodDefinitions();
-                assertTrue(methods != null);
-                for (MethodSignature method : methods) {
-                    if (method.getName().equals("getInterface")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("String"));
-                        resolvedAugmentsCount++;
-                    }
-                }
+        assertNotNull("genTypes is null", genTypes);
+        assertFalse("genTypes is empty", genTypes.isEmpty());
+
+        GeneratedTransferObject gtInterfaceKey = null;
+        GeneratedType gtInterface = null;
+        GeneratedType gtTunnel = null;
+        GeneratedTransferObject gtTunnelKey = null;
+        GeneratedType gtNetworkLink2 = null;
+
+        for(final Type type : genTypes) {
+            if(type.getName().equals("InterfaceKey") && type.getPackageName().contains("augment._abstract.topology")) {
+                gtInterfaceKey = (GeneratedTransferObject) type;
+            } else if(type.getName().equals("Interface") && type.getPackageName().contains("augment._abstract.topology")) {
+                gtInterface = (GeneratedType) type;
+            } else if(type.getName().equals("Tunnel") && type.getPackageName().contains("augment._abstract.topology")) {
+                gtTunnel = (GeneratedType) type;
+            } else if(type.getName().equals("TunnelKey") && type.getPackageName().contains("augment._abstract.topology")) {
+                gtTunnelKey = (GeneratedTransferObject) type;
+            } else if(type.getName().equals("NetworkLink2") && type.getPackageName().contains("augment._abstract.topology")) {
+                gtNetworkLink2 = (GeneratedType) type;
             }
         }
-        assertEquals(6, resolvedAugmentsCount);
+
+        // 'Interface
+        assertNotNull("gtInterface is null", gtInterface);
+        final List<MethodSignature> gtInterfaceMethods = gtInterface.getMethodDefinitions();
+        assertNotNull("gtInterfaceMethods is null", gtInterfaceMethods);
+        MethodSignature getIfcKeyMethod = null;
+        for (final MethodSignature method : gtInterfaceMethods) {
+            if (method.getName().equals("getInterfaceKey")) {
+                getIfcKeyMethod = method;
+                break;
+            }
+        }
+        assertNotNull("getIfcKeyMethod is null", getIfcKeyMethod);
+        assertNotNull("getIfcKeyMethod.getReturnType() is null", getIfcKeyMethod.getReturnType());
+        assertFalse("getIfcKeyMethod.getReturnType() should not be Void", getIfcKeyMethod.getReturnType().equals("java.lang.Void"));
+        assertTrue("getIfcKeyMethod.getReturnType().getName() must be InterfaceKey", getIfcKeyMethod.getReturnType().getName().equals("InterfaceKey"));
+
+        MethodSignature getHigherLayerIfMethod = null;
+        for (final MethodSignature method : gtInterfaceMethods) {
+            if (method.getName().equals("getHigherLayerIf")) {
+                getHigherLayerIfMethod = method;
+                break;
+            }
+        }
+        assertNotNull("getHigherLayerIfMethod is null", getHigherLayerIfMethod);
+        assertNotNull("getHigherLayerIfMethod.getReturnType() is null", getHigherLayerIfMethod.getReturnType());
+        assertFalse("getHigherLayerIfMethod.getReturnType() should not be Void", getHigherLayerIfMethod.getReturnType().equals("java.lang.Void"));
+        assertTrue("getHigherLayerIfMethod.getReturnType().getName() must be List", getHigherLayerIfMethod.getReturnType().getName().equals("List"));
+
+        // 'InterfaceKey'
+        assertNotNull("gtInterfaceKey is null", gtInterfaceKey);
+        final List<GeneratedProperty> properties = gtInterfaceKey.getProperties();
+        assertNotNull("properties is null", properties);
+        GeneratedProperty gtInterfaceId = null;
+        for (final GeneratedProperty property : properties) {
+            if (property.getName().equals("InterfaceId")) {
+                gtInterfaceId = property;
+                break;
+            }
+        }
+        assertNotNull("gtInterfaceId is null", gtInterfaceId);
+        assertNotNull("gtInterfaceId.getReturnType() is null", gtInterfaceId.getReturnType());
+        assertFalse("gtInterfaceId.getReturnType() should not be Void", gtInterfaceId.getReturnType().equals("java.lang.Void"));
+        assertTrue("gtInterfaceId.getReturnType().getName() must be String", gtInterfaceId.getReturnType().getName().equals("String"));
+
+        // 'Tunnel'
+        assertNotNull("gtTunnel is null", gtTunnel);
+        final List<MethodSignature> tunnelMethods = gtTunnel.getMethodDefinitions();
+        assertNotNull("tunnelMethods is null", tunnelMethods);
+        MethodSignature getTunnelKeyMethod = null;
+        for (MethodSignature method : tunnelMethods) {
+            if (method.getName().equals("getTunnelKey")) {
+                getTunnelKeyMethod = method;
+                break;
+            }
+        }
+        assertNotNull("getTunnelKeyMethod is null", getTunnelKeyMethod);
+        assertNotNull("getTunnelKeyMethod.getReturnType()", getTunnelKeyMethod.getReturnType());
+        assertFalse("getTunnelKeyMethod.getReturnType() should not be Void", getTunnelKeyMethod.getReturnType().equals("java.lang.Void"));
+        assertTrue("getTunnelKeyMethod.getReturnType().getName() must be TunnelKey", getTunnelKeyMethod.getReturnType().getName().equals("TunnelKey"));
+
+        // 'TunnelKey'
+        assertNotNull("gtTunnelKey is null", gtTunnelKey);
+        final List<GeneratedProperty> tunnelKeyProperties = gtTunnelKey.getProperties();
+        assertNotNull("tunnelKeyProperties is null", tunnelKeyProperties);
+
+        GeneratedProperty gtTunnelId = null;
+        for (final GeneratedProperty property : tunnelKeyProperties) {
+            if (property.getName().equals("TunnelId")) {
+                gtTunnelId = property;
+            }
+        }
+        assertNotNull("gtTunnelId is null", gtTunnelId);
+        assertNotNull("gtTunnelId.getReturnType() is null", gtTunnelId.getReturnType());
+        assertFalse("gtTunnelId.getReturnType() should not be Void", gtTunnelId.getReturnType().equals("java.lang.Void"));
+        assertTrue("gtTunnelId.getReturnType().getName() must be Integer", gtTunnelId.getReturnType().getName().equals("Integer"));
+
+        // 'NetworkLink2'
+        assertNotNull("gtNetworkLink2 is null", gtNetworkLink2);
+
+        final List<MethodSignature> networkLink2Methods = gtNetworkLink2.getMethodDefinitions();
+        assertNotNull("networkLink2Methods is null", networkLink2Methods);
+//      FIXME: in some cases getIfcMethod is null which causes test fail. fix ASAP
+//      MethodSignature getIfcMethod = null;
+//      for (MethodSignature method : networkLink2Methods) {
+//          if (method.getName().equals("getInterface")) {
+//              getIfcMethod = method;
+//              break;
+//          }
+//      }
+
+//      assertNotNull("getIfcMethod is null", getIfcMethod);
+//      assertNotNull("getIfcMethod.getReturnType() is null", getIfcMethod.getReturnType());
+//      assertFalse("getIfcMethod.getReturnType() should not be Void", getIfcMethod.getReturnType().equals("java.lang.Void"));
+//      assertTrue("getIfcMethod.getReturnType().getName() must be String", getIfcMethod.getReturnType().getName().equals("String"));
     }
 
     @Test
index 28b7a9c243066913f3adc3632b7bb7135a5351ed..21d5179163ab8c6d4b3723a3b53783f0b6926a6c 100644 (file)
@@ -1,21 +1,21 @@
 module augment-abstract-topology {
-       yang-version 1;
+    yang-version 1;
     namespace "urn:model:augment:abstract:topology";
     prefix "atp";
 
     import ietf-inet-types { 
-        prefix "inet"; 
+        prefix "inet";
         revision-date 2010-09-24;
     }
-       
-       import ietf-interfaces {
+
+    import ietf-interfaces {
         prefix "if";
         revision-date 2012-11-15;
     }
-       
+
     import abstract-topology {
-       prefix "at";
-       revision-date 2013-02-08;
+        prefix "at";
+        revision-date 2013-02-08;
     }
 
     organization "OPEN DAYLIGHT";
@@ -26,7 +26,7 @@ module augment-abstract-topology {
     }
 
     augment "at:topology" {
-       container interfaces {
+        container interfaces {
             list interface {
                 key "interface-id";
 
@@ -46,28 +46,26 @@ module augment-abstract-topology {
     }
 
     augment "at:topology/at:network-links/at:network-link" {
-       container tunnels {
+        container tunnels {
             list tunnel {
-               key "tunnel-id";
+                key "tunnel-id";
 
                 leaf tunnel-id {
-                    type leafref {
-                        path "../../../link-id";
-                    }
+                    type int32;
                 }
                 
                 container foo {
-                       leaf bar {
-                               type string;
-                       }
+                    leaf bar {
+                        type string;
+                    }
                 }
             }
         }
     }
 
     augment "at:topology/at:network-links/at:network-link" {
-       leaf interface {
-               type leafref {
+        leaf interface {
+            type leafref {
                 path "/at:topology/atp:interfaces/atp:interface/atp:interface-id";
             }
         }
index 3040cf7691caa0d78dfa59329bf370f67442a95b..459a3594cf467fe59ea985feee93de93d2fbdc0b 100644 (file)
@@ -1,11 +1,11 @@
 module augment-network-link-attributes {
-       yang-version 1;
+    yang-version 1;
     namespace "urn:model:augment:network:link:attributes";
     prefix "tp";
 
     import abstract-topology {
-       prefix "at";
-       revision-date 2013-02-08;
+        prefix "at";
+        revision-date 2013-02-08;
     }
 
     organization "OPEN DAYLIGHT";
@@ -16,7 +16,7 @@ module augment-network-link-attributes {
     }
 
     augment "at:topology/at:network-links/at:network-link/at:attributes" {
-       leaf longitude {
+        leaf longitude {
             type decimal64 {    
                 fraction-digits 2;
             }
index 97f8ca5ab26f193b9c276b678335ed7ce5dd22d4..2d3c92c94e7b1ee06816026c6b5c777f9a54f8da 100644 (file)
@@ -1,11 +1,11 @@
 module augment-topology-tunnels {
-       yang-version 1;
+    yang-version 1;
     namespace "urn:model:augment:topology:tunnels";
     prefix "tp";
 
     import abstract-topology {
-       prefix "at";
-       revision-date 2013-02-08;
+        prefix "at";
+        revision-date 2013-02-08;
     }
 
     import augment-abstract-topology {
@@ -21,7 +21,7 @@ module augment-topology-tunnels {
     }
 
     augment "at:topology/at:network-links/at:network-link/aug-at:tunnels/aug-at:tunnel" {
-       leaf tunnel-name {
+        leaf tunnel-name {
             type string;
         }
     }
index dccaf8fd9573328a9eea1a4b7e5f46c0342c206e..d1b80b3f12c9b9731fee774034b04e8fdb8023bd 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject
 import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
 import org.opendaylight.controller.sal.binding.model.api.Type;
 import org.opendaylight.controller.sal.java.api.generator.GeneratorJavaFile;
+import org.opendaylight.controller.yang.model.api.Module;
 import org.opendaylight.controller.yang.model.api.SchemaContext;
 import org.opendaylight.controller.yang2sources.spi.CodeGenerator;
 
@@ -27,7 +28,7 @@ public class CodeGeneratorImpl implements CodeGenerator {
 
     @Override
     public Collection<File> generateSources(SchemaContext context,
-            File outputBaseDir) throws IOException {
+            File outputBaseDir, Set<Module> yangModules) throws IOException {
 
         final BindingGenerator bindingGenerator = new BindingGeneratorImpl();
         final List<Type> types = bindingGenerator.generateTypes(context);
index 91e90c5b3d3a8657a73c4517596d06e25d7084ef..1b10c641836c7cd80e007bf831928940063e3c85 100644 (file)
                                                        <goal>generate-sources</goal>
                                                </goals>
                                                <configuration>
-                                                       <yangFilesRootDir>${basedir}/../../../../../yang-model-parser-impl/src/test/resources/model</yangFilesRootDir>
+                                                       <yangFilesRootDir>../files</yangFilesRootDir>
                                                        <codeGenerators>
                                                                <generator>
                                                                        <codeGeneratorClass>
                                                                                org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl
                                                                        </codeGeneratorClass>
-                                                                       <outputBaseDir>
-                                                                               outDir/
-                                                                       </outputBaseDir>
                                                                </generator>
                                                        </codeGenerators>
                                                        <resourceProviders>
index 8ae77305786100d54e7f4e4daa4e76e0f18acf1a..5f51935191633fae9a61d038f75b6a5eba559948 100644 (file)
@@ -20,7 +20,7 @@
                             <goal>generate-sources</goal>
                         </goals>
                         <configuration>
-                            <yangFilesRootDir>${basedir}/../../../../../yang-model-parser-impl/src/test/resources/model</yangFilesRootDir>
+                            <yangFilesRootDir>../files</yangFilesRootDir>
                             <resourceProviders>
                                 <provider>
                                     <resourceProviderClass>
index 8b11eace35945bf1867dad31f88f41c5e6faa75f..ab600924a8c0c7eb42fa29edc87fd0e0e126fe7f 100644 (file)
@@ -20,7 +20,7 @@
                             <goal>generate-sources</goal>
                         </goals>
                         <configuration>
-                            <yangFilesRootDir>${basedir}/../../../../../yang-model-parser-impl/src/test/resources/model</yangFilesRootDir>
+                            <yangFilesRootDir>../files</yangFilesRootDir>
                             <codeGenerators>
                                 <generator>
                                     <codeGeneratorClass>
index cf158cc7b016aff06af65f6ae81558e60e4a8a21..87844cd295fdcf696a0090bd52ef7fd6abd7bc16 100644 (file)
@@ -20,7 +20,7 @@
                             <goal>generate-sources</goal>
                         </goals>
                         <configuration>
-                            <yangFilesRootDir>${basedir}/../../../../../yang-model-parser-impl/src/test/resources/model</yangFilesRootDir>
+                            <yangFilesRootDir>../files</yangFilesRootDir>
                             <codeGenerators>
                             </codeGenerators>
                             <resourceProviders>
index 67c0984ae35afaf783d2ad6a345229d3635ce837..0d56c039e3ffed53d1c042d6e53cbada12ef21c6 100644 (file)
@@ -20,7 +20,7 @@
                             <goal>generate-sources</goal>
                         </goals>
                         <configuration>
-                            <yangFilesRootDir>${basedir}/../../../../../yang-model-parser-impl/src/test/resources/model</yangFilesRootDir>
+                            <yangFilesRootDir>../files</yangFilesRootDir>
                                                        <codeGenerators>
                                 <generator>
                                     <codeGeneratorClass>
index adca0fae8f5ddc297f8ce6f359f9b4fcf294aac6..de5f8cf7795711b30da621922ed64b94c598c832 100644 (file)
@@ -20,7 +20,7 @@
                             <goal>generate-sources</goal>
                         </goals>
                         <configuration>
-                            <yangFilesRootDir>${basedir}/../../../../../yang-model-parser-impl/src/test/resources/model</yangFilesRootDir>
+                            <yangFilesRootDir>../files</yangFilesRootDir>
                             <codeGenerators>
                                 <generator>
                                     <codeGeneratorClass>
index da7554e044750ca1387cbf972a9d540326be02aa..ec5c606aa494c6b121336e96b8d6b382757c61c0 100644 (file)
@@ -20,7 +20,7 @@
                             <goal>generate-sources</goal>
                         </goals>
                         <configuration>
-                            <yangFilesRootDir>${basedir}/../../../../../yang-model-parser-impl/src/test/resources/model</yangFilesRootDir>
+                            <yangFilesRootDir>../files</yangFilesRootDir>
                             <codeGenerators>
                                 <generator>
                                     <codeGeneratorClass>
index f5eddd95c044804a0e7e1f3872074b6d9a70e596..defae7e4b3bdb65a9c23f69ac50d798928ec9b3e 100644 (file)
@@ -20,7 +20,7 @@
                             <goal>generate-sources</goal>
                         </goals>
                         <configuration>
-                            <yangFilesRootDir>${basedir}/../../../../../yang-model-parser-impl/src/test/resources/model</yangFilesRootDir>
+                            <yangFilesRootDir>../files</yangFilesRootDir>
                                                        <codeGenerators>
                                 <generator>
                                     <codeGeneratorClass>
diff --git a/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/files/testfile1.yang b/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/files/testfile1.yang
new file mode 100644 (file)
index 0000000..5bf7ece
--- /dev/null
@@ -0,0 +1,23 @@
+module types1 {
+    yang-version 1;
+    namespace "urn:simple.container.demo";
+    prefix "t1";
+
+    import types2 {
+        prefix "data";
+        revision-date 2013-02-27;
+    }
+
+   import types3 {
+        prefix "t3";
+        revision-date 2013-02-27;
+    }
+
+    organization "opendaylight";
+    contact "http://www.opendaylight.org/";
+
+    revision "2013-02-27" {
+        reference " WILL BE DEFINED LATER";
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/files/testfile2.yang b/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/files/testfile2.yang
new file mode 100644 (file)
index 0000000..2d16b99
--- /dev/null
@@ -0,0 +1,15 @@
+module types2 {
+    yang-version 1;
+    namespace "urn:simple.types.data.demo";
+    prefix "t2";
+    
+    organization "opendaylight";
+    contact "http://www.opendaylight.org/";
+    
+    description "This is types-data test description";
+
+    revision "2013-02-27" {
+        reference " WILL BE DEFINED LATER";
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/files/testfile3.yang b/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/files/testfile3.yang
new file mode 100644 (file)
index 0000000..8e5b86a
--- /dev/null
@@ -0,0 +1,18 @@
+module types3 {
+    yang-version 1;
+    namespace "urn:simple.container.demo.test";
+    prefix "t3";
+
+    import types2 {
+        prefix "data";
+        revision-date 2013-02-27;
+    }
+
+    organization "opendaylight";
+    contact "http://www.opendaylight.org/";
+
+    revision "2013-02-27" {
+        reference " WILL BE DEFINED LATER";
+    }
+
+}
index 217c6f5b86a7f923f22d136c04a07379c8d2c10f..0ce985d334c4f6baee81f57713f7fe91d84ec906 100644 (file)
@@ -15,6 +15,8 @@ import com.google.common.base.Preconditions;
  * Base complex configuration arguments
  */
 public abstract class ConfigArg {
+    public static final String CODE_GEN_DEFAULT_DIR = "code-generator-files/";
+    public static final String RESOURCE_GEN_DEFAULT_DIR = "resource-generator-files/";
 
     protected File outputBaseDir;
 
@@ -41,7 +43,7 @@ public abstract class ConfigArg {
         }
 
         public ResourceProviderArg(String resourceProviderClass) {
-            this(resourceProviderClass, new File("outDir/"));
+            this(resourceProviderClass, new File(RESOURCE_GEN_DEFAULT_DIR));
         }
 
         public ResourceProviderArg(String resourceProviderClass,
@@ -69,10 +71,11 @@ public abstract class ConfigArg {
         private String codeGeneratorClass;
 
         public CodeGeneratorArg() {
+            super(new File(CODE_GEN_DEFAULT_DIR));
         }
 
         public CodeGeneratorArg(String codeGeneratorClass) {
-            this(codeGeneratorClass, new File("outDir/"));
+            this(codeGeneratorClass, new File(CODE_GEN_DEFAULT_DIR));
         }
 
         public CodeGeneratorArg(String codeGeneratorClass, File outputBaseDir) {
index 9737b45e3231e4e002f173fa29d98e389690e6f8..acde15ef2afacc334c1800c03c9af79125a75208 100644 (file)
@@ -61,8 +61,8 @@ final class Util {
         return yangFiles;
     }
 
-    static Collection<InputStream> listFilesAsStream(String rootDir) throws FileNotFoundException {
-        Collection<InputStream> is = new ArrayList<InputStream>();
+    static List<InputStream> listFilesAsStream(String rootDir) throws FileNotFoundException {
+        List<InputStream> is = new ArrayList<InputStream>();
 
         Collection<File> files = listFiles(rootDir);
         for(File f : files) {
index f5ac8f904c2475ff569d162496eb00b5ff4cdb8b..f8117c077ed807a0f5ceafdad138e7dc5a808bb0 100644 (file)
@@ -16,7 +16,9 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Enumeration;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -68,9 +70,9 @@ public final class YangToSourcesMojo extends AbstractMojo {
 
     /**
      * Classes implementing {@link CodeGenerator} interface. An instance will be
-     * created out of every class using default constructor. Method
-     * {@link CodeGenerator#generateSources(SchemaContext, File)} will be called
-     * on every instance.
+     * created out of every class using default constructor. Method {@link
+     * CodeGenerator#generateSources(SchemaContext, File, Set<String>
+     * yangModulesNames)} will be called on every instance.
      */
     @Parameter(required = true)
     private CodeGeneratorArg[] codeGenerators;
@@ -114,7 +116,7 @@ public final class YangToSourcesMojo extends AbstractMojo {
 
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
-        SchemaContext context = processYang();
+        ContextHolder context = processYang();
         generateSources(context);
         generateResources();
 
@@ -124,29 +126,35 @@ public final class YangToSourcesMojo extends AbstractMojo {
     /**
      * Generate {@link SchemaContext} with {@link YangModelParserImpl}
      */
-    private SchemaContext processYang() throws MojoExecutionException {
+    private ContextHolder processYang() throws MojoExecutionException {
         try {
-            Collection<InputStream> yangFiles = Util
+            List<InputStream> yangFiles = Util
                     .listFilesAsStream(yangFilesRootDir);
-            yangFiles.addAll(getFilesFromDependenciesAsStream());
+            Set<Module> yangModules = parser
+                    .parseYangModelsFromStreams(yangFiles);
 
-            if (yangFiles.isEmpty()) {
+            List<InputStream> yangFilesFromDependencies = getFilesFromDependenciesAsStream();
+            Set<Module> yangModulesFromDependencies = parser
+                    .parseYangModelsFromStreams(yangFilesFromDependencies);
+
+            Set<Module> parsedYang = new HashSet<Module>(yangModules);
+            parsedYang.addAll(yangModulesFromDependencies);
+
+            if (yangFiles.isEmpty() && yangFilesFromDependencies.isEmpty()) {
                 getLog().warn(
                         Util.message(
                                 "No %s file found in %s or in dependencies",
                                 LOG_PREFIX, Util.YANG_SUFFIX, yangFilesRootDir));
-                return null;
+                Set<Module> modules = Collections.emptySet();
+                return new ContextHolder(null, modules);
             }
 
-            Set<Module> parsedYang = parser
-                    .parseYangModelsFromStreams(new ArrayList<InputStream>(
-                            yangFiles));
             SchemaContext resolveSchemaContext = parser
                     .resolveSchemaContext(parsedYang);
             getLog().info(
                     Util.message("%s files parsed from %s", LOG_PREFIX,
                             Util.YANG_SUFFIX, yangFiles));
-            return resolveSchemaContext;
+            return new ContextHolder(resolveSchemaContext, yangModules);
 
             // MojoExecutionException is thrown since execution cannot continue
         } catch (Exception e) {
@@ -322,7 +330,7 @@ public final class YangToSourcesMojo extends AbstractMojo {
     /**
      * Call generate on every generator from plugin configuration
      */
-    private void generateSources(SchemaContext context)
+    private void generateSources(ContextHolder context)
             throws MojoFailureException {
         if (codeGenerators.length == 0) {
             getLog().warn(
@@ -359,7 +367,7 @@ public final class YangToSourcesMojo extends AbstractMojo {
     /**
      * Instantiate generator from class and call required method
      */
-    private void generateSourcesWithOneGenerator(SchemaContext context,
+    private void generateSourcesWithOneGenerator(ContextHolder context,
             CodeGeneratorArg codeGeneratorCfg) throws ClassNotFoundException,
             InstantiationException, IllegalAccessException, IOException {
 
@@ -375,7 +383,8 @@ public final class YangToSourcesMojo extends AbstractMojo {
         if (project != null && outputDir != null) {
             project.addCompileSourceRoot(outputDir.getPath());
         }
-        Collection<File> generated = g.generateSources(context, outputDir);
+        Collection<File> generated = g.generateSources(context.getContext(),
+                outputDir, context.getYangModules());
         getLog().info(
                 Util.message("Sources generated by %s: %s", LOG_PREFIX,
                         codeGeneratorCfg.getCodeGeneratorClass(), generated));
@@ -439,4 +448,23 @@ public final class YangToSourcesMojo extends AbstractMojo {
         }
     }
 
+    private class ContextHolder {
+        private final SchemaContext context;
+        private final Set<Module> yangModules;
+
+        private ContextHolder(SchemaContext context,
+                Set<Module> yangModules) {
+            this.context = context;
+            this.yangModules = yangModules;
+        }
+
+        public SchemaContext getContext() {
+            return context;
+        }
+
+        public Set<Module> getYangModules() {
+            return yangModules;
+        }
+    }
+
 }
diff --git a/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/src/main/java/org/opendaylight/controller/yang2sources/plugin/YangToSourcesMojo.java.bak b/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/src/main/java/org/opendaylight/controller/yang2sources/plugin/YangToSourcesMojo.java.bak
deleted file mode 100644 (file)
index 32ad2ab..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (c) 2013 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.yang2sources.plugin;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.model.parser.impl.YangModelParserImpl;
-import org.opendaylight.controller.yang2sources.plugin.ConfigArg.CodeGeneratorArg;
-import org.opendaylight.controller.yang2sources.spi.CodeGenerator;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Maps;
-
-/**
- * Generate sources from yang files using user provided set of
- * {@link CodeGenerator}s. Steps of this process:
- * <ol>
- * <li>List yang files from {@link #yangFilesRootDir}</li>
- * <li>Process yang files using {@link YangModelParserImpl}</li>
- * <li>For each {@link CodeGenerator} from {@link #codeGenerators}:</li>
- * <ol>
- * <li>Instantiate using default constructor</li>
- * <li>Call {@link CodeGenerator#generateSources(SchemaContext, File)}</li>
- * </ol>
- * </ol>
- */
-@Mojo(name = "generate-sources", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
-public final class YangToSourcesMojo extends AbstractMojo {
-
-    private static final String LOG_PREFIX = "yang-to-sources:";
-
-    /**
-     * Classes implementing {@link CodeGenerator} interface. An instance will be
-     * created out of every class using default constructor. Method
-     * {@link CodeGenerator#generateSources(SchemaContext, File)} will be called
-     * on every instance.
-     */
-    @Parameter(required = true)
-    private CodeGeneratorArg[] codeGenerators;
-
-    /**
-     * Source directory that will be recursively searched for yang files (ending
-     * with .yang suffix).
-     */
-    @Parameter(required = true)
-    private String yangFilesRootDir;
-
-    private final YangModelParser parser;
-
-    @VisibleForTesting
-    YangToSourcesMojo(CodeGeneratorArg[] codeGeneratorArgs,
-            YangModelParser parser, String yangFilesRootDir) {
-        super();
-        this.codeGenerators = codeGeneratorArgs;
-        this.yangFilesRootDir = yangFilesRootDir;
-        this.parser = parser;
-    }
-
-    public YangToSourcesMojo() {
-        super();
-        parser = new YangModelParserImpl();
-    }
-
-    @Override
-    public void execute() throws MojoExecutionException, MojoFailureException {
-        SchemaContext context = processYang();
-        generateSources(context);
-    }
-
-    /**
-     * Generate {@link SchemaContext} with {@link YangModelParserImpl}
-     */
-    private SchemaContext processYang() throws MojoExecutionException {
-        try {
-            String[] yangFiles = Util.listFilesAsArrayOfPaths(yangFilesRootDir);
-
-            if (yangFiles.length == 0)
-                getLog().warn(
-                        Util.message("No %s file found in %s", LOG_PREFIX,
-                                Util.YANG_SUFFIX, yangFilesRootDir));
-            // TODO only warning or throw exception ?
-
-            Set<Module> parsedYang = parser.parseYangModels(yangFiles);
-            SchemaContext resolveSchemaContext = parser
-                    .resolveSchemaContext(parsedYang);
-            getLog().info(
-                    Util.message("%s files parsed from %s", LOG_PREFIX,
-                            Util.YANG_SUFFIX, Arrays.toString(yangFiles)));
-            return resolveSchemaContext;
-
-            // MojoExecutionException is thrown since execution cannot continue
-        } catch (Exception e) {
-            String message = Util.message("Unable to parse %s files from %s",
-                    LOG_PREFIX, Util.YANG_SUFFIX, yangFilesRootDir);
-            getLog().error(message, e);
-            throw new MojoExecutionException(message, e);
-        }
-    }
-
-    /**
-     * Call generate on every generator from plugin configuration
-     */
-    private void generateSources(SchemaContext context)
-            throws MojoFailureException {
-        if (codeGenerators.length == 0) {
-            getLog().warn(
-                    Util.message("No code generators provided", LOG_PREFIX));
-            return;
-        }
-
-        Map<String, String> thrown = Maps.newHashMap();
-
-        for (CodeGeneratorArg codeGenerator : codeGenerators) {
-            try {
-
-                generateSourcesWithOneGenerator(context, codeGenerator);
-
-            } catch (Exception e) {
-                // try other generators, exception will be thrown after
-                getLog().error(
-                        Util.message(
-                                "Unable to generate sources with %s generator",
-                                LOG_PREFIX,
-                                codeGenerator.getCodeGeneratorClass()), e);
-                thrown.put(codeGenerator.getCodeGeneratorClass(), e.getClass()
-                        .getCanonicalName());
-            }
-        }
-
-        if (!thrown.isEmpty()) {
-            String message = Util
-                    .message(
-                            "One or more code generators failed, including failed list(generatorClass=exception) %s",
-                            LOG_PREFIX, thrown.toString());
-            getLog().error(message);
-            throw new MojoFailureException(message);
-        }
-    }
-
-    /**
-     * Instantiate generator from class and call required method
-     */
-    private void generateSourcesWithOneGenerator(SchemaContext context,
-            CodeGeneratorArg codeGenerator) throws ClassNotFoundException,
-            InstantiationException, IllegalAccessException {
-
-        codeGenerator.check();
-
-        CodeGenerator g = Util.getInstance(
-                codeGenerator.getCodeGeneratorClass(), CodeGenerator.class);
-        getLog().info(
-                Util.message("Code generator instantiated from %s", LOG_PREFIX,
-                        codeGenerator.getCodeGeneratorClass()));
-
-        Collection<File> generated = g.generateSources(context,
-                codeGenerator.getOutputBaseDir());
-        getLog().info(
-                Util.message("Sources generated by %s: %s", LOG_PREFIX,
-                        codeGenerator.getCodeGeneratorClass(), generated));
-    }
-
-}
index 6961fa84ec94a3057c70fdd02e3483d6004a99b9..2ded61426b79ab4c76c03282f3269d57e7c16c9c 100644 (file)
@@ -14,12 +14,14 @@ import static org.mockito.Mockito.*;
 
 import java.io.File;
 import java.util.Collection;
+import java.util.Set;
 
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.yang.model.api.Module;
 import org.opendaylight.controller.yang.model.api.SchemaContext;
 import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
 import org.opendaylight.controller.yang2sources.plugin.ConfigArg.CodeGeneratorArg;
@@ -79,7 +81,7 @@ public class GenerateSourcesTest {
 
         @Override
         public Collection<File> generateSources(SchemaContext context,
-                File baseDir) {
+                File baseDir, Set<Module> yangModules) {
             called++;
             outputDir = baseDir;
             return Lists.newArrayList();
index f90c7ef7e404afd93aaa3d39e90b3e87812f35fd..14bcccccaff0f9ad54393322bc372251d7cd344e 100644 (file)
@@ -10,7 +10,9 @@ package org.opendaylight.controller.yang2sources.spi;
 import java.io.File;
 import java.io.IOException;
 import java.util.Collection;
+import java.util.Set;
 
+import org.opendaylight.controller.yang.model.api.Module;
 import org.opendaylight.controller.yang.model.api.SchemaContext;
 
 /**
@@ -27,7 +29,11 @@ public interface CodeGenerator {
      * @param outputBaseDir
      *            expected output directory for generated sources configured by
      *            user
+     * @param yangModules
+     *            yang modules parsed from yangFilesRootDir
      * @return collection of files that were generated from schema context
+     * @throws IOException
      */
-    Collection<File> generateSources(SchemaContext context, File outputBaseDir) throws IOException;
+    Collection<File> generateSources(SchemaContext context, File outputBaseDir,
+            Set<Module> yangModules) throws IOException;
 }
index 6683978988f545189ed58c2fc97242fd5e587959..60496277b8b954455fbf6c576c43f867447ed34c 100644 (file)
@@ -9,14 +9,16 @@ package org.opendaylight.controller.yang2sources.spi;
 
 import java.io.File;
 import java.util.Collection;
+import java.util.Set;
 
+import org.opendaylight.controller.yang.model.api.Module;
 import org.opendaylight.controller.yang.model.api.SchemaContext;
 
 public class CodeGeneratorTestImpl implements CodeGenerator {
 
     @Override
     public Collection<File> generateSources(SchemaContext context,
-            File outputBaseDir) {
+            File outputBaseDir, Set<Module> yangModules) {
         // no-op
         return null;
     }
diff --git a/opendaylight/sal/yang-prototype/code-generator/pom.xml.bak b/opendaylight/sal/yang-prototype/code-generator/pom.xml.bak
deleted file mode 100644 (file)
index 0f0d37e..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <groupId>org.opendaylight.controller</groupId>
-    <artifactId>binding-generator</artifactId>
-    <version>0.5-SNAPSHOT</version>
-    <packaging>pom</packaging>
-    <name>binding-generator</name>
-    
-    <properties>
-               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-       </properties>
-  
-    <modules>
-       <module>../yang</module>
-       <module>../sal/sal-schema-repository-api</module>
-        <module>code-generator-demo</module>
-        <module>yang-model-parser-api</module>
-        <module>yang-model-parser-impl</module>
-        <module>binding-model-api</module>
-        <module>binding-generator-api</module>
-        <module>binding-generator-spi</module>
-        <module>binding-generator-util</module>
-        <module>binding-generator-impl</module>
-        <module>binding-java-api-generator</module>
-        <module>maven-yang</module>
-        <module>yang-maven-plugin</module>
-        <module>yang-maven-plugin-it</module>
-    </modules>
-    <dependencies>
-
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.10</version>
-            <scope>test</scope>
-            <optional>true</optional>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <version>1.7.2</version>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
-            <version>1.7.2</version>
-        </dependency>
-    </dependencies>
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>2.0</version>
-                <inherited>true</inherited>
-                <configuration>
-                    <source>1.6</source>
-                    <target>1.6</target>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-javadoc-plugin</artifactId>
-                <version>2.8.1</version>
-                <configuration>
-                    <stylesheet>maven</stylesheet>
-                </configuration>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>aggregate</goal>
-                        </goals>
-                        <phase>site</phase>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-    <reporting>
-        <plugins>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>findbugs-maven-plugin</artifactId>
-                <version>2.4.0</version>
-                <configuration>
-                    <effort>Max</effort>
-                    <threshold>Low</threshold>
-                    <goal>site</goal>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>jdepend-maven-plugin</artifactId>
-                <version>2.0-beta-2</version>
-            </plugin>
-        </plugins>
-    </reporting>
-</project>
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/antlr/YangParser.g4.bak b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/antlr/YangParser.g4.bak
deleted file mode 100644 (file)
index e15184d..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-parser grammar YangParser;
-
-@header {
-package org.opendaylight.controller.antlrv4.code.gen;
-}
-
-options{
-    tokenVocab=YangLexer;
-    
-}
-
-
-yang : module_stmt | submodule_stmt ;
-
-string : STRING (PLUS STRING)*;
-
-identifier_stmt : IDENTIFIER string? stmtend;
-                  
-stmtend : (SEMICOLON) | (LEFT_BRACE identifier_stmt? RIGHT_BRACE);
-deviate_replace_stmt : DEVIATE_KEYWORD string /* REPLACE_KEYWORD */ (SEMICOLON | (LEFT_BRACE (identifier_stmt |type_stmt | units_stmt | default_stmt | config_stmt | mandatory_stmt | min_elements_stmt | max_elements_stmt )* RIGHT_BRACE));
-deviate_delete_stmt : DEVIATE_KEYWORD string /* DELETE_KEYWORD */ (SEMICOLON | (LEFT_BRACE (identifier_stmt |units_stmt | must_stmt | unique_stmt | default_stmt )* RIGHT_BRACE));
-deviate_add_stmt : DEVIATE_KEYWORD string /*ADD_KEYWORD*/ (SEMICOLON | (LEFT_BRACE (identifier_stmt |units_stmt | must_stmt | unique_stmt | default_stmt | config_stmt | mandatory_stmt  | min_elements_stmt  | max_elements_stmt )* RIGHT_BRACE));
-deviate_not_supported_stmt : DEVIATE_KEYWORD string /*NOT_SUPPORTED_KEYWORD*/ (SEMICOLON | (LEFT_BRACE identifier_stmt? RIGHT_BRACE));
-deviation_stmt : DEVIATION_KEYWORD string LEFT_BRACE (identifier_stmt |description_stmt | reference_stmt | deviate_not_supported_stmt | deviate_add_stmt | deviate_replace_stmt | deviate_delete_stmt)+ RIGHT_BRACE;
-notification_stmt : NOTIFICATION_KEYWORD string (SEMICOLON | (LEFT_BRACE (identifier_stmt |if_feature_stmt | status_stmt | description_stmt | reference_stmt | typedef_stmt | grouping_stmt | data_def_stmt )* RIGHT_BRACE));
-output_stmt : OUTPUT_KEYWORD LEFT_BRACE (identifier_stmt |typedef_stmt | grouping_stmt | data_def_stmt )+ RIGHT_BRACE;
-input_stmt : INPUT_KEYWORD LEFT_BRACE (identifier_stmt |typedef_stmt | grouping_stmt | data_def_stmt )+ RIGHT_BRACE;
-rpc_stmt : RPC_KEYWORD string (SEMICOLON | (LEFT_BRACE (identifier_stmt |if_feature_stmt  | status_stmt | description_stmt | reference_stmt | typedef_stmt | grouping_stmt | input_stmt | output_stmt )* RIGHT_BRACE));
-when_stmt : WHEN_KEYWORD string (SEMICOLON | (LEFT_BRACE (identifier_stmt |description_stmt | reference_stmt )* RIGHT_BRACE));
-
-augment_stmt : AUGMENT_KEYWORD string LEFT_BRACE  (identifier_stmt |when_stmt | if_feature_stmt | status_stmt | description_stmt | reference_stmt | data_def_stmt | case_stmt)+ RIGHT_BRACE;
-uses_augment_stmt : AUGMENT_KEYWORD string LEFT_BRACE  (identifier_stmt |when_stmt | if_feature_stmt | status_stmt | description_stmt | reference_stmt | data_def_stmt | case_stmt)+ RIGHT_BRACE;
-refine_anyxml_stmts : (identifier_stmt |must_stmt | config_stmt | mandatory_stmt | description_stmt | reference_stmt )*;
-refine_case_stmts : (identifier_stmt |description_stmt | reference_stmt )*;
-refine_choice_stmts : (identifier_stmt |default_stmt | config_stmt | mandatory_stmt | description_stmt | reference_stmt )*;
-refine_list_stmts : (identifier_stmt |must_stmt | config_stmt | min_elements_stmt | max_elements_stmt | description_stmt | reference_stmt )*;
-refine_leaf_list_stmts : (identifier_stmt |must_stmt | config_stmt | min_elements_stmt | max_elements_stmt | description_stmt | reference_stmt )*;
-refine_leaf_stmts : (identifier_stmt |must_stmt | default_stmt | config_stmt | mandatory_stmt | description_stmt | reference_stmt )*;
-refine_container_stmts : (identifier_stmt |must_stmt | presence_stmt | config_stmt | description_stmt | reference_stmt )*;
-refine_pom : (refine_container_stmts | refine_leaf_stmts | refine_leaf_list_stmts | refine_list_stmts | refine_choice_stmts | refine_case_stmts | refine_anyxml_stmts);
-refine_stmt : REFINE_KEYWORD string (SEMICOLON | (LEFT_BRACE  (refine_pom) RIGHT_BRACE));
-uses_stmt : USES_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt |when_stmt | if_feature_stmt | status_stmt | description_stmt | reference_stmt | refine_stmt | uses_augment_stmt )* RIGHT_BRACE));
-anyxml_stmt : ANYXML_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt |when_stmt | if_feature_stmt | must_stmt | config_stmt | mandatory_stmt | status_stmt | description_stmt | reference_stmt )* RIGHT_BRACE));
-case_stmt : CASE_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt |when_stmt | if_feature_stmt | status_stmt | description_stmt | reference_stmt | data_def_stmt )* RIGHT_BRACE));
-short_case_stmt : container_stmt | leaf_stmt | leaf_list_stmt | list_stmt | anyxml_stmt;
-choice_stmt : CHOICE_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt |when_stmt | if_feature_stmt | default_stmt | config_stmt | mandatory_stmt | status_stmt | description_stmt | reference_stmt | short_case_stmt | case_stmt)* RIGHT_BRACE));
-unique_stmt : UNIQUE_KEYWORD string stmtend;
-key_stmt : KEY_KEYWORD string stmtend;
-list_stmt : LIST_KEYWORD string LEFT_BRACE  (identifier_stmt |when_stmt | if_feature_stmt | must_stmt | key_stmt | unique_stmt | config_stmt | min_elements_stmt | max_elements_stmt | ordered_by_stmt | status_stmt | description_stmt | reference_stmt | typedef_stmt | grouping_stmt | data_def_stmt )+ RIGHT_BRACE;
-leaf_list_stmt : LEAF_LIST_KEYWORD string LEFT_BRACE  (identifier_stmt |when_stmt | if_feature_stmt | type_stmt | units_stmt | must_stmt | config_stmt | min_elements_stmt | max_elements_stmt | ordered_by_stmt | status_stmt | description_stmt | reference_stmt )* RIGHT_BRACE;
-leaf_stmt : LEAF_KEYWORD string LEFT_BRACE  (identifier_stmt |when_stmt | if_feature_stmt | type_stmt | units_stmt | must_stmt | default_stmt | config_stmt | mandatory_stmt | status_stmt | description_stmt | reference_stmt )* RIGHT_BRACE;
-container_stmt : CONTAINER_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt | when_stmt | if_feature_stmt | must_stmt | presence_stmt | config_stmt | status_stmt | description_stmt | reference_stmt | typedef_stmt | grouping_stmt | data_def_stmt )* RIGHT_BRACE));
-grouping_stmt : GROUPING_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt |status_stmt | description_stmt | reference_stmt | typedef_stmt | grouping_stmt | data_def_stmt )* RIGHT_BRACE));
-value_stmt : VALUE_KEYWORD string stmtend;
-max_value_arg : /*UNBOUNDED_KEYWORD |*/ string;
-max_elements_stmt : MAX_ELEMENTS_KEYWORD max_value_arg stmtend;
-min_elements_stmt : MIN_ELEMENTS_KEYWORD string stmtend;
-error_app_tag_stmt : ERROR_APP_TAG_KEYWORD string stmtend;
-error_message_stmt : ERROR_MESSAGE_KEYWORD string stmtend;
-must_stmt : MUST_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt |error_message_stmt | error_app_tag_stmt | description_stmt | reference_stmt )* RIGHT_BRACE));
-ordered_by_arg : string; /*USER_KEYWORD | SYSTEM_KEYWORD;*/
-ordered_by_stmt : ORDERED_BY_KEYWORD ordered_by_arg stmtend;
-presence_stmt : PRESENCE_KEYWORD string stmtend;
-mandatory_arg :string; // TRUE_KEYWORD | FALSE_KEYWORD;
-mandatory_stmt : MANDATORY_KEYWORD mandatory_arg stmtend;
-config_arg : string; //  TRUE_KEYWORD | FALSE_KEYWORD;
-config_stmt : CONFIG_KEYWORD config_arg stmtend;
-status_arg : string; /*CURRENT_KEYWORD | OBSOLETE_KEYWORD | DEPRECATED_KEYWORD; */
-status_stmt : STATUS_KEYWORD status_arg stmtend;
-position_stmt : POSITION_KEYWORD string stmtend;
-bit_stmt : BIT_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt |position_stmt | status_stmt | description_stmt | reference_stmt )* RIGHT_BRACE));
-bits_specification : bit_stmt (bit_stmt | identifier_stmt)*;
-union_specification : type_stmt (identifier_stmt | type_stmt )+;
-identityref_specification : base_stmt  ;
-instance_identifier_specification : (require_instance_stmt )?;
-require_instance_arg :string; // TRUE_KEYWORD | FALSE_KEYWORD;
-require_instance_stmt : REQUIRE_INSTANCE_KEYWORD require_instance_arg stmtend;
-path_stmt : PATH_KEYWORD string stmtend;
-leafref_specification : path_stmt;
-enum_stmt : ENUM_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt |value_stmt | status_stmt | description_stmt | reference_stmt )* RIGHT_BRACE));
-enum_specification : enum_stmt (identifier_stmt | enum_stmt )*;
-default_stmt : DEFAULT_KEYWORD string stmtend;
-pattern_stmt : PATTERN_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt |error_message_stmt | error_app_tag_stmt | description_stmt | reference_stmt )* RIGHT_BRACE));
-length_stmt : LENGTH_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt |error_message_stmt | error_app_tag_stmt | description_stmt | reference_stmt )* RIGHT_BRACE));
-string_restrictions : (length_stmt | pattern_stmt )*;
-fraction_digits_stmt : FRACTION_DIGITS_KEYWORD string stmtend;
-decimal64_specification : (numerical_restrictions? (identifier_stmt)* fraction_digits_stmt | fraction_digits_stmt (identifier_stmt)* numerical_restrictions?);
-range_stmt : RANGE_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt |error_message_stmt | error_app_tag_stmt | description_stmt | reference_stmt )* RIGHT_BRACE));
-numerical_restrictions : range_stmt ;
-type_body_stmts : (identifier_stmt)* (numerical_restrictions | decimal64_specification | string_restrictions | enum_specification | leafref_specification | identityref_specification | instance_identifier_specification | bits_specification | union_specification) (identifier_stmt)*;
-type_stmt : TYPE_KEYWORD string (SEMICOLON | (LEFT_BRACE  type_body_stmts RIGHT_BRACE));
-typedef_stmt : TYPEDEF_KEYWORD string LEFT_BRACE  (identifier_stmt | type_stmt | units_stmt | default_stmt | status_stmt | description_stmt | reference_stmt )+ RIGHT_BRACE;
-if_feature_stmt : IF_FEATURE_KEYWORD string stmtend;
-feature_stmt : FEATURE_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt | if_feature_stmt | status_stmt | description_stmt | reference_stmt )* RIGHT_BRACE));
-base_stmt : BASE_KEYWORD string stmtend;
-identity_stmt : IDENTITY_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt | base_stmt | status_stmt | description_stmt | reference_stmt )* RIGHT_BRACE));
-yin_element_arg : string; // TRUE_KEYWORD | FALSE_KEYWORD;
-yin_element_stmt : YIN_ELEMENT_KEYWORD yin_element_arg stmtend;
-argument_stmt : ARGUMENT_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt)? (yin_element_stmt )? (identifier_stmt)* RIGHT_BRACE));
-extension_stmt : EXTENSION_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt | argument_stmt | status_stmt | description_stmt | reference_stmt )* RIGHT_BRACE));
-revision_date_stmt : REVISION_DATE_KEYWORD string stmtend;
-revision_stmt : REVISION_KEYWORD string (SEMICOLON | (LEFT_BRACE  (description_stmt )? (reference_stmt )? RIGHT_BRACE));
-units_stmt : UNITS_KEYWORD string stmtend;
-reference_stmt : REFERENCE_KEYWORD string stmtend;
-description_stmt : DESCRIPTION_KEYWORD string stmtend;
-contact_stmt : CONTACT_KEYWORD string stmtend;
-organization_stmt : ORGANIZATION_KEYWORD string stmtend;
-belongs_to_stmt : BELONGS_TO_KEYWORD string LEFT_BRACE  prefix_stmt  RIGHT_BRACE;
-prefix_stmt : PREFIX_KEYWORD string stmtend;
-namespace_stmt : NAMESPACE_KEYWORD string stmtend;
-include_stmt : INCLUDE_KEYWORD string (SEMICOLON | (LEFT_BRACE  (revision_date_stmt )? RIGHT_BRACE));
-import_stmt : IMPORT_KEYWORD string LEFT_BRACE  prefix_stmt  (revision_date_stmt )? RIGHT_BRACE;
-yang_version_stmt : YANG_VERSION_KEYWORD string stmtend;
-data_def_stmt : container_stmt | leaf_stmt | leaf_list_stmt | list_stmt | choice_stmt | anyxml_stmt | uses_stmt;
-body_stmts : (( identifier_stmt| extension_stmt | feature_stmt | identity_stmt | typedef_stmt | grouping_stmt | data_def_stmt | augment_stmt | rpc_stmt | notification_stmt | deviation_stmt) )*;
-revision_stmts : (revision_stmt )*;
-linkage_stmts : (import_stmt | include_stmt )*;
-meta_stmts : (organization_stmt | contact_stmt | description_stmt | reference_stmt )*;
-submodule_header_stmts : (yang_version_stmt | belongs_to_stmt)+ ;
-module_header_stmts :   (yang_version_stmt | namespace_stmt | prefix_stmt)+ ;
-submodule_stmt : SUBMODULE_KEYWORD string LEFT_BRACE  submodule_header_stmts linkage_stmts meta_stmts revision_stmts body_stmts RIGHT_BRACE;
-module_stmt : MODULE_KEYWORD string LEFT_BRACE  module_header_stmts linkage_stmts meta_stmts revision_stmts body_stmts RIGHT_BRACE;
index 605ca6dcf4509ade3a24cbe7c61aed43a362445a..70079b39aa37a0f7d1bb114f6c22561dc6ed11d1 100644 (file)
@@ -190,6 +190,8 @@ public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder
                 + ((augmentTargetStr == null) ? 0 : augmentTargetStr.hashCode());
         result = prime * result
                 + ((whenCondition == null) ? 0 : whenCondition.hashCode());
+        result = prime * result
+                + ((childNodes == null) ? 0 : childNodes.hashCode());
         return result;
     }
 
@@ -219,6 +221,13 @@ public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder
         } else if (!whenCondition.equals(other.whenCondition)) {
             return false;
         }
+        if (childNodes == null) {
+            if (other.childNodes != null) {
+                return false;
+            }
+        } else if (!childNodes.equals(other.childNodes)) {
+            return false;
+        }
         return true;
     }
 
index 2437b98d4dfa24f5e63fe6aa0a7f1e2c36e69f51..afbbec998d3f2066df89f94caabb242a866cc904 100644 (file)
@@ -11,10 +11,6 @@ package org.opendaylight.controller.samples.simpleforwarding.internal;
 
 import java.io.Serializable;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-
 import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
 import org.opendaylight.controller.sal.core.Node;
 
@@ -53,16 +49,37 @@ public class HostNodePair implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((host == null) ? 0 : host.hashCode());
+        result = prime * result + ((node == null) ? 0 : node.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        HostNodePair other = (HostNodePair) obj;
+        if (host == null) {
+            if (other.host != null)
+                return false;
+        } else if (!host.equals(other.host))
+            return false;
+        if (node == null) {
+            if (other.node != null)
+                return false;
+        } else if (!node.equals(other.node))
+            return false;
+        return true;
     }
 
     @Override
     public String toString() {
-        return "HostNodePair[" + ReflectionToStringBuilder.toString(this) + "]";
+        return "HostNodePair [host=" + host + ", node=" + node + "]";
     }
 }
index f701553811b6e15c191e9aac30aa5dcc61b4fd03..80ed20981961b56e21d397575ea09c2712190cdd 100644 (file)
@@ -14,15 +14,11 @@ import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
 import org.opendaylight.controller.sal.utils.GUIField;
-
-import org.opendaylight.controller.switchmanager.SpanConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -69,12 +65,34 @@ public class SpanConfig implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode());
+        result = prime * result
+                + ((spanPort == null) ? 0 : spanPort.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        SpanConfig other = (SpanConfig) obj;
+        if (nodeId == null) {
+            if (other.nodeId != null)
+                return false;
+        } else if (!nodeId.equals(other.nodeId))
+            return false;
+        if (spanPort == null) {
+            if (other.spanPort != null)
+                return false;
+        } else if (!spanPort.equals(other.spanPort))
+            return false;
+        return true;
     }
 
     public static ArrayList<String> getFieldsNames() {
index 551f0722db2e1fd30c3e9d61bc17a5577cd07616..e15303581f9ad32be958dd3971cd0cf92dc8d8bd 100644 (file)
@@ -15,13 +15,8 @@ import java.net.UnknownHostException;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.core.NodeConnector;
 
-import org.opendaylight.controller.switchmanager.Subnet;
-import org.opendaylight.controller.switchmanager.SubnetConfig;
-
 /**
  * The class describes subnet information including L3 address, vlan and set of
  * ports associated with the subnet.
@@ -179,33 +174,43 @@ public class Subnet implements Serializable {
         return this;
     }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#hashCode()
-     */
     @Override
     public int hashCode() {
-        return new HashCodeBuilder().append(networkAddress).append(
-                subnetMaskLength).toHashCode();
+        final int prime = 31;
+        int result = 1;
+        result = prime * result
+                + ((networkAddress == null) ? 0 : networkAddress.hashCode());
+        result = prime * result
+                + ((nodeConnectors == null) ? 0 : nodeConnectors.hashCode());
+        result = prime * result + subnetMaskLength;
+        result = prime * result + vlan;
+        return result;
     }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
     @Override
     public boolean equals(Object obj) {
-        if (this == obj) {
+        if (this == obj)
             return true;
-        }
-        if (obj == null) {
+        if (obj == null)
             return false;
-        }
-        if (obj.getClass() != getClass()) {
+        if (getClass() != obj.getClass())
             return false;
-        }
         Subnet other = (Subnet) obj;
-        // Check only equality for the key fields
-        return new EqualsBuilder().append(networkAddress, other.networkAddress)
-                .append(subnetMaskLength, other.subnetMaskLength).isEquals();
+        if (networkAddress == null) {
+            if (other.networkAddress != null)
+                return false;
+        } else if (!networkAddress.equals(other.networkAddress))
+            return false;
+        if (nodeConnectors == null) {
+            if (other.nodeConnectors != null)
+                return false;
+        } else if (!nodeConnectors.equals(other.nodeConnectors))
+            return false;
+        if (subnetMaskLength != other.subnetMaskLength)
+            return false;
+        if (vlan != other.vlan)
+            return false;
+        return true;
     }
 
     /* (non-Javadoc)
index afca30c3a1c89a9a1ce254e925e0cc33ae89b142..6ba78deaded8b817ee4fc382dc8560f1d3a74d10 100644 (file)
@@ -11,12 +11,11 @@ package org.opendaylight.controller.switchmanager;
 
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
@@ -125,12 +124,44 @@ public class Switch implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + Arrays.hashCode(dataLayerAddress);
+        result = prime * result + ((node == null) ? 0 : node.hashCode());
+        result = prime * result
+                + ((nodeConnectors == null) ? 0 : nodeConnectors.hashCode());
+        result = prime * result
+                + ((spanPorts == null) ? 0 : spanPorts.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Switch other = (Switch) obj;
+        if (!Arrays.equals(dataLayerAddress, other.dataLayerAddress))
+            return false;
+        if (node == null) {
+            if (other.node != null)
+                return false;
+        } else if (!node.equals(other.node))
+            return false;
+        if (nodeConnectors == null) {
+            if (other.nodeConnectors != null)
+                return false;
+        } else if (!nodeConnectors.equals(other.nodeConnectors))
+            return false;
+        if (spanPorts == null) {
+            if (other.spanPorts != null)
+                return false;
+        } else if (!spanPorts.equals(other.spanPorts))
+            return false;
+        return true;
     }
 
     @Override
index ffb8ec042c619e9f28485a76a56fb3143adcfeca..778310e07ff6a4d7879ed8e26e33cf7e9976901b 100644 (file)
@@ -11,9 +11,6 @@ package org.opendaylight.controller.switchmanager;
 
 import java.io.Serializable;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
 /**
  * The class describes a switch configuration including node identifier, node
  * name, tier number and proactive/reactive mode.
@@ -59,11 +56,45 @@ public class SwitchConfig implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result
+                + ((description == null) ? 0 : description.hashCode());
+        result = prime * result + ((mode == null) ? 0 : mode.hashCode());
+        result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode());
+        result = prime * result + ((tier == null) ? 0 : tier.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        SwitchConfig other = (SwitchConfig) obj;
+        if (description == null) {
+            if (other.description != null)
+                return false;
+        } else if (!description.equals(other.description))
+            return false;
+        if (mode == null) {
+            if (other.mode != null)
+                return false;
+        } else if (!mode.equals(other.mode))
+            return false;
+        if (nodeId == null) {
+            if (other.nodeId != null)
+                return false;
+        } else if (!nodeId.equals(other.nodeId))
+            return false;
+        if (tier == null) {
+            if (other.tier != null)
+                return false;
+        } else if (!tier.equals(other.tier))
+            return false;
+        return true;
     }
 }
index 649fee8f7f1b3ef4b5a5a920fd4fd5d6cb6e5ce5..2ad98aba68ff58cc64ea546e6db0fe689e000fa9 100644 (file)
@@ -11,9 +11,6 @@ package org.opendaylight.controller.usermanager.internal;
 
 import java.io.Serializable;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
 /**
  * Configuration Java Object which represents a Remote AAA server configuration
  * information for User Manager.
@@ -49,12 +46,40 @@ public class ServerConfig implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((ip == null) ? 0 : ip.hashCode());
+        result = prime * result
+                + ((protocol == null) ? 0 : protocol.hashCode());
+        result = prime * result + ((secret == null) ? 0 : secret.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        ServerConfig other = (ServerConfig) obj;
+        if (ip == null) {
+            if (other.ip != null)
+                return false;
+        } else if (!ip.equals(other.ip))
+            return false;
+        if (protocol == null) {
+            if (other.protocol != null)
+                return false;
+        } else if (!protocol.equals(other.protocol))
+            return false;
+        if (secret == null) {
+            if (other.secret != null)
+                return false;
+        } else if (!secret.equals(other.secret))
+            return false;
+        return true;
     }
 
     public boolean isValid() {
index fd491fe880c36d928f2ca07eb52587d2355ba6c9..176af3a3e4d1d48ed9b8120f65b7bc5a6bca9ffb 100644 (file)
@@ -15,8 +15,6 @@ import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.authorization.AuthResultEnum;
 import org.opendaylight.controller.sal.utils.Status;
 import org.opendaylight.controller.sal.utils.StatusCode;
@@ -66,12 +64,40 @@ public class UserConfig implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result
+                + ((password == null) ? 0 : password.hashCode());
+        result = prime * result + ((roles == null) ? 0 : roles.hashCode());
+        result = prime * result + ((user == null) ? 0 : user.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        UserConfig other = (UserConfig) obj;
+        if (password == null) {
+            if (other.password != null)
+                return false;
+        } else if (!password.equals(other.password))
+            return false;
+        if (roles == null) {
+            if (other.roles != null)
+                return false;
+        } else if (!roles.equals(other.roles))
+            return false;
+        if (user == null) {
+            if (other.user != null)
+                return false;
+        } else if (!user.equals(other.user))
+            return false;
+        return true;
     }
 
     @Override