+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.controller.md.sal.dom.xsql;
import java.io.DataInputStream;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
+/**
+ * @author Sharon Aicler(saichler@gmail.com)
+ **/
public class XSQLBluePrint implements DatabaseMetaData, Serializable {
private static final long serialVersionUID = 1L;
String odlTableName) {
Map<String, XSQLBluePrintNode> map = this.odlNameToBluePrint
.get(odlTableName);
- if (map == null)
+ if (map == null) {
return null;
+ }
return map.values().toArray(new XSQLBluePrintNode[map.size()]);
}
return cacheLoadedSuccessfuly;
}
- private static Map<Class, Set<Class>> superClassMap = new HashMap<Class, Set<Class>>();
+ private static Map<Class<?>, Set<Class<?>>> superClassMap = new HashMap<>();
- public static Set<Class> getInheritance(Class myObjectClass,
- Class returnType) {
+ public static Set<Class<?>> getInheritance(Class<?> myObjectClass,
+ Class<?> returnType) {
if (returnType != null && myObjectClass.equals(returnType)) {
- return new HashSet<Class>();
+ return new HashSet<>();
}
- Set<Class> result = superClassMap.get(myObjectClass);
+ Set<Class<?>> result = superClassMap.get(myObjectClass);
if (result != null) {
return result;
}
- result = new HashSet<Class>();
+ result = new HashSet<>();
superClassMap.put(myObjectClass, result);
if (returnType != null) {
if (!returnType.equals(myObjectClass)) {
- Class mySuperClass = myObjectClass.getSuperclass();
+ Class<?> mySuperClass = myObjectClass.getSuperclass();
while (mySuperClass != null) {
result.add(mySuperClass);
mySuperClass = mySuperClass.getSuperclass();
return result;
}
- public static Set<Class> collectInterfaces(Class cls) {
- Set<Class> result = new HashSet();
- Class myInterfaces[] = cls.getInterfaces();
+ public static Set<Class<?>> collectInterfaces(Class<?> cls) {
+ Set<Class<?>> result = new HashSet<>();
+ Class<?> myInterfaces[] = cls.getInterfaces();
if (myInterfaces != null) {
- for (Class in : myInterfaces) {
+ for (Class<?> in : myInterfaces) {
result.add(in);
result.addAll(collectInterfaces(in));
}
return result;
}
- public void addToBluePrintCache(XSQLBluePrintNode blNode) {
- this.tableNameToBluePrint.put(blNode.getBluePrintNodeName(), blNode);
- Map<String, XSQLBluePrintNode> map = this.odlNameToBluePrint.get(blNode
- .getODLTableName());
- if (map == null) {
- map = new HashMap<String, XSQLBluePrintNode>();
- this.odlNameToBluePrint.put(blNode.getODLTableName(), map);
+ public XSQLBluePrintNode addToBluePrintCache(XSQLBluePrintNode blNode,XSQLBluePrintNode parent) {
+ XSQLBluePrintNode existingNode = this.tableNameToBluePrint.get(blNode.getBluePrintNodeName());
+ if(existingNode!=null){
+ existingNode.mergeAugmentation(blNode);
+ return existingNode;
+ }else{
+ this.tableNameToBluePrint.put(blNode.getBluePrintNodeName(), blNode);
+ Map<String, XSQLBluePrintNode> map = this.odlNameToBluePrint.get(blNode.getODLTableName());
+ if (map == null) {
+ map = new HashMap<String, XSQLBluePrintNode>();
+ this.odlNameToBluePrint.put(blNode.getODLTableName(), map);
+ }
+ map.put(blNode.getBluePrintNodeName(), blNode);
+ if(parent!=null)
+ parent.addChild(blNode);
+ return blNode;
}
- map.put(blNode.getBluePrintNodeName(), blNode);
}
- public Class getGenericType(ParameterizedType type) {
+ public Class<?> getGenericType(ParameterizedType type) {
Type[] typeArguments = type.getActualTypeArguments();
for (Type typeArgument : typeArguments) {
if (typeArgument instanceof ParameterizedType) {
ParameterizedType pType = (ParameterizedType) typeArgument;
- return (Class) pType.getRawType();
+ return (Class<?>) pType.getRawType();
} else if (typeArgument instanceof Class) {
- return (Class) typeArgument;
+ return (Class<?>) typeArgument;
}
}
return null;
}
- public Class getMethodReturnTypeFromGeneric(Method m) {
+ public Class<?> getMethodReturnTypeFromGeneric(Method m) {
Type rType = m.getGenericReturnType();
if (rType instanceof ParameterizedType) {
return getGenericType((ParameterizedType) rType);