From: Tony Tkacik Date: Tue, 17 Sep 2013 13:51:55 +0000 (+0000) Subject: Merge "Added RoutingContext annotation, updated InstanceIdentifier" X-Git-Tag: release/beryllium~781 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=c66116cd352ed63c0f91aa73931863ffb4d8672f;hp=0947441809228da0e71c6dd657f6046a8de10d4a;p=mdsal.git Merge "Added RoutingContext annotation, updated InstanceIdentifier" --- diff --git a/yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java b/yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java index ed90626f29..dc9a8008bf 100644 --- a/yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java +++ b/yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java @@ -1,77 +1,110 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.binding; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Uniquely identifies instance of data tree. - * - * - */ -public class InstanceIdentifier { - - private final List path; - private final Class targetType; - - public InstanceIdentifier(Class type) { - path = Collections.emptyList(); - this.targetType = type; - } - - public InstanceIdentifier(List path, Class type) { - this.path = Collections. unmodifiableList(new ArrayList<>(path)); - this.targetType = type; - } - - /** - * - * @return - */ - public List getPath() { - return this.path; - } - - public Class getTargetType() { - return this.targetType; - } - - /** - * Path argument of instance identifier. - * - * Interface which implementations are used as path components of the - * instance path. - * - * @author ttkacik - * - */ - interface PathArgument { - - } - - public static class IdentifiableItem, T extends Identifier> implements PathArgument { - - private final T key; - private final Class type; - - public IdentifiableItem(Class type, T key) { - this.type = type; - this.key = key; - } - - T getKey() { - return this.key; - } - - Class getType() { - return this.type; - } - } -} +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.yangtools.yang.binding; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Uniquely identifies instance of data tree. + * + * + */ +public class InstanceIdentifier { + + private final List path; + private final Class targetType; + + public InstanceIdentifier(Class type) { + path = Collections.emptyList(); + this.targetType = type; + } + + public InstanceIdentifier(List path, Class type) { + this.path = Collections. unmodifiableList(new ArrayList<>(path)); + this.targetType = type; + } + + /** + * + * @return + */ + public List getPath() { + return this.path; + } + + public Class getTargetType() { + return this.targetType; + } + + + + + @Override + public String toString() { + return "InstanceIdentifier [path=" + path + "]"; + } + + /** + * Path argument of instance identifier. + * + * Interface which implementations are used as path components of the + * instance path. + * + * @author ttkacik + * + */ + public interface PathArgument { + + } + + public static class IdentifiableItem, T extends Identifier> implements PathArgument { + + private final T key; + private final Class type; + + public IdentifiableItem(Class type, T key) { + this.type = type; + this.key = key; + } + + T getKey() { + return this.key; + } + + Class getType() { + return this.type; + } + + @Override + public boolean equals(Object obj) { + if(obj == null) { + return false; + } + if(obj.hashCode() != hashCode()) { + return false; + } + if(!(obj instanceof IdentifiableItem)) { + return false; + } + IdentifiableItem foreign = (IdentifiableItem) obj; + return key.equals(foreign.getKey()); + } + + @Override + public int hashCode() { + return key.hashCode(); + } + + @Override + public String toString() { + return "IdentifiableItem [key=" + key + "]"; + } + } +} diff --git a/yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/annotations/RoutingContext.java b/yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/annotations/RoutingContext.java new file mode 100644 index 0000000000..5a3af9bceb --- /dev/null +++ b/yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/annotations/RoutingContext.java @@ -0,0 +1,11 @@ +package org.opendaylight.yangtools.yang.binding.annotations; + +import java.lang.annotation.Inherited; + +import org.opendaylight.yangtools.yang.binding.BaseIdentity; + +@Inherited +public @interface RoutingContext { + + Class value(); +}