import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
+import com.google.common.collect.Multimaps;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
public final class ModuleContext {
private final List<GeneratedTypeBuilder> augmentations = new ArrayList<GeneratedTypeBuilder>();
private final BiMap<Type,AugmentationSchema> typeToAugmentation = HashBiMap.create();
+ private final Map<Type,Object> typeToSchema = new HashMap<>();
+
+
private final Multimap<Type, Type> choiceToCases = HashMultimap.create();
private final BiMap<Type,ChoiceCaseNode> caseTypeToSchema = HashBiMap.create();
}
public Multimap<Type, Type> getChoiceToCases() {
- return choiceToCases;
+ return Multimaps.unmodifiableMultimap(choiceToCases);
}
public Multimap<Type, Type> getAugmentableToAugmentations() {
- return augmentableToAugmentations;
+ return Multimaps.unmodifiableMultimap(augmentableToAugmentations);
}
public GeneratedTypeBuilder getModuleNode() {
genTOs.add(b);
}
- public void addChildNodeType(final SchemaPath p, final GeneratedTypeBuilder b) {
- childNodes.put(p, b);
+ public void addChildNodeType(final SchemaNode p, final GeneratedTypeBuilder b) {
+ childNodes.put(p.getPath(), b);
+ typeToSchema.put(b,p);
}
public void addGroupingType(final SchemaPath p, final GeneratedTypeBuilder b) {
}
public Map<SchemaPath, GeneratedTypeBuilder> getChildNodes() {
- return childNodes;
+ return Collections.unmodifiableMap(childNodes);
}
public Map<SchemaPath, GeneratedTypeBuilder> getGroupings() {
- return groupings;
+ return Collections.unmodifiableMap(groupings);
}
public Map<SchemaPath, GeneratedTypeBuilder> getCases() {
- return cases;
+ return Collections.unmodifiableMap(cases);
}
public Map<QName,GeneratedTOBuilder> getIdentities() {
- return identities;
+ return Collections.unmodifiableMap(identities);
}
public Set<GeneratedTypeBuilder> getTopLevelNodes() {
- return topLevelNodes;
+ return Collections.unmodifiableSet(topLevelNodes);
}
public List<GeneratedTypeBuilder> getAugmentations() {
- return augmentations;
+ return Collections.unmodifiableList(augmentations);
}
public BiMap<Type, AugmentationSchema> getTypeToAugmentation() {
- return typeToAugmentation;
+ return Maps.unmodifiableBiMap(typeToAugmentation);
}
public void addTypeToAugmentation(final GeneratedTypeBuilder builder, final AugmentationSchema schema) {
- typeToAugmentation.put(builder, schema);
+ typeToAugmentation.put(builder, schema);
+ typeToSchema.put(builder, schema);
}
public void addTargetToAugmentation(final Type target, final GeneratedTypeBuilder augmentation) {
augmentableToAugmentations.put(target,augmentation);
}
- public void addChoiceToCaseMapping(Type choiceType, Type caseType, ChoiceCaseNode schema) {
+ public void addChoiceToCaseMapping(final Type choiceType, final Type caseType, final ChoiceCaseNode schema) {
choiceToCases.put(choiceType, caseType);
caseTypeToSchema.put(caseType, schema);
+ typeToSchema.put(caseType, schema);
}
public BiMap<Type, ChoiceCaseNode> getCaseTypeToSchemas() {
- return caseTypeToSchema;
+ return Maps.unmodifiableBiMap(caseTypeToSchema);
+ }
+
+ /**
+ *
+ * Returns mapping of type to its schema.
+ *
+ * Valid values are only instances of {@link DataSchemaNode} or {@link AugmentationSchema}
+ *
+ * @return
+ */
+ public Map<Type, Object> getTypeToSchema() {
+ return Collections.unmodifiableMap(typeToSchema);
}
}