import org.opendaylight.yangtools.yang.model.api.NotificationDefinition
import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil
import org.opendaylight.yangtools.sal.binding.model.api.Restrictions
-
+import org.opendaylight.yangtools.yang.common.QName\r
+\r
public class BindingGeneratorImpl implements BindingGenerator {
private final Map<Module, ModuleContext> genCtx = new HashMap()
filteredGenTypes.addAll(genCtx.get(m).generatedTypes);
}
- genCtx.clear;
+ //genCtx.clear;
return filteredGenTypes;
}
*/
private def GeneratedTypeBuilder addDefaultInterfaceDefinition(String packageName, SchemaNode schemaNode,
Type parent) {
- val builder = addRawInterfaceDefinition(packageName, schemaNode, "");
+ val it = addRawInterfaceDefinition(packageName, schemaNode, "");\r
+ val qname = schemaNode.QName;
+ //addConstant(QName.typeForClass,"QNAME",'''\r
+ // org.opendaylight.yangtools.yang.common.QName.create("«qname.namespace»","«qname.formattedRevision»","«qname.localName»");\r
+ //''')\r
if (parent === null) {
- builder.addImplementsType(DATA_OBJECT);
+ addImplementsType(DATA_OBJECT);
} else {
- builder.addImplementsType(BindingTypes.childOf(parent));
+ addImplementsType(BindingTypes.childOf(parent));
}
if (!(schemaNode instanceof GroupingDefinition)) {
- builder.addImplementsType(augmentable(builder));
+ addImplementsType(augmentable(it));
}
if (schemaNode instanceof DataNodeContainer) {
- addImplementedInterfaceFromUses(schemaNode as DataNodeContainer, builder);
+ addImplementedInterfaceFromUses(schemaNode as DataNodeContainer, it);
}
- return builder;
+ return it;
}
/**\r
* @return string with the name of the getter method for\r
* <code>methodName</code> in JAVA method format\r
*/
- private def String getterMethodName(String methodName, Type returnType) {
+ public static def String getterMethodName(String localName, Type returnType) {
val method = new StringBuilder();
if (BOOLEAN.equals(returnType)) {
method.append("is");
} else {
method.append("get");
}
- method.append(parseToClassName(methodName));
+ method.append(parseToClassName(localName));
return method.toString();
}
}
return null
}
-
+\r
+\r
+ public def getModuleContexts() {\r
+ genCtx;\r
+ }
}
import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-final class ModuleContext {
+public final class ModuleContext {
private GeneratedTypeBuilder moduleNode;
private final List<GeneratedTOBuilder> genTOs = new ArrayList<GeneratedTOBuilder>();
private final Map<SchemaPath, Type> typedefs = new HashMap<SchemaPath, Type>();
augmentations.add(b);
}
+ public Map<SchemaPath, Type> getTypedefs() {
+ return typedefs;
+ }
+
+ public Map<SchemaPath, GeneratedTypeBuilder> getChildNodes() {
+ return childNodes;
+ }
+
+ public Map<SchemaPath, GeneratedTypeBuilder> getGroupings() {
+ return groupings;
+ }
+
+ public Map<SchemaPath, GeneratedTypeBuilder> getCases() {
+ return cases;
+ }
+
+ public Set<GeneratedTOBuilder> getIdentities() {
+ return identities;
+ }
+
+ public Set<GeneratedTypeBuilder> getTopLevelNodes() {
+ return topLevelNodes;
+ }
+
+ public List<GeneratedTypeBuilder> getAugmentations() {
+ return augmentations;
+ }
+
}
if (obj == null) {
return false;
}
- if (getClass() != obj.getClass()) {
+ if (false ==(obj instanceof Type)) {
return false;
}
Type other = (Type) obj;
*
*
*/
-public final class InstanceIdentifier<T extends DataObject> implements Path<InstanceIdentifier<?>>,Immutable {
+public final class InstanceIdentifier<T extends DataObject> implements Path<InstanceIdentifier<? extends DataObject>>,Immutable {
private final List<PathArgument> path;
private final Class<T> targetType;
import java.io.Serializable;
import java.net.URI;
import java.net.URISyntaxException;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
protected static final Logger LOGGER = LoggerFactory.getLogger(QName.class);
- private SimpleDateFormat revisionFormat = new SimpleDateFormat("yyyy-MM-dd");
+ private static final SimpleDateFormat REVISION_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
private final URI namespace;
private final String localName;
private final String prefix;
+ private final String formattedRevision;
private final Date revision;
/**
this.localName = localName;
this.revision = revision;
this.prefix = prefix;
+ if(revision != null) {
+ this.formattedRevision = REVISION_FORMAT.format(revision);
+ } else {
+ this.formattedRevision = null;
+ }
}
/**
int result = 1;
result = prime * result + ((localName == null) ? 0 : localName.hashCode());
result = prime * result + ((namespace == null) ? 0 : namespace.hashCode());
- result = prime * result + ((revision == null) ? 0 : revision.hashCode());
+ result = prime * result + ((formattedRevision == null) ? 0 : formattedRevision.hashCode());
return result;
}
} else if (!namespace.equals(other.namespace)) {
return false;
}
- if (revision == null) {
- if (other.revision != null) {
+ if (formattedRevision == null) {
+ if (other.formattedRevision != null) {
return false;
}
} else if (!revision.equals(other.revision)) {
}
return true;
}
+
+
+ public static QName create(QName base, String localName){
+ return new QName(base, localName);
+ }
+
+ public static QName create(URI namespace, Date revision, String localName){
+ return new QName(namespace, revision, localName);
+ }
+
+
+ public static QName create(String namespace, String revision, String localName) throws IllegalArgumentException{
+ try {
+ URI namespaceUri = new URI(namespace);
+ Date revisionDate = REVISION_FORMAT.parse(revision);
+ return create(namespaceUri, revisionDate, localName);
+ } catch (ParseException pe) {
+ throw new IllegalArgumentException("Revision is not in supported format", pe);
+ } catch (URISyntaxException ue) {
+ throw new IllegalArgumentException("Namespace is is not valid URI", ue);
+ }
+ }
@Override
public String toString() {
sb.append("(" + namespace);
if (revision != null) {
- sb.append("?revision=" + revisionFormat.format(revision));
+ sb.append("?revision=" + REVISION_FORMAT.format(revision));
}
sb.append(")");
}
String query = "";
if (revision != null) {
- query = "revision=" + revisionFormat.format(revision);
+ query = "revision=" + formattedRevision;
}
URI compositeURI = null;
}
return compositeURI;
}
+
+ public String getFormattedRevision() {
+ return formattedRevision;
+ }
}