Merge "Fixing minor build errors"
authorGiovanni Meo <gmeo@cisco.com>
Thu, 16 May 2013 13:01:49 +0000 (13:01 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 16 May 2013 13:01:49 +0000 (13:01 +0000)
42 files changed:
opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntry.java
opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntryInstall.java
opendaylight/hosttracker/api/src/main/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnector.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6Error.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6StatsReply.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6StatsRequest.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Output.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/PushVlan.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetDlDst.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetDlSrc.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetDlType.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetNwDst.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetNwSrc.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetNwTos.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetTpDst.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetTpSrc.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanCfi.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanId.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/SetVlanPcp.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/authorization/Resource.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/authorization/ResourceGroup.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Actions.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Bandwidth.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Buffers.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Capabilities.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Config.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/ContainerFlow.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Description.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Edge.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Host.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Latency.java
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/java/org/opendaylight/controller/yang2sources/plugin/it/YangToSourcesPluginTest.java
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest1/pom.xml [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest1/src/main/resources/testfile1.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest1/src/main/resources/testfile2.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest1/src/main/resources/testfile3.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest2/pom.xml [new file with mode: 0644]
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/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/UnionTypeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/impl/YangParserImpl.java

index 2e174d25e29930e43431d72052c8060ddc5b9939..6aa5b07e2a0e782c81f15de11835758ce1cc4cea 100644 (file)
@@ -11,8 +11,6 @@ package org.opendaylight.controller.forwardingrulesmanager;
 import java.io.Serializable;
 import java.util.Date;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.core.ContainerFlow;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
@@ -90,12 +88,47 @@ public class FlowEntry implements Cloneable, Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((flow == null) ? 0 : flow.hashCode());
+        result = prime * result
+                + ((flowName == null) ? 0 : flowName.hashCode());
+        result = prime * result
+                + ((groupName == null) ? 0 : groupName.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;
+        FlowEntry other = (FlowEntry) obj;
+        if (flow == null) {
+            if (other.flow != null)
+                return false;
+        } else if (!flow.equals(other.flow))
+            return false;
+        if (flowName == null) {
+            if (other.flowName != null)
+                return false;
+        } else if (!flowName.equals(other.flowName))
+            return false;
+        if (groupName == null) {
+            if (other.groupName != null)
+                return false;
+        } else if (!groupName.equals(other.groupName))
+            return false;
+        if (node == null) {
+            if (other.node != null)
+                return false;
+        } else if (!node.equals(other.node))
+            return false;
+        return true;
     }
 
     @Override
index 96b6819e5773f6071808e96a4523887c060b20a8..18255bc021aeffbc4ee5b887d98b19065dd9d08a 100644 (file)
@@ -8,8 +8,6 @@
 
 package org.opendaylight.controller.forwardingrulesmanager;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.core.ContainerFlow;
 import org.opendaylight.controller.sal.core.Node;
 
@@ -42,12 +40,40 @@ public class FlowEntryInstall {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((cFlow == null) ? 0 : cFlow.hashCode());
+        result = prime * result + ((install == null) ? 0 : install.hashCode());
+        result = prime * result
+                + ((original == null) ? 0 : original.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;
+        FlowEntryInstall other = (FlowEntryInstall) obj;
+        if (cFlow == null) {
+            if (other.cFlow != null)
+                return false;
+        } else if (!cFlow.equals(other.cFlow))
+            return false;
+        if (install == null) {
+            if (other.install != null)
+                return false;
+        } else if (!install.equals(other.install))
+            return false;
+        if (original == null) {
+            if (other.original != null)
+                return false;
+        } else if (!original.equals(other.original))
+            return false;
+        return true;
     }
 
     public String getFlowName() {
index c83dc3d4089870cc020d0b6abf6fbd15e3637042..e7b5745a2ec63c3fc3544d3b538e1d5188154303 100644 (file)
@@ -19,8 +19,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.apache.commons.lang3.builder.ReflectionToStringBuilder;
 import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.Host;
@@ -140,20 +138,36 @@ public class HostNodeConnector extends Host {
         return this;
     }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#hashCode()
-     */
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result
+                + ((nodeConnector == null) ? 0 : nodeConnector.hashCode());
+        result = prime * result + (staticHost ? 1231 : 1237);
+        result = prime * result + vlan;
+        return result;
     }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
     @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;
+        HostNodeConnector other = (HostNodeConnector) obj;
+        if (nodeConnector == null) {
+            if (other.nodeConnector != null)
+                return false;
+        } else if (!nodeConnector.equals(other.nodeConnector))
+            return false;
+        if (staticHost != other.staticHost)
+            return false;
+        if (vlan != other.vlan)
+            return false;
+        return true;
     }
 
     public boolean equalsByIP(InetAddress networkAddress) {
index 4f0dbd5ca55b0b621f6202a68e7488cdc4447486..c52c3f56b800a57ff247bc4a7246db2b3065c49d 100644 (file)
@@ -1,10 +1,8 @@
 package org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension;
 
 import java.nio.ByteBuffer;
+import java.util.Arrays;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 import org.openflow.protocol.OFError;
 
 public class V6Error extends OFError {
@@ -65,16 +63,44 @@ public class V6Error extends OFError {
     
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + Arrays.hashCode(V6ErrorData);
+        result = prime * result + V6VendorErrorCode;
+        result = prime * result + V6VendorErrorType;
+        result = prime * result + V6VendorId;
+        return result;
     }
 
     @Override
     public String toString() {
-        return "V6Error[" + ReflectionToStringBuilder.toString(this) + "]";
+        return "V6Error [V6VendorId=" + V6VendorId + ", V6VendorErrorType="
+                + V6VendorErrorType + ", V6VendorErrorCode="
+                + V6VendorErrorCode + ", V6ErrorData="
+                + Arrays.toString(V6ErrorData) + ", errorType=" + errorType
+                + ", errorCode=" + errorCode + ", factory=" + factory
+                + ", error=" + Arrays.toString(error) + ", errorIsAscii="
+                + errorIsAscii + ", version=" + version + ", type=" + type
+                + ", length=" + length + ", xid=" + xid + "]";
     }
 
     @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;
+        V6Error other = (V6Error) obj;
+        if (!Arrays.equals(V6ErrorData, other.V6ErrorData))
+            return false;
+        if (V6VendorErrorCode != other.V6VendorErrorCode)
+            return false;
+        if (V6VendorErrorType != other.V6VendorErrorType)
+            return false;
+        if (V6VendorId != other.V6VendorId)
+            return false;
+        return true;
     }
 }
index 8b5662ccf1bd282a96e1bafb30ea8844b409268d..6893fa78e279979bb3149038a3f87b3bc4234a49 100644 (file)
@@ -12,9 +12,6 @@ package org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6e
 import java.nio.ByteBuffer;
 import java.util.List;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 import org.openflow.protocol.action.OFAction;
 import org.openflow.protocol.statistics.OFVendorStatistics;
 import org.openflow.util.U16;
@@ -314,17 +311,84 @@ public class V6StatsReply extends OFVendorStatistics {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        result = prime * result + (int) (byteCount ^ (byteCount >>> 32));
+        result = prime * result + (int) (cookie ^ (cookie >>> 32));
+        result = prime * result + durationNanoseconds;
+        result = prime * result + durationSeconds;
+        result = prime * result + hardAge;
+        result = prime * result + hardTimeout;
+        result = prime * result + idleAge;
+        result = prime * result + idleTimeout;
+        result = prime * result + length;
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + match_len;
+        result = prime * result + (int) (packetCount ^ (packetCount >>> 32));
+        result = prime * result + priority;
+        result = prime * result + tableId;
+        return result;
     }
 
     @Override
     public String toString() {
-        return "V6StatsReply[" + ReflectionToStringBuilder.toString(this) + "]";
+        return "V6StatsReply [length=" + length + ", tableId=" + tableId
+                + ", durationSeconds=" + durationSeconds
+                + ", durationNanoseconds=" + durationNanoseconds
+                + ", priority=" + priority + ", idleTimeout=" + idleTimeout
+                + ", hardTimeout=" + hardTimeout + ", match_len=" + match_len
+                + ", idleAge=" + idleAge + ", hardAge=" + hardAge + ", cookie="
+                + cookie + ", packetCount=" + packetCount + ", byteCount="
+                + byteCount + ", match=" + match + ", actions=" + actions + "]";
     }
 
     @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;
+        V6StatsReply other = (V6StatsReply) obj;
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        if (byteCount != other.byteCount)
+            return false;
+        if (cookie != other.cookie)
+            return false;
+        if (durationNanoseconds != other.durationNanoseconds)
+            return false;
+        if (durationSeconds != other.durationSeconds)
+            return false;
+        if (hardAge != other.hardAge)
+            return false;
+        if (hardTimeout != other.hardTimeout)
+            return false;
+        if (idleAge != other.idleAge)
+            return false;
+        if (idleTimeout != other.idleTimeout)
+            return false;
+        if (length != other.length)
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (match_len != other.match_len)
+            return false;
+        if (packetCount != other.packetCount)
+            return false;
+        if (priority != other.priority)
+            return false;
+        if (tableId != other.tableId)
+            return false;
+        return true;
     }
 
 }
index 26d0065a45162ca493a5c15266d4b405ecc338ab..593b464d3c68cec4f3a753657c3085a9081b94bf 100644 (file)
@@ -9,11 +9,10 @@
 
 package org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
+import java.nio.ByteBuffer;
+
 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 import org.openflow.protocol.statistics.OFVendorStatistics;
-import java.nio.ByteBuffer;
 
 
 /**
@@ -140,7 +139,13 @@ public class V6StatsRequest extends OFVendorStatistics {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + match_len;
+        result = prime * result + msgsubtype;
+        result = prime * result + outPort;
+        result = prime * result + tableId;
+        return result;
     }
 
     @Override
@@ -151,6 +156,21 @@ public class V6StatsRequest extends OFVendorStatistics {
 
     @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;
+        V6StatsRequest other = (V6StatsRequest) obj;
+        if (match_len != other.match_len)
+            return false;
+        if (msgsubtype != other.msgsubtype)
+            return false;
+        if (outPort != other.outPort)
+            return false;
+        if (tableId != other.tableId)
+            return false;
+        return true;
     }
 }
index 5e4f5f81fa15ef92d044324c667f97c7ddbffccd..d8144d7bb74eaaf7a043ce3cba623b58b53c041b 100644 (file)
@@ -15,8 +15,6 @@ import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.bind.annotation.XmlTransient;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -122,12 +120,24 @@ public abstract class Action {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((type == null) ? 0 : type.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;
+        Action other = (Action) obj;
+        if (type != other.type)
+            return false;
+        return true;
     }
 
     @Override
index 8c23da8cfa2c80bf79d71296de60ff0b9d68d2f4..e09968836ff1877cfb195974808aaceda1ef4680 100644 (file)
@@ -14,8 +14,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.core.NodeConnector;
 
 /**
@@ -46,13 +44,28 @@ public class Output extends Action {
     }
 
     @Override
-    public boolean equals(Object other) {
-        return EqualsBuilder.reflectionEquals(this, other);
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Output other = (Output) obj;
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        return result;
     }
 
     @Override
index d50851ae49705df37bf61c5f143c3cdc7d87051d..f3b862fe7e2d2e16e5a5e07da4afa992d0478a6a 100644 (file)
@@ -14,8 +14,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;
 
 /**
@@ -147,13 +145,34 @@ public class PushVlan extends Action {
     }
 
     @Override
-    public boolean equals(Object other) {
-        return EqualsBuilder.reflectionEquals(this, other);
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        PushVlan other = (PushVlan) obj;
+        if (cfi != other.cfi)
+            return false;
+        if (pcp != other.pcp)
+            return false;
+        if (tag != other.tag)
+            return false;
+        if (vlanId != other.vlanId)
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + cfi;
+        result = prime * result + pcp;
+        result = prime * result + tag;
+        result = prime * result + vlanId;
+        return result;
     }
 
     @Override
index 53c2806443203f55dd47003d135ff1f4a5825094..2413c23314b5732c3e5d17cbbb44058835cb3d2d 100644 (file)
@@ -9,13 +9,13 @@
 
 package org.opendaylight.controller.sal.action;
 
+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.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.utils.HexEncode;
 
 /**
@@ -52,13 +52,25 @@ public class SetDlDst extends Action {
     }
     
     @Override
-    public boolean equals(Object other) {
-        return EqualsBuilder.reflectionEquals(this, other);
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        SetDlDst other = (SetDlDst) obj;
+        if (!Arrays.equals(address, other.address))
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + Arrays.hashCode(address);
+        return result;
     }
 
     @Override
index 9d31fe274e19fdb2157c1841c85b4511c5c0c95d..3cdd5b617038c9aadf5aad41115edfebc26ef768 100644 (file)
@@ -9,13 +9,13 @@
 
 package org.opendaylight.controller.sal.action;
 
+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.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.utils.HexEncode;
 
 /**
@@ -56,13 +56,25 @@ public class SetDlSrc extends Action {
     }
     
     @Override
-    public boolean equals(Object other) {
-        return EqualsBuilder.reflectionEquals(this, other);
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        SetDlSrc other = (SetDlSrc) obj;
+        if (!Arrays.equals(address, other.address))
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + Arrays.hashCode(address);
+        return result;
     }
 
     @Override
index 51a24a6ac2ecd1cff2374c72158df4217b7d462a..f76000c64948d42849fd4e5c1cde568e373dcf4b 100644 (file)
@@ -14,8 +14,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;
 
 /**
@@ -55,13 +53,25 @@ public class SetDlType extends Action {
     }
 
     @Override
-    public boolean equals(Object other) {
-        return EqualsBuilder.reflectionEquals(this, other);
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        SetDlType other = (SetDlType) obj;
+        if (dlType != other.dlType)
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + dlType;
+        return result;
     }
 
     @Override
index 7db7081ab967c64c480f3a913c961249bfeaaac2..bccca3f1f236b99aafee3a77d8803aad9111a284 100644 (file)
@@ -16,9 +16,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;
-
 /**
  * Set network destination address action
  */
@@ -53,13 +50,28 @@ public class SetNwDst extends Action {
     }
 
     @Override
-    public boolean equals(Object other) {
-        return EqualsBuilder.reflectionEquals(this, other);
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        SetNwDst other = (SetNwDst) obj;
+        if (address == null) {
+            if (other.address != null)
+                return false;
+        } else if (!address.equals(other.address))
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((address == null) ? 0 : address.hashCode());
+        return result;
     }
 
     @Override
index 3e75e47502cae2710a8f5d16b351d0ffae5e283e..5595b610de6f153cd3fbea6b8e46039ceadfaaea 100644 (file)
@@ -16,9 +16,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;
-
 /**
  * Set network source address action
  */
@@ -53,13 +50,28 @@ public class SetNwSrc extends Action {
     }
 
     @Override
-    public boolean equals(Object other) {
-        return EqualsBuilder.reflectionEquals(this, other);
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        SetNwSrc other = (SetNwSrc) obj;
+        if (address == null) {
+            if (other.address != null)
+                return false;
+        } else if (!address.equals(other.address))
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((address == null) ? 0 : address.hashCode());
+        return result;
     }
 
     @Override
index 33c96d37385df0a31d36c5ac960e1805f8e789a6..69fdd89ffb4cfb10f12ae899498c007454511edf 100644 (file)
@@ -14,9 +14,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;
-
 /**
  * Set network TOS action
  */
@@ -47,13 +44,25 @@ public class SetNwTos extends Action {
     }
 
     @Override
-    public boolean equals(Object other) {
-        return EqualsBuilder.reflectionEquals(this, other);
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        SetNwTos other = (SetNwTos) obj;
+        if (tos != other.tos)
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + tos;
+        return result;
     }
 
     @Override
index fb7c824494fc3b1aca82859b81045adaa7e7e204..825092c54fe355b520d0098771142b662c265930 100644 (file)
@@ -14,9 +14,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;
-
 /**
  * Set destination transport port action
  */
@@ -46,13 +43,25 @@ public class SetTpDst extends Action {
     }
 
     @Override
-    public boolean equals(Object other) {
-        return EqualsBuilder.reflectionEquals(this, other);
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        SetTpDst other = (SetTpDst) obj;
+        if (port != other.port)
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + port;
+        return result;
     }
 
     @Override
index 20210ad5e846f1eb4dfaee76c9b4f1616f0c0cc4..cdae5aad2ac7385c300f9c0f1f43f6456fd73f7d 100644 (file)
@@ -14,9 +14,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;
-
 /**
  * Set source transport port action
  *
@@ -47,13 +44,25 @@ public class SetTpSrc extends Action {
     }
 
     @Override
-    public boolean equals(Object other) {
-        return EqualsBuilder.reflectionEquals(this, other);
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        SetTpSrc other = (SetTpSrc) obj;
+        if (port != other.port)
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + port;
+        return result;
     }
 
     @Override
index c21430e9e95803ab698f6edc6d18fbf99cc5c7a1..fc3d0a60ef2a742a3929f8d6f09490db2f3511ab 100644 (file)
@@ -14,9 +14,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;
-
 /**
  * Set vlan CFI action
  *
@@ -47,13 +44,25 @@ public class SetVlanCfi extends Action {
     }
 
     @Override
-    public boolean equals(Object other) {
-        return EqualsBuilder.reflectionEquals(this, other);
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        SetVlanCfi other = (SetVlanCfi) obj;
+        if (cfi != other.cfi)
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + cfi;
+        return result;
     }
 
     @Override
index 9c9b364b897d1e9d31a381dbf5aeb292337fdd3e..b1e4748bc3b4f9dd1426cd4958af319eabda5e23 100644 (file)
@@ -14,9 +14,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;
-
 /**
  * Set vlan id action
  */
@@ -48,13 +45,25 @@ public class SetVlanId extends Action {
     }
 
     @Override
-    public boolean equals(Object other) {
-        return EqualsBuilder.reflectionEquals(this, other);
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        SetVlanId other = (SetVlanId) obj;
+        if (vlanId != other.vlanId)
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + vlanId;
+        return result;
     }
 
     @Override
index 5c315debffc2a044eaadb9bf63609929498b3a41..c47723ebdf61021bde42532dfe45ac4e26584cee 100644 (file)
@@ -14,9 +14,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;
-
 /**
  * Set vlan PCP action
  */
@@ -46,13 +43,25 @@ public class SetVlanPcp extends Action {
     }
 
     @Override
-    public boolean equals(Object other) {
-        return EqualsBuilder.reflectionEquals(this, other);
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        SetVlanPcp other = (SetVlanPcp) obj;
+        if (pcp != other.pcp)
+            return false;
+        return true;
     }
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + pcp;
+        return result;
     }
 
     @Override
index ef8744b551bb2aea811f0b92ce4b77e2248942b0..9cf7420d1b01c7622d7d0576ccb0493456891001 100644 (file)
@@ -11,9 +11,6 @@ package org.opendaylight.controller.sal.authorization;
 
 import java.io.Serializable;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
 /**
  * It represents the elementary resource along with
  * the access privilege associated to it
@@ -38,12 +35,32 @@ public class Resource implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result
+                + ((privilege == null) ? 0 : privilege.hashCode());
+        result = prime * result
+                + ((resource == null) ? 0 : resource.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;
+        Resource other = (Resource) obj;
+        if (privilege != other.privilege)
+            return false;
+        if (resource == null) {
+            if (other.resource != null)
+                return false;
+        } else if (!resource.equals(other.resource))
+            return false;
+        return true;
     }
 
     @Override
index 61e44dda4b424e7dd8c63a12af07da81962ce3ca..5a2a17f6cf45b18604ce305d2e11fba276b18e33 100644 (file)
@@ -11,9 +11,6 @@ package org.opendaylight.controller.sal.authorization;
 
 import java.io.Serializable;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
 /**
  * Represents a group of resources along with the privilege associated to it
  *
@@ -48,12 +45,32 @@ public class ResourceGroup implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result
+                + ((groupName == null) ? 0 : groupName.hashCode());
+        result = prime * result
+                + ((privilege == null) ? 0 : privilege.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;
+        ResourceGroup other = (ResourceGroup) obj;
+        if (groupName == null) {
+            if (other.groupName != null)
+                return false;
+        } else if (!groupName.equals(other.groupName))
+            return false;
+        if (privilege != other.privilege)
+            return false;
+        return true;
     }
 
     @Override
index 6fb38a3a90279a898786e5c1ed1f088ad6cd5488..3f81d0c4c5524150bf386158e8d22921f57249f6 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   Actions.java
  *
@@ -83,12 +80,24 @@ public class Actions extends Property {
     
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + actionsValue;
+        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;
+        Actions other = (Actions) obj;
+        if (actionsValue != other.actionsValue)
+            return false;
+        return true;
     }
 
     @Override
index 32f661ca5ff29a7a14d284068692d45d83638e46..fa5cc10827d5847140dd21ec72b24138b23b901f 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   BandWidth.java
  *
@@ -84,12 +81,25 @@ public class Bandwidth extends Property {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result
+                + (int) (bandwidthValue ^ (bandwidthValue >>> 32));
+        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;
+        Bandwidth other = (Bandwidth) obj;
+        if (bandwidthValue != other.bandwidthValue)
+            return false;
+        return true;
     }
 
     @Override
index 91f647d45b2b1c7588355bd2880d7e58f4ce7330..991ed688f2eda4d630d63f15b965983ca07acc97 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   Buffers.java
  *
@@ -59,12 +56,24 @@ public class Buffers extends Property {
     
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + buffersValue;
+        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;
+        Buffers other = (Buffers) obj;
+        if (buffersValue != other.buffersValue)
+            return false;
+        return true;
     }
 
     @Override
index d4c8cd1b56e71fd92a428db7a290f99dea1d5c00..a41a0e22904482050bbcfe95c4338c2acb0dc520 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   Capabilities.java
  *
@@ -76,12 +73,24 @@ public class Capabilities extends Property {
     
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + capabilitiesValue;
+        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;
+        Capabilities other = (Capabilities) obj;
+        if (capabilitiesValue != other.capabilitiesValue)
+            return false;
+        return true;
     }
 
     @Override
index f8a48997f827e06a5e554344d8b3339e17b444c6..c547c2bb455bd89f9d26b0c1483d9d6b3d8cc8d2 100644 (file)
@@ -11,9 +11,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 Admin Config status
  * 
@@ -53,12 +50,24 @@ public class Config extends Property {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + configValue;
+        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;
+        Config other = (Config) obj;
+        if (configValue != other.configValue)
+            return false;
+        return true;
     }
 
     @Override
index acb3e19f69da6a88a2b8f1a0cda1d2f258b7c70a..2a80bd608823e2bf0a0ee329379a9578127af000 100644 (file)
@@ -11,8 +11,6 @@ package org.opendaylight.controller.sal.core;
 
 import java.io.Serializable;
 
-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.SetDlType;
 import org.opendaylight.controller.sal.action.SetNwDst;
@@ -48,12 +46,27 @@ public class ContainerFlow implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((match == null) ? 0 : match.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;
+        ContainerFlow other = (ContainerFlow) obj;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        return true;
     }
 
     @Override
index 4233dcbb683b0db55ab9170aefa6561152e7820b..4138aa6c34068038c72ae97e9f8f5658a6b1211b 100644 (file)
@@ -3,9 +3,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.
  */
@@ -39,12 +36,28 @@ public class Description extends Property {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result
+                + ((description == null) ? 0 : description.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;
+        Description other = (Description) obj;
+        if (description == null) {
+            if (other.description != null)
+                return false;
+        } else if (!description.equals(other.description))
+            return false;
+        return true;
     }
 
     @Override
index 162a4d4232eef7e06b4b9162faab1cc1140b54aa..c119eb79f554fc47f34f05fba02bdd17591fede5 100644 (file)
 package org.opendaylight.controller.sal.core;
 
 import java.io.Serializable;
-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;
 
 /**
  *
@@ -126,12 +124,39 @@ public class Edge implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime
+                * result
+                + ((headNodeConnector == null) ? 0 : headNodeConnector
+                        .hashCode());
+        result = prime
+                * result
+                + ((tailNodeConnector == null) ? 0 : tailNodeConnector
+                        .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;
+        Edge other = (Edge) obj;
+        if (headNodeConnector == null) {
+            if (other.headNodeConnector != null)
+                return false;
+        } else if (!headNodeConnector.equals(other.headNodeConnector))
+            return false;
+        if (tailNodeConnector == null) {
+            if (other.tailNodeConnector != null)
+                return false;
+        } else if (!tailNodeConnector.equals(other.tailNodeConnector))
+            return false;
+        return true;
     }
 
     @Override
index f5490860d652cec6e171bc32d99f7228f2569bcc..50036372afc041f106009834e676e7ab5f7037d5 100644 (file)
@@ -17,9 +17,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.HashCodeBuilder;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 import org.opendaylight.controller.sal.packet.address.DataLinkAddress;
 
 @XmlRootElement(name="host")
@@ -93,16 +90,41 @@ public class Host implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime
+                * result
+                + ((dataLayerAddress == null) ? 0 : dataLayerAddress.hashCode());
+        result = prime * result
+                + ((networkAddress == null) ? 0 : networkAddress.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;
+        Host other = (Host) obj;
+        if (dataLayerAddress == null) {
+            if (other.dataLayerAddress != null)
+                return false;
+        } else if (!dataLayerAddress.equals(other.dataLayerAddress))
+            return false;
+        if (networkAddress == null) {
+            if (other.networkAddress != null)
+                return false;
+        } else if (!networkAddress.equals(other.networkAddress))
+            return false;
+        return true;
     }
 
     @Override
     public String toString() {
-        return "Host[" + ReflectionToStringBuilder.toString(this) + "]";
+        return "Host [dataLayerAddress=" + dataLayerAddress
+                + ", networkAddress=" + networkAddress + "]";
     }
 }
index 395863591437d2bec527cd3144724abf5593f646..61e3872669b67f6a01f955bf2d15780635e0c84a 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   Latency.java
  *
@@ -71,12 +68,24 @@ public class Latency extends Property {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + (int) (latency ^ (latency >>> 32));
+        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;
+        Latency other = (Latency) obj;
+        if (latency != other.latency)
+            return false;
+        return true;
     }
 
     @Override
index 75d6ee5d7d5ffb1898cb950d37af25203d2e0e04..267e35ab605fc469a3785655956c0edcdf35407a 100644 (file)
@@ -116,4 +116,17 @@ public class YangToSourcesPluginTest {
         verifyCorrectLog(v);
     }
 
+    @Test
+    public void testFindResourceOnCp() throws VerificationException {
+        Verifier v1 = new Verifier(new File("src/test/resources/GenerateTest1/").getAbsolutePath());
+        v1.executeGoal("package");
+        v1.assertFilePresent("target/external-resources/testfile1.yang");
+        v1.assertFilePresent("target/external-resources/testfile2.yang");
+        v1.assertFilePresent("target/external-resources/testfile3.yang");
+
+        Verifier v2 = YangToSourcesPluginTest.setUp("GenerateTest2/",
+                false);
+        v2.executeGoal("package");
+    }
+
 }
diff --git a/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest1/pom.xml b/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest1/pom.xml
new file mode 100644 (file)
index 0000000..df21358
--- /dev/null
@@ -0,0 +1,51 @@
+<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>generator-test1</artifactId>
+       <version>0.5-SNAPSHOT</version>
+
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.opendaylight.controller</groupId>
+                               <artifactId>yang-maven-plugin</artifactId>
+                               <version>0.5-SNAPSHOT</version>
+                               <executions>
+                                       <execution>
+                                               <goals>
+                                                       <goal>generate-sources</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <yangFilesRootDir>src/main/resources</yangFilesRootDir>
+                                                       <codeGenerators>
+                                                               <generator>
+                                                                       <codeGeneratorClass>
+                                                                               org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl
+                                                                       </codeGeneratorClass>
+                                                               </generator>
+                                                       </codeGenerators>
+                                                       <resourceProviders>
+                                                               <provider>
+                                                                       <resourceProviderClass>
+                                                                               org.opendaylight.controller.yang2sources.spi.ResourceProviderTestImpl
+                                                                       </resourceProviderClass>
+                                                               </provider>
+                                                       </resourceProviders>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+
+                               <dependencies>
+                                       <dependency>
+                                               <groupId>org.opendaylight.controller</groupId>
+                                               <artifactId>yang-maven-plugin-spi</artifactId>
+                                               <version>0.5-SNAPSHOT</version>
+                                               <type>test-jar</type>
+                                       </dependency>
+                               </dependencies>
+                       </plugin>
+               </plugins>
+       </build>
+</project>
diff --git a/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest1/src/main/resources/testfile1.yang b/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest1/src/main/resources/testfile1.yang
new file mode 100644 (file)
index 0000000..2f43553
--- /dev/null
@@ -0,0 +1,118 @@
+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";
+    }
+
+    leaf testleaf {
+        type data:my-type1 {
+            range "min..max";
+        }
+    }
+
+    leaf test-string-leaf {
+        type data:my-string-type-ext;
+    }
+
+    leaf leaf-with-length {
+       type data:my-string-type {
+               length "7..max";
+       }
+    }
+
+    leaf test-int-leaf {
+        type data:my-int-type-ext;
+    }
+
+    leaf test-decimal-leaf {
+        type data:my-decimal-type {
+            fraction-digits 4;
+        }
+    }
+
+    leaf test-decimal-leaf2 {
+        type data:my-decimal-type-ext;
+    }
+
+    container ext {
+        data:c-define "MY_INTERFACES";
+    }
+
+    leaf union-leaf {
+       type data:my-union-ext;
+    }
+
+    deviation /data:system/data:user {
+        deviate add {
+            default "admin"; // new users are 'admin' by default
+            config "true";
+        }
+    }
+
+    leaf nested-union-leaf {
+       type data:nested-union1;
+    }
+
+    leaf custom-union-leaf {
+        type t3:union1;
+    }
+
+    container transfer {
+        choice how {
+            default interval;
+            case interval {
+                leaf interval {
+                    type uint16;
+                    default 30;
+                    units minutes;
+                }
+            }
+            case daily {
+                leaf daily {
+                    type empty;
+                }
+                leaf time-of-day {
+                    type string;
+                    units 24-hour-clock;
+                    default 1am;
+                }
+            }
+            case manual {
+                leaf manual {
+                    type empty;
+                }
+            }
+        }
+    }
+
+    anyxml data {
+        description
+          "Copy of the source datastore subset that matched
+           the filter criteria (if any).  An empty data container
+           indicates that the request did not produce any results.";
+    }
+
+    augment "/data:interfaces/data:ifEntry/t3:augment-holder" {
+        when "if:ifType='ds0'";
+        leaf ds0ChannelNumber {
+            type string;
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest1/src/main/resources/testfile2.yang b/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest1/src/main/resources/testfile2.yang
new file mode 100644 (file)
index 0000000..1a7b45e
--- /dev/null
@@ -0,0 +1,179 @@
+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";
+    }
+    
+    typedef my-base-int32-type {
+        type int32 {
+            range "2..20";
+        }
+    }
+
+    typedef my-type1 {
+        type my-base-int32-type {
+            range "11..max";
+        }
+        units "mile";
+        default "11";
+    }
+    
+    typedef my-custom-string {
+        type string {
+            pattern "[a-k]*";
+            length "5..11";
+        }
+    }
+    
+    typedef my-string-type {
+        type my-custom-string {
+            length "5..10";
+        }
+    }
+    
+    typedef my-string-type2 {
+        type my-string-type {
+            pattern "[b-u]*";
+        }
+    }
+
+    typedef my-string-type-ext {
+        type my-string-type2 {
+            pattern "[e-z]*";
+        }
+    }
+
+    typedef my-int-type {
+        type int32 {
+            range "10..20";
+        }
+    }
+    
+    typedef my-int-type2 {
+        type my-int-type {
+            range "12..18";
+        }
+    }
+    
+    typedef my-int-type-ext {
+        type my-int-type2 {
+            range "14..16";
+        }
+    }
+    
+    typedef my-decimal-type {
+        type decimal64 {
+            fraction-digits 6;
+        }
+    }
+    
+    typedef my-decimal-type-ext {
+        type decimal64 {
+            fraction-digits 5;
+        }
+    }
+
+    typedef my-union {
+       type union {
+               type int16 {
+                       range "1..100";
+               }
+               type int32;
+       }
+    }
+
+    typedef my-union-ext {
+       type my-union;
+    }
+
+    typedef nested-union1 {
+       type nested-union2;
+    }
+
+    typedef nested-union2 {
+       type union {
+               type my-union-ext;
+               type string;
+       }
+    }
+
+    leaf if-name {
+        type leafref {
+            path "/interface/name";
+        }
+    }
+     
+    leaf name {
+        type string;
+    }
+     
+    leaf nested-type-leaf {
+        type my-type1;
+    }
+    
+    extension c-define {
+        description
+        "Takes as argument a name string.
+        Makes the code generator use the given name in the
+        #define.";
+        argument "name" {
+            yin-element "true";
+        }
+    }
+    
+    container system {
+        leaf user {
+            type string;
+        }
+    }
+    
+    grouping target {
+        leaf address {
+            type string;
+            description "Target IP address";
+        }
+        container port {
+            description "Target port container";
+        }
+    }
+
+    container peer {
+        container destination {
+            uses target {
+                refine address {
+                    default "1.2.3.4";
+                }
+                refine port {
+                    must "must-condition" {
+                        error-message "An error message test";
+                        error-app-tag "An error app tag test";
+                    }
+                }
+            }
+        }
+    }
+    
+    container interfaces {
+         list ifEntry {
+             key "ifIndex";
+
+             leaf ifIndex {
+                 type uint32;
+                 units minutes;
+             }
+             
+             leaf ifMtu {
+                 type int32;
+             }
+         }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest1/src/main/resources/testfile3.yang b/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest1/src/main/resources/testfile3.yang
new file mode 100644 (file)
index 0000000..b203124
--- /dev/null
@@ -0,0 +1,141 @@
+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";
+    }
+
+    typedef union1 {
+        type union2;
+    }
+
+    typedef union2 {
+        type union {
+            type int32;
+            type data:nested-union2;
+        }
+    }
+
+    augment "/data:interfaces/data:ifEntry" {
+        when "if:ifType='ds0'";
+        container augment-holder {
+            description "Description for augment holder";
+        }
+    }
+    
+    augment "/data:interfaces/data:ifEntry" {
+        when "if:ifType='ds2'";
+        container augment-holder2 {
+            description "Description for augment holder";
+        }
+    }
+
+    container network {
+        mnt:mountpoint point {
+               mnt:target-ref target;
+        }
+        
+           description "network-description";
+           reference "network-reference";
+           status obsolete;
+           config true;
+           presence "some presence text";
+    }
+
+    feature local-storage {
+        description
+            "This feature means the device supports local
+             storage (memory, flash or disk) that can be used to
+             store syslog messages.";
+    }
+    
+    extension c-define {
+        description
+            "Takes as argument a name string.
+             Makes the code generator use the given name in the
+             #define.";
+        argument "name";
+    }
+    
+    notification event {
+        leaf event-class {
+            type string;
+        }
+        anyxml reporting-entity;
+        leaf severity {
+            type string;
+        }
+    }
+    
+    rpc get-config {
+        description
+          "Retrieve all or part of a specified configuration.";
+
+        reference "RFC 6241, Section 7.1";
+
+        input {
+            container source {
+                description
+                  "Particular configuration to retrieve.";
+
+                choice config-source {
+                    mandatory true;
+                    description
+                      "The configuration to retrieve.";
+                    case a {
+                        leaf candidate {
+                            if-feature candidate;
+                            type empty;
+                            description
+                              "The candidate configuration is the config source.";
+                        }
+                    }
+                    case b {
+                        leaf running {
+                            type empty;
+                            description
+                              "The running configuration is the config source.";
+                        }
+                    }
+                    case c {
+                        leaf startup {
+                            if-feature startup;
+                            type empty;
+                            description
+                              "The startup configuration is the config source.
+                               This is optional-to-implement on the server because
+                               not all servers will support filtering for this
+                               datastore.";
+                        }
+                    }
+                }
+            }
+
+            anyxml filter {
+                description
+                  "Subtree or XPath filter to use.";
+                   nc:get-filter-element-attributes;
+            }
+        }
+
+        output {
+            anyxml data {
+                description
+                  "Copy of the source datastore subset that matched
+                   the filter criteria (if any).  An empty data container
+                   indicates that the request did not produce any results.";
+            }
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest2/pom.xml b/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/src/test/resources/GenerateTest2/pom.xml
new file mode 100644 (file)
index 0000000..7948efc
--- /dev/null
@@ -0,0 +1,67 @@
+<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>generator-test2</artifactId>
+       <version>0.5-SNAPSHOT</version>
+
+       <dependencies>
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>generator-test1</artifactId>
+                       <version>0.5-SNAPSHOT</version>
+                       <scope>system</scope>
+                       <systemPath>${project.basedir}/../GenerateTest1/target/generator-test1-0.5-SNAPSHOT.jar</systemPath>
+               </dependency>
+       </dependencies>
+
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.opendaylight.controller</groupId>
+                               <artifactId>yang-maven-plugin</artifactId>
+                               <version>0.5-SNAPSHOT</version>
+                               <executions>
+                                       <execution>
+                                               <goals>
+                                                       <goal>generate-sources</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <yangFilesRootDir>${project.basedir}</yangFilesRootDir>
+                                                       <codeGenerators>
+                                                               <generator>
+                                                                       <codeGeneratorClass>
+                                                                               org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl
+                                                                       </codeGeneratorClass>
+                                                                       <outputBaseDir>
+                                                                               outDir/
+                                                                       </outputBaseDir>
+                                                               </generator>
+                                                       </codeGenerators>
+                                                       <resourceProviders>
+                                                               <provider>
+                                                                       <resourceProviderClass>
+                                                                               org.opendaylight.controller.yang2sources.spi.ResourceProviderTestImpl
+                                                                       </resourceProviderClass>
+                                                                       <outputBaseDir>
+                                                                               outDir/
+                                                                       </outputBaseDir>
+                                                               </provider>
+                                                       </resourceProviders>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+
+                               <dependencies>
+                                       <dependency>
+                                               <groupId>org.opendaylight.controller</groupId>
+                                               <artifactId>yang-maven-plugin-spi</artifactId>
+                                               <version>0.5-SNAPSHOT</version>
+                                               <type>test-jar</type>
+                                       </dependency>
+                               </dependencies>
+                       </plugin>
+               </plugins>
+       </build>
+</project>
index 5676530afec2eaecedab1469608654abb3ebc675..9737b45e3231e4e002f173fa29d98e389690e6f8 100644 (file)
@@ -51,7 +51,7 @@ final class Util {
 
         File file = new File(rootDir);
         if(!file.exists()) {
-            throw new FileNotFoundException();
+            throw new FileNotFoundException(rootDir);
         }
 
         Collection<File> yangFiles = FileUtils.listFiles(new File(rootDir),
index 262198571674611c352660c78636119dd5012f34..f5ac8f904c2475ff569d162496eb00b5ff4cdb8b 100644 (file)
@@ -45,6 +45,7 @@ import org.opendaylight.controller.yang2sources.spi.ResourceGenerator;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
+import com.google.common.io.Files;
 
 /**
  * Generate sources from yang files using user provided set of
@@ -62,7 +63,7 @@ import com.google.common.collect.Maps;
 @Mojo(name = "generate-sources", defaultPhase = LifecyclePhase.GENERATE_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true)
 public final class YangToSourcesMojo extends AbstractMojo {
     private static final String LOG_PREFIX = "yang-to-sources:";
-    private static final String INPUT_RESOURCE_DIR = "META-INF/yangs/";
+    private static final String INPUT_RESOURCE_DIR = "META-INF/yang/";
     private static final String OUTPUT_RESOURCE_DIR = "/target/external-resources/";
 
     /**
@@ -131,8 +132,9 @@ public final class YangToSourcesMojo extends AbstractMojo {
 
             if (yangFiles.isEmpty()) {
                 getLog().warn(
-                        Util.message("No %s file found in %s", LOG_PREFIX,
-                                Util.YANG_SUFFIX, yangFilesRootDir));
+                        Util.message(
+                                "No %s file found in %s or in dependencies",
+                                LOG_PREFIX, Util.YANG_SUFFIX, yangFilesRootDir));
                 return null;
             }
 
@@ -178,8 +180,8 @@ public final class YangToSourcesMojo extends AbstractMojo {
         yangFiles.addAll(getFilesFromYangRoot());
 
         // load files from dependencies
-        yangFiles.addAll(getFilesFromDependencies());
-
+        Collection<File> filesFromDependencies = getFilesFromDependencies();
+        yangFiles.addAll(filesFromDependencies);
 
         for (ResourceProviderArg resourceProvider : resourceProviders) {
             try {
@@ -211,25 +213,31 @@ public final class YangToSourcesMojo extends AbstractMojo {
 
         File rootDir = new File(yangFilesRootDir);
         try {
-            if(!rootDir.isAbsolute()) {
-                yangFilesLoaded = Util.listFiles(project.getBasedir().getAbsolutePath() + yangFilesRootDir);
-            } else {
+            if (rootDir.isAbsolute()) {
                 yangFilesLoaded = Util.listFiles(yangFilesRootDir);
+            } else {
+                String path = project.getBasedir().getAbsolutePath()
+                        + File.separator + yangFilesRootDir;
+                yangFilesLoaded = Util.listFiles(path);
             }
-
-        } catch(FileNotFoundException e) {
-            getLog().warn("Directory '" + yangFilesRootDir + "' does not exists.");
+        } catch (FileNotFoundException e) {
+            getLog().warn(
+                    "yangFilesRootDir[" + rootDir.getAbsolutePath()
+                            + "] does not exists.");
             yangFilesLoaded = new ArrayList<File>();
         }
+
         Collection<File> yangFiles = new ArrayList<File>(yangFilesLoaded);
 
         try {
-            for(File yangFile : yangFilesLoaded) {
+            for (File yangFile : yangFilesLoaded) {
                 InputStream is = new FileInputStream(yangFile);
-                yangFiles.add(createFileFromStream(is, project.getBasedir().getAbsolutePath() + OUTPUT_RESOURCE_DIR + yangFile.getName()));
+                yangFiles.add(createFileFromStream(is,
+                        project.getBasedir().getAbsolutePath()
+                                + OUTPUT_RESOURCE_DIR + yangFile.getName()));
                 resources.add(is);
             }
-        } catch(IOException e) {
+        } catch (IOException e) {
             getLog().warn("Exception while loading yang files.", e);
         }
         return yangFiles;
@@ -256,8 +264,11 @@ public final class YangToSourcesMojo extends AbstractMojo {
                             continue;
                         }
                         InputStream entryStream = zip.getInputStream(entry);
-                        String newEntryName = entryName.substring(INPUT_RESOURCE_DIR.length());
-                        File f = createFileFromStream(entryStream, project.getBasedir().getAbsolutePath() + OUTPUT_RESOURCE_DIR + newEntryName);
+                        String newEntryName = entryName
+                                .substring(INPUT_RESOURCE_DIR.length());
+                        File tmp = Files.createTempDir();
+                        File f = createFileFromStream(entryStream,
+                                tmp.getAbsolutePath() + newEntryName);
                         yangFiles.add(f);
 
                         resources.add(entryStream);
@@ -272,9 +283,10 @@ public final class YangToSourcesMojo extends AbstractMojo {
         return yangFiles;
     }
 
-    private File createFileFromStream(InputStream is, String absoluteName) throws IOException {
+    private File createFileFromStream(InputStream is, String absoluteName)
+            throws IOException {
         File f = new File(absoluteName);
-        if(!f.exists()) {
+        if (!f.exists()) {
             f.getParentFile().mkdirs();
         }
         f.createNewFile();
@@ -392,8 +404,8 @@ public final class YangToSourcesMojo extends AbstractMojo {
                     ZipEntry entry = entries.nextElement();
                     String entryName = entry.getName();
 
-                    if(entryName.startsWith(INPUT_RESOURCE_DIR)) {
-                        if(entry.isDirectory()) {
+                    if (entryName.startsWith(INPUT_RESOURCE_DIR)) {
+                        if (entry.isDirectory()) {
                             continue;
                         }
                         if (!Util.acceptedFilter(entryName, filter)) {
@@ -422,7 +434,7 @@ public final class YangToSourcesMojo extends AbstractMojo {
             try {
                 resource.close();
             } catch (IOException e) {
-                getLog().warn("Failed to close resources: "+ resource, e);
+                getLog().warn("Failed to close resources: " + resource, e);
             }
         }
     }
index fd9a3aabc84cc5d10b7d1d41cca9a4b5787de809..a184e23e1b84f6dea74e814801aea5660a1a7d0a 100644 (file)
@@ -33,10 +33,14 @@ import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder
  */
 public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
         TypeDefinitionBuilder, Builder {
+    private final static String CLASS_NAME = UnionTypeBuilder.class
+            .getSimpleName();
+
     private final int line;
     private final List<TypeDefinition<?>> types;
     private final List<TypeDefinitionBuilder> typedefs;
     private final UnionType instance;
+    private boolean built;
 
     private final List<String> actualPath;
     private final URI namespace;
@@ -89,40 +93,43 @@ public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public UnionType build() {
-        for (TypeDefinitionBuilder tdb : typedefs) {
-            types.add(tdb.build());
+        if (built) {
+            return instance;
+        } else {
+            for (TypeDefinitionBuilder tdb : typedefs) {
+                types.add(tdb.build());
+            }
+            built = true;
+            return instance;
         }
-        return instance;
     }
 
     @Override
     public void setPath(final SchemaPath schemaPath) {
-        throw new IllegalStateException("Can not set path to "
-                + UnionTypeBuilder.class.getSimpleName());
+        throw new IllegalStateException("Can not set path to " + CLASS_NAME);
     }
 
     @Override
     public void setDescription(final String description) {
         throw new IllegalStateException("Can not set description to "
-                + UnionTypeBuilder.class.getSimpleName());
+                + CLASS_NAME);
     }
 
     @Override
     public void setReference(final String reference) {
         throw new IllegalStateException("Can not set reference to "
-                + UnionTypeBuilder.class.getSimpleName());
+                + CLASS_NAME);
     }
 
     @Override
     public void setStatus(final Status status) {
-        throw new IllegalStateException("Can not set status to "
-                + UnionTypeBuilder.class.getSimpleName());
+        throw new IllegalStateException("Can not set status to " + CLASS_NAME);
     }
 
     @Override
     public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
         throw new IllegalStateException("Can not add unknown node to "
-                + UnionTypeBuilder.class.getSimpleName());
+                + CLASS_NAME);
     }
 
     @Override
index 42b348a1bbbf02de70da6c68901bd5d6b016767c..7c2aa6692b8df09ec97a9e70f92a65726613e1b4 100644 (file)
@@ -19,6 +19,8 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
@@ -122,7 +124,7 @@ public class YangParserImpl implements YangModelParser {
 
     private Map<String, TreeMap<Date, ModuleBuilder>> resolveModuleBuilders(
             final List<InputStream> yangFileStreams) {
-        final Map<String, TreeMap<Date, ModuleBuilder>> modules = new HashMap<String, TreeMap<Date, ModuleBuilder>>();
+        final Map<String, TreeMap<Date, ModuleBuilder>> modules = new LinkedHashMap<String, TreeMap<Date, ModuleBuilder>>();
         final ParseTreeWalker walker = new ParseTreeWalker();
         final List<ParseTree> trees = parseStreams(yangFileStreams);
         final ModuleBuilder[] builders = new ModuleBuilder[trees.size()];
@@ -140,7 +142,22 @@ public class YangParserImpl implements YangModelParser {
         // module dependency graph sorted
         List<ModuleSimple> sorted = new ModuleDependencySort(builders).sort();
 
-        for (ModuleBuilder builder : builders) {
+        // TODO FIX THIS ASAP!
+        // FIXME this is just temp workaround the ModuleDependencySort MUST
+        // RETURN ordered List
+        // of SORTED and DEPENDECNY RESOLVED MODULE BUILDERS!!!!!!
+        final List<ModuleBuilder> orderedBuilders = new ArrayList<ModuleBuilder>();
+        for (final ModuleSimple ms : sorted) {
+            for (int i = 0; i < builders.length; ++i) {
+                if (ms.getName().equals(builders[i].getName())
+                        && ms.getRevision().equals(builders[i].getRevision())) {
+                    orderedBuilders.add(builders[i]);
+                }
+            }
+        }
+        // FIXME END OF WORKAROUND
+
+        for (ModuleBuilder builder : orderedBuilders) {
             final String builderName = builder.getName();
             Date builderRevision = builder.getRevision();
             if (builderRevision == null) {
@@ -193,7 +210,7 @@ public class YangParserImpl implements YangModelParser {
         resolveAugments(modules);
 
         // build
-        final Set<Module> result = new HashSet<Module>();
+        final Set<Module> result = new LinkedHashSet<Module>();
         for (Map.Entry<String, TreeMap<Date, ModuleBuilder>> entry : modules
                 .entrySet()) {
             final Map<Date, Module> modulesByRevision = new HashMap<Date, Module>();
@@ -485,7 +502,7 @@ public class YangParserImpl implements YangModelParser {
         List<PatternConstraint> patterns = Collections.emptyList();
         Integer fractionDigits = null;
         if (referencedType == null) {
-            final TypeDefinitionBuilder tdb = (TypeDefinitionBuilder) nodeToResolve;
+            final TypeDefinitionBuilder tdb = nodeToResolve.getTypedef();
             ranges = tdb.getRanges();
             constraints.addRanges(ranges);
             lengths = tdb.getLengths();
@@ -657,7 +674,7 @@ public class YangParserImpl implements YangModelParser {
             for (AugmentationSchemaBuilder augmentBuilder : module
                     .getAddedAugments()) {
 
-                if(!augmentBuilder.isResolved()) {
+                if (!augmentBuilder.isResolved()) {
                     final SchemaPath augmentTargetSchemaPath = augmentBuilder
                             .getTargetPath();
                     final List<QName> path = augmentTargetSchemaPath.getPath();
@@ -675,7 +692,8 @@ public class YangParserImpl implements YangModelParser {
                     for (DataSchemaNodeBuilder child : dependentModule
                             .getChildNodes()) {
                         final QName childQName = child.getQName();
-                        if (childQName.getLocalName().equals(qname.getLocalName())) {
+                        if (childQName.getLocalName().equals(
+                                qname.getLocalName())) {
                             currentParent = child;
                             i++;
                             break;
@@ -702,7 +720,8 @@ public class YangParserImpl implements YangModelParser {
                     }
 
                     final QName currentQName = currentParent.getQName();
-                    final QName lastAugmentPathElement = path.get(path.size() - 1);
+                    final QName lastAugmentPathElement = path
+                            .get(path.size() - 1);
                     if (currentQName.getLocalName().equals(
                             lastAugmentPathElement.getLocalName())) {
                         ParserUtils.fillAugmentTarget(augmentBuilder,
@@ -710,13 +729,13 @@ public class YangParserImpl implements YangModelParser {
                         ((AugmentationTargetBuilder) currentParent)
                                 .addAugmentation(augmentBuilder);
                         SchemaPath oldPath = currentParent.getPath();
-                        augmentBuilder.setTargetPath(new SchemaPath(oldPath.getPath(), oldPath.isAbsolute()));
+                        augmentBuilder.setTargetPath(new SchemaPath(oldPath
+                                .getPath(), oldPath.isAbsolute()));
                         augmentBuilder.setResolved(true);
                         module.augmentResolved();
                     }
                 }
 
-
             }
         }
     }
@@ -1130,9 +1149,13 @@ public class YangParserImpl implements YangModelParser {
 
         @Override
         public Module findModuleByName(final String name, final Date revision) {
-            if ((name != null) && (revision != null)) {
+            if (name != null) {
                 for (final Module module : modules) {
-                    if (module.getName().equals(name)
+                    if (revision == null) {
+                        if (module.getName().equals(name)) {
+                            return module;
+                        }
+                    } else if (module.getName().equals(name)
                             && module.getRevision().equals(revision)) {
                         return module;
                     }