import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import javax.annotation.Nullable;
import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.AugmentationSchemaProxy;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.util.EffectiveAugmentationSchema;
import org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* schema.
*
* @param augClass Augmentation class
- * @return Schema of augmentation
- * @throws IllegalArgumentException If supplied class is not an augmentation or current context does not contain schema for augmentation.
+ * @return Schema of augmentation or null if augmentaiton is not known in this context
+ * @throws IllegalArgumentException If supplied class is not an augmentation
*/
- public AugmentationSchema getAugmentationDefinition(final Class<?> augClass) throws IllegalArgumentException {
+ public @Nullable AugmentationSchema getAugmentationDefinition(final Class<?> augClass) throws IllegalArgumentException {
Preconditions.checkArgument(Augmentation.class.isAssignableFrom(augClass), "Class %s does not represent augmentation", augClass);
- final AugmentationSchema ret = augmentationToSchema.get(referencedType(augClass));
- Preconditions.checkArgument(ret != null, "Supplied augmentation %s is not valid in current context", augClass);
- return ret;
+ return augmentationToSchema.get(referencedType(augClass));
}
/**
public Entry<AugmentationIdentifier, AugmentationSchema> getResolvedAugmentationSchema(final DataNodeContainer target,
final Class<? extends Augmentation<?>> aug) {
final AugmentationSchema origSchema = getAugmentationDefinition(aug);
+ Preconditions.checkArgument(origSchema != null, "Augmentation %s is not known in current schema context",aug);
/*
* FIXME: Validate augmentation schema lookup
*
}
final AugmentationIdentifier identifier = new AugmentationIdentifier(childNames);
- final AugmentationSchema proxy = new AugmentationSchemaProxy(origSchema, realChilds);
+ final AugmentationSchema proxy = new EffectiveAugmentationSchema(origSchema, realChilds);
return new AbstractMap.SimpleEntry<>(identifier, proxy);
}
* the given context.
* @throws IllegalArgumentException If supplied class does not represent case.
*/
- public Optional<ChoiceCaseNode> getCaseSchemaDefinition(final ChoiceNode schema, final Class<?> childClass) throws IllegalArgumentException {
+ public Optional<ChoiceCaseNode> getCaseSchemaDefinition(final ChoiceSchemaNode schema, final Class<?> childClass) throws IllegalArgumentException {
final DataSchemaNode origSchema = getSchemaDefinition(childClass);
Preconditions.checkArgument(origSchema instanceof ChoiceCaseNode, "Supplied schema %s is not case.", origSchema);
}
public ImmutableMap<Type, Entry<Type, Type>> getChoiceCaseChildren(final DataNodeContainer schema) {
- final Map<Type,Entry<Type,Type>> childToCase = new HashMap<>();;
- for (final ChoiceNode choice : FluentIterable.from(schema.getChildNodes()).filter(ChoiceNode.class)) {
- final ChoiceNode originalChoice = getOriginalSchema(choice);
+ final Map<Type,Entry<Type,Type>> childToCase = new HashMap<>();
+ for (final ChoiceSchemaNode choice : FluentIterable.from(schema.getChildNodes()).filter(ChoiceSchemaNode.class)) {
+ final ChoiceSchemaNode originalChoice = getOriginalSchema(choice);
final Type choiceType = referencedType(typeToDefiningSchema.inverse().get(originalChoice));
final Collection<Type> cases = choiceToCases.get(choiceType);