1 package org.opendaylight.controller.md.sal.dom.xsql;
3 import java.io.Serializable;
4 import java.util.LinkedList;
9 public class XSQLBluePrintRelation implements Serializable {
10 private static final long serialVersionUID = 2L;
11 private XSQLBluePrintNode parent = null;
12 private String property = null;
13 private Class<?> childClass = null;
15 public XSQLBluePrintRelation(XSQLBluePrintNode _parent, String _property,
16 Class<?> _childClass) {
17 this.parent = _parent;
18 this.property = _property;
19 this.childClass = _childClass;
22 public Class<?> getNEClosestClass() {
23 Class<?> p = parent.getInterface();
24 return getNEClosestClass(p);
28 public static Class<?> getNEClosestClass(Class<?> p) {
29 while (!p.getInterfaces()[0]
30 .equals(Object.class/*XSQLBluePrint.STOP_INTERFACE*/)) {
31 p = p.getInterfaces()[0];
36 public XSQLBluePrintNode getParent() {
40 public String getProperty() {
44 public Class<?> getChildClass() {
45 return this.childClass;
48 public boolean equals(Object obj) {
49 XSQLBluePrintRelation other = (XSQLBluePrintRelation) obj;
50 if (other.parent != null && this.parent == null) {
53 if (other.parent == null && this.parent != null) {
57 if (other.parent == null && this.parent == null) {
58 return property.equals(other.property);
61 if (other.parent.toString().equals(this.parent.toString())) {
62 return property.equals(other.property);
68 public int hashCode() {
70 return parent.toString().hashCode() + property.hashCode();
72 return property.hashCode();
75 public String toString() {
77 return parent.toString() + ":" + property;
83 public List execute(Object o) {
84 List result = new LinkedList();
89 if (Set.class.isAssignableFrom(o.getClass())) {
91 for (Object oo : lst) {
92 addToResult(result, execute(oo));
95 } else if (List.class.isAssignableFrom(o.getClass())) {
97 for (Object oo : lst) {
98 addToResult(result, execute(oo));
101 } else if (Map.class.isAssignableFrom(o.getClass())) {
103 for (Object oo : map.values()) {
104 addToResult(result, execute(oo));
109 addToResult(result, XSQLCriteria.getValue(o, this.property));
114 public static void addToResult(List result, Object o) {
118 if (Set.class.isAssignableFrom(o.getClass())) {
120 for (Object oo : lst) {
123 } else if (List.class.isAssignableFrom(o.getClass())) {
125 for (Object oo : lst) {
128 } else if (Map.class.isAssignableFrom(o.getClass())) {
130 for (Object oo : map.values()) {