*/
package org.opendaylight.yangtools.yang.binding;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.opendaylight.yangtools.concepts.Builder;
-import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.concepts.Path;
-
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.concepts.Immutable;
+import org.opendaylight.yangtools.concepts.Path;
/**
*
* Interface which implementations are used as path components of the
* path in overall data tree.
*/
- public interface PathArgument {
+ public interface PathArgument extends Comparable<PathArgument> {
Class<? extends DataObject> getType();
}
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((type == null) ? 0 : type.hashCode());
- return result;
+ return type.hashCode();
}
@Override
return false;
}
final AbstractPathArgument<?> other = (AbstractPathArgument<?>) obj;
- if (type == null) {
- if (other.type != null) {
- return false;
- }
- } else if (!type.equals(other.type)) {
- return false;
- }
- return true;
+ return type.equals(other.type);
+ }
+
+ @Override
+ public int compareTo(PathArgument arg) {
+ return type.getCanonicalName().compareTo(arg.getType().getCanonicalName());
}
}
@Override
public boolean equals(final Object obj) {
- return super.equals(obj) && obj.hashCode() == hashCode() && key.equals(((IdentifiableItem<?, ?>) obj).getKey());
+ return super.equals(obj) && key.equals(((IdentifiableItem<?, ?>) obj).getKey());
}
@Override
public int hashCode() {
- return key.hashCode();
+ return super.hashCode() * 31 + key.hashCode();
}
@Override