<dependency>
<groupId>org.opendaylight.mdsal.model</groupId>
<artifactId>ietf-type-util</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
</dependency>
<!-- RFC7223 -->
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>2.1.8</version>
+ <version>3.0.0</version>
<dependencies>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-artifacts</artifactId>
- <version>2.1.8</version>
+ <version>3.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
final Iterator<YangInstanceIdentifier.PathArgument> toEnter = domArgumentList.iterator();
DataTreeCandidateNode current = domData;
while (toEnter.hasNext() && current != null) {
- current = current.getModifiedChild(toEnter.next());
+ current = current.getModifiedChild(toEnter.next()).orElse(null);
}
return current != null && current.getModificationType() != UNMODIFIED ? create(childCodec, current) : null;
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
assertNotNull(lazySerializedContainerNode);
assertEquals(leafNode, lazySerializedContainerNode.getChild(leafNode.getIdentifier()).get());
assertFalse(lazySerializedContainerNode.getChild(mock(PathArgument.class)).isPresent());
- assertTrue(lazySerializedContainerNode.getAttributes().isEmpty());
assertTrue(lazySerializedContainerNode.getValue().isEmpty());
assertEquals(lazySerializedContainerNode.getIdentifier().getNodeType(),
lazySerializedContainerNode.getNodeType());
assertEquals(rpcName.getLastComponent(), lazySerializedContainerNode.getIdentifier().getNodeType());
- assertNull(lazySerializedContainerNode.getAttributeValue(null));
assertEquals(dataObject, lazySerializedContainerNode.bindingData());
}
}
\ No newline at end of file
public synchronized void changeSchema(final SchemaContext newContext) {
schemaContext = newContext;
- for (ListenerRegistration<SchemaContextListener> listener : listeners) {
+ for (ListenerRegistration<? extends SchemaContextListener> listener : listeners.getRegistrations()) {
listener.getInstance().onGlobalContextUpdated(schemaContext);
}
}
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
import java.util.concurrent.Callable;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
if (schema instanceof LeafSchemaNode) {
valueType = method.getReturnType();
} else if (schema instanceof LeafListSchemaNode) {
- final Type genericType = ClassLoaderUtils.getFirstGenericParameter(method.getGenericReturnType());
+ final Optional<Type> optType = ClassLoaderUtils.getFirstGenericParameter(
+ method.getGenericReturnType());
+ checkState(optType.isPresent(), "Failed to find return type for %s", method);
+ final Type genericType = optType.get();
if (genericType instanceof Class<?>) {
valueType = (Class<?>) genericType;
} else if (genericType instanceof ParameterizedType) {
@Override
public IdentifiableItemCodec getPathArgumentCodec(final Class<?> listClz, final ListSchemaNode schema) {
- final Class<? extends Identifier<?>> identifier = ClassLoaderUtils.findFirstGenericArgument(listClz,
+ final Optional<Class<Identifier<?>>> optIdentifier = ClassLoaderUtils.findFirstGenericArgument(listClz,
Identifiable.class);
+ checkState(optIdentifier.isPresent(), "Failed to find identifier for %s", listClz);
+
+ final Class<Identifier<?>> identifier = optIdentifier.get();
final Map<QName, ValueContext> valueCtx = new HashMap<>();
for (final LeafNodeCodecContext<?> leaf : getLeafNodes(identifier, schema).values()) {
final QName name = leaf.getDomPathArgument().getNodeType();
import java.util.Deque;
import java.util.Map;
import java.util.Map.Entry;
+import javax.xml.transform.dom.DOMSource;
import org.opendaylight.yangtools.concepts.Delegator;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.BindingStreamEventWriter;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
// NormalizedNode writer does not have entry into case, but into choice
// so for leaving case, we do not emit endNode.
if (!(left instanceof CaseNodeCodecContext)) {
- getDelegate().endNode();
+ delegate.endNode();
}
}
@Override
public void leafNode(final String localName, final Object value) throws IOException {
- Entry<NodeIdentifier, Object> dom = serializeLeaf(localName, value);
- getDelegate().leafNode(dom.getKey(), dom.getValue());
+ final Entry<NodeIdentifier, Object> dom = serializeLeaf(localName, value);
+ delegate.startLeafNode(dom.getKey());
+ delegate.scalarValue(dom.getValue());
+ delegate.endNode();
}
@Override
public void anyxmlNode(final String name, final Object value) throws IOException {
- Entry<NodeIdentifier, Object> dom = serializeLeaf(name, value);
- getDelegate().anyxmlNode(dom.getKey(), dom.getValue());
+ final Entry<NodeIdentifier, Object> dom = serializeLeaf(name, value);
+ delegate.startAnyxmlNode(dom.getKey());
+ delegate.domSourceValue((DOMSource) dom.getValue());
+ delegate.endNode();
}
@Override
public void leafSetEntryNode(final Object value) throws IOException {
- LeafNodeCodecContext<?> ctx = (LeafNodeCodecContext<?>) current();
- getDelegate().leafSetEntryNode(ctx.getSchema().getQName(),
- ctx.getValueCodec().serialize(value));
+ final LeafNodeCodecContext<?> ctx = (LeafNodeCodecContext<?>) current();
+ final Object domValue = ctx.getValueCodec().serialize(value);
+ delegate.startLeafSetEntryNode(new NodeWithValue<>(ctx.getSchema().getQName(), domValue));
+ delegate.scalarValue(domValue);
+ delegate.endNode();
}
@Override
public void startAugmentationNode(final Class<? extends Augmentation<?>> augmentationType)
throws IOException {
- getDelegate().startAugmentationNode(enter(augmentationType, AugmentationIdentifier.class));
+ delegate.startAugmentationNode(enter(augmentationType, AugmentationIdentifier.class));
}
@Override
@Override
public void startChoiceNode(final Class<? extends DataContainer> type, final int childSizeHint)
throws IOException {
- getDelegate().startChoiceNode(enter(type, NodeIdentifier.class), childSizeHint);
+ delegate.startChoiceNode(enter(type, NodeIdentifier.class), childSizeHint);
}
@Override
public void startContainerNode(final Class<? extends DataObject> object, final int childSizeHint)
throws IOException {
- getDelegate().startContainerNode(enter(object, NodeIdentifier.class), childSizeHint);
+ delegate.startContainerNode(enter(object, NodeIdentifier.class), childSizeHint);
}
@Override
public void startLeafSet(final String localName, final int childSizeHint) throws IOException {
final NodeIdentifier id = enter(localName, NodeIdentifier.class);
emitSchema(current().getSchema());
- getDelegate().startLeafSet(id, childSizeHint);
+ delegate.startLeafSet(id, childSizeHint);
}
@Override
public void startOrderedLeafSet(final String localName, final int childSizeHint) throws IOException {
- getDelegate().startOrderedLeafSet(enter(localName, NodeIdentifier.class), childSizeHint);
+ delegate.startOrderedLeafSet(enter(localName, NodeIdentifier.class), childSizeHint);
}
@Override
public void startMapEntryNode(final Identifier<?> key, final int childSizeHint) throws IOException {
duplicateSchemaEnter();
NodeIdentifierWithPredicates identifier = ((KeyedListNodeCodecContext<?>) current()).serialize(key);
- getDelegate().startMapEntryNode(identifier, childSizeHint);
+ delegate.startMapEntryNode(identifier, childSizeHint);
}
@Override
public <T extends DataObject & Identifiable<?>> void startMapNode(final Class<T> mapEntryType,
final int childSizeHint) throws IOException {
- getDelegate().startMapNode(enter(mapEntryType, NodeIdentifier.class), childSizeHint);
+ delegate.startMapNode(enter(mapEntryType, NodeIdentifier.class), childSizeHint);
}
@Override
public <T extends DataObject & Identifiable<?>> void startOrderedMapNode(final Class<T> mapEntryType,
final int childSizeHint) throws IOException {
- getDelegate().startOrderedMapNode(enter(mapEntryType, NodeIdentifier.class), childSizeHint);
+ delegate.startOrderedMapNode(enter(mapEntryType, NodeIdentifier.class), childSizeHint);
}
@Override
public void startUnkeyedList(final Class<? extends DataObject> obj, final int childSizeHint) throws IOException {
- getDelegate().startUnkeyedList(enter(obj, NodeIdentifier.class), childSizeHint);
+ delegate.startUnkeyedList(enter(obj, NodeIdentifier.class), childSizeHint);
}
@Override
public void startUnkeyedListItem(final int childSizeHint) throws IOException {
- getDelegate().startUnkeyedListItem(duplicateSchemaEnter(), childSizeHint);
+ delegate.startUnkeyedListItem(duplicateSchemaEnter(), childSizeHint);
}
@Override
public void flush() throws IOException {
- getDelegate().flush();
+ delegate.flush();
}
@Override
public void close() throws IOException {
- getDelegate().close();
+ delegate.close();
}
}
package org.opendaylight.mdsal.binding.dom.codec.impl;
import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Verify.verify;
-import static java.util.Objects.requireNonNull;
import com.google.common.base.Throwables;
import com.google.common.base.Verify;
private ActionCodecContext prepareActionContext(final int inputOffset, final int outputOffset,
final int expectedArgsLength, final Class<? extends Action<?, ?, ?>> action, final Class<?> actionType) {
- final ParameterizedType paramType = requireNonNull(ClassLoaderUtils.findParameterizedType(action, actionType),
- () -> "There does not exist any ParameterType in " + action);
+ final Optional<ParameterizedType> optParamType = ClassLoaderUtils.findParameterizedType(action, actionType);
+ checkState(optParamType.isPresent(), "%s does not specialize %s", action, actionType);
+
+ final ParameterizedType paramType = optParamType.get();
final Type[] args = paramType.getActualTypeArguments();
checkArgument(args.length == expectedArgsLength, "Unexpected (%s) Action generatic arguments", args.length);
final ActionDefinition schema = factory().getRuntimeContext().getActionDefinition(action);
import org.opendaylight.yangtools.concepts.Codec;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.yangtools.yang.model.api.PathExpression;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
final TypeDefinition<?> subtype) throws NoSuchMethodException {
final SchemaContext schemaContext = bindingCodecContext.getRuntimeContext().getSchemaContext();
final Module module = schemaContext.findModule(subtype.getQName().getModule()).get();
- final RevisionAwareXPath xpath = ((LeafrefTypeDefinition) subtype).getPathStatement();
+ final PathExpression xpath = ((LeafrefTypeDefinition) subtype).getPathStatement();
// find schema node in schema context by xpath of leafref
final SchemaNode dataNode;
if (xpath.isAbsolute()) {
import com.google.common.annotations.Beta;
import com.google.common.collect.ForwardingObject;
import java.util.Collection;
-import java.util.Map;
import java.util.Optional;
import org.checkerframework.checker.lock.qual.GuardedBy;
import org.eclipse.jdt.annotation.NonNull;
return delegate();
}
- @Override
- public Map<QName, String> getAttributes() {
- return delegate().getAttributes();
- }
-
- @Override
- public Object getAttributeValue(final QName name) {
- return delegate().getAttributeValue(name);
- }
-
@Override
public Collection<DataContainerChild<? extends PathArgument, ?>> getValue() {
return delegate().getValue();
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableChoiceNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
}
private static ContainerNode getNormalizedTopWithAugments(final AugmentationNode... augChild) {
- final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> builder =
- ImmutableContainerNodeBuilder.create();
+ final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> builder = ImmutableContainerNodeBuilder.create();
for (AugmentationNode augmentationNode : augChild) {
builder.withChild(augmentationNode);
final Module parentModule = findParentModule(schemaContext, leaf);
Type returnType = null;
- final TypeDefinition<?> typeDef = CompatUtils.compatLeafType(leaf);
+ final TypeDefinition<?> typeDef = CompatUtils.compatType(leaf);
if (isInnerType(leaf, typeDef)) {
if (typeDef instanceof EnumTypeDefinition) {
returnType = typeProvider.javaTypeForSchemaDefinitionType(typeDef, leaf, inGrouping);
final boolean isReadOnly) {
if (leaf != null && toBuilder != null) {
Type returnType;
- final TypeDefinition<?> typeDef = CompatUtils.compatLeafType(leaf);
+ final TypeDefinition<?> typeDef = CompatUtils.compatType(leaf);
if (typeDef instanceof UnionTypeDefinition) {
// GeneratedType for this type definition should have be already created
final ModuleContext mc = moduleContext(typeDef.getQName().getModule());
*/
package org.opendaylight.mdsal.binding.yang.types;
-import static com.google.common.base.Verify.verifyNotNull;
import static java.util.Objects.requireNonNull;
import static org.opendaylight.mdsal.binding.model.util.BindingTypes.TYPE_OBJECT;
import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.yangtools.yang.model.api.PathExpression;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
import org.opendaylight.yangtools.yang.model.util.ModuleDependencySort;
-import org.opendaylight.yangtools.yang.model.util.RevisionAwareXPathImpl;
+import org.opendaylight.yangtools.yang.model.util.PathExpressionImpl;
import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
import org.opendaylight.yangtools.yang.model.util.type.CompatUtils;
private boolean isLeafRefSelfReference(final LeafrefTypeDefinition leafref, final SchemaNode parentNode) {
final SchemaNode leafRefValueNode;
- final RevisionAwareXPath leafRefXPath = leafref.getPathStatement();
- final RevisionAwareXPath leafRefStrippedXPath = new RevisionAwareXPathImpl(
- GROUPS_PATTERN.matcher(leafRefXPath.toString()).replaceAll(""), leafRefXPath.isAbsolute());
+ final PathExpression leafRefXPath = leafref.getPathStatement();
+ final PathExpression leafRefStrippedXPath = new PathExpressionImpl(
+ GROUPS_PATTERN.matcher(leafRefXPath.getOriginalString()).replaceAll(""), leafRefXPath.isAbsolute());
///// skip leafrefs in augments - they're checked once augments are resolved
final Iterator<QName> iterator = parentNode.getPath().getPathFromRoot().iterator();
final boolean inGrouping) {
Preconditions.checkArgument(leafrefType != null, "Leafref Type Definition reference cannot be NULL!");
- final RevisionAwareXPath xpath = leafrefType.getPathStatement();
+ final PathExpression xpath = leafrefType.getPathStatement();
Preconditions.checkArgument(xpath != null, "The Path Statement for Leafref Type Definition cannot be NULL!");
- final String strXPath = verifyNotNull(xpath.toString());
+ final String strXPath = xpath.getOriginalString();
if (strXPath.indexOf('[') != -1) {
// XXX: why are we special-casing this?
return Types.objectType();
private static boolean leafContainsEnumDefinition(final SchemaNode dataNode) {
if (dataNode instanceof LeafSchemaNode) {
final LeafSchemaNode leaf = (LeafSchemaNode) dataNode;
- return CompatUtils.compatLeafType(leaf) instanceof EnumTypeDefinition;
+ return CompatUtils.compatType(leaf) instanceof EnumTypeDefinition;
}
return false;
}
if (dataNode != null) {
if (dataNode instanceof LeafSchemaNode) {
final LeafSchemaNode leaf = (LeafSchemaNode) dataNode;
- final TypeDefinition<?> type = CompatUtils.compatLeafType(leaf);
+ final TypeDefinition<?> type = CompatUtils.compatType(leaf);
returnType = javaTypeForSchemaDefinitionType(type, leaf);
} else if (dataNode instanceof LeafListSchemaNode) {
final LeafListSchemaNode leafList = (LeafListSchemaNode) dataNode;
}
public String getTypeDefaultConstruction(final LeafSchemaNode node, final String defaultValue) {
- final TypeDefinition<?> type = CompatUtils.compatLeafType(node);
+ final TypeDefinition<?> type = CompatUtils.compatType(node);
final QName typeQName = type.getQName();
final TypeDefinition<?> base = baseTypeDefForExtendedType(type);
requireNonNull(type, () -> "Cannot provide default construction for null type of " + node);
Preconditions.checkArgument(leafrefType.getPathStatement() != null,
"The Path Statement for Leafref Type Definition cannot be NULL!");
- final RevisionAwareXPath xpath = leafrefType.getPathStatement();
- final String strXPath = xpath.toString();
+ final PathExpression xpath = leafrefType.getPathStatement();
+ final String strXPath = xpath.getOriginalString();
if (strXPath != null) {
if (strXPath.indexOf('[') == -1) {
}
private String unionToDef(final LeafSchemaNode node) {
- final TypeDefinition<?> type = CompatUtils.compatLeafType(node);
+ final TypeDefinition<?> type = CompatUtils.compatType(node);
String parentName;
String className;
import java.util.List;
import java.util.Optional;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.yangtools.yang.model.api.PathExpression;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
+import org.opendaylight.yangtools.yang.xpath.api.YangLocationPath;
/**
* Mock LeafrefDypeDefinition implementation with non-null referenced RevisionAwareXPath. Although RevisionAwareXPath
*/
public class LeafrefTypeWithNullToStringInXpath implements LeafrefTypeDefinition {
@Override
- public RevisionAwareXPath getPathStatement() {
- return new RevisionAwareXPath() {
+ public PathExpression getPathStatement() {
+ return new PathExpression() {
@Override
public boolean isAbsolute() {
return false;
}
@Override
- public String toString() {
+ public String getOriginalString() {
return null;
}
+
+ @Override
+ public YangLocationPath getLocation() {
+ throw new UnsupportedOperationException();
+ }
};
}
* 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.mdsal.binding.yang.types;
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.Optional;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.yangtools.yang.model.api.PathExpression;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
*/
public class LeafrefTypeWithNullXpath implements LeafrefTypeDefinition {
@Override
- public RevisionAwareXPath getPathStatement() {
+ public PathExpression getPathStatement() {
return null;
}
provider.provideTypeForLeafref(leafrePath, this.schemaNode, false);
}
- @Test(expected = IllegalStateException.class)
+ @Test(expected = NullPointerException.class)
public void provideTypeForLeafrefWithNullParentModuleTest() {
final AbstractTypeProvider provider = new RuntimeTypeProvider(SCHEMA_CONTEXT);
final LeafSchemaNode leaf = provideLeafNodeFromTopLevelContainer(TEST_TYPE_PROVIDER, "bar",
leaf cond-leafref {
type leafref {
- path "/tp:topology/tp:network-nodes/tp:network-node[node-id = 'super-node']";
+ path "/tp:topology/tp:network-nodes/tp:network-node[node-id = current()/super-node]";
}
}
}
}
}
-}
\ No newline at end of file
+}
leaf conditional-leafref {
type leafref {
- path "/prov:foo/prov:bars/prov:bar-item[prov:id=10]";
+ path "/prov:foo/prov:bars/prov:bar-item[prov:id=current()/../id]";
}
}
path "/somewhere/i/bellong";
}
}
-}
\ No newline at end of file
+}
leaf foo-cond-bar-item {
type leafref {
- path "../../foo/bars/bar-item[id=10]";
+ path "../../foo/bars/bar-item[id=current()/../bar-id]";
}
}
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class BindingGeneratorUtilTest {
- private static final SchemaPath ROOT_PATH = SchemaPath.create(true, QName.create("test", "/root"));
+ private static final SchemaPath ROOT_PATH = SchemaPath.create(true, QName.create("test", "root"));
@Rule
public ExpectedException expectedEx = ExpectedException.none();
generatedTypeBuilder.setDescription("My description ...");
generatedTypeBuilder.setModuleName("myModuleName");
generatedTypeBuilder.setReference("myReference");
- generatedTypeBuilder.setSchemaPath(SchemaPath.create(true, QName.create("test", "/path")));
+ generatedTypeBuilder.setSchemaPath(SchemaPath.create(true, QName.create("test", "path")));
assertNotNull(generatedTypeBuilder.addComment(TypeComments.javadoc("My comment..").get()));
assertEquals(
assertEquals("My description ...", instance.getDescription());
assertEquals("myModuleName", instance.getModuleName());
assertEquals("myReference", instance.getReference());
- assertEquals(SchemaPath.create(true, QName.create("test", "/path")).getPathFromRoot(),
+ assertEquals(SchemaPath.create(true, QName.create("test", "path")).getPathFromRoot(),
instance.getSchemaPath());
assertEquals("My comment..", instance.getComment().getJavadoc());
}
*/
public static Class<? extends Augmentable<?>> findAugmentationTarget(
final Class<? extends Augmentation<?>> augmentation) {
- return ClassLoaderUtils.findFirstGenericArgument(augmentation, Augmentation.class);
+ final Optional<Class<Augmentable<?>>> opt = ClassLoaderUtils.findFirstGenericArgument(augmentation,
+ Augmentation.class);
+ return opt.orElse(null);
}
/**
* @return Parent class, e.g. class of which the childClass is ChildOf.
*/
public static Class<?> findHierarchicalParent(final Class<? extends ChildOf<?>> childClass) {
- return ClassLoaderUtils.findFirstGenericArgument(childClass, ChildOf.class);
+ return ClassLoaderUtils.findFirstGenericArgument(childClass, ChildOf.class).orElse(null);
}
/**
*/
public static Class<?> findHierarchicalParent(final DataObject child) {
if (child instanceof ChildOf) {
- return ClassLoaderUtils.findFirstGenericArgument(child.implementedInterface(), ChildOf.class);
+ return ClassLoaderUtils.findFirstGenericArgument(child.implementedInterface(), ChildOf.class).orElse(null);
}
return null;
}
public static Optional<Class<?>> resolveRpcOutputClass(final Method targetMethod) {
checkState(isRpcMethod(targetMethod), "Supplied method is not a RPC invocation method");
Type futureType = targetMethod.getGenericReturnType();
- Type rpcResultType = ClassLoaderUtils.getFirstGenericParameter(futureType);
- Type rpcResultArgument = ClassLoaderUtils.getFirstGenericParameter(rpcResultType);
+ Type rpcResultType = ClassLoaderUtils.getFirstGenericParameter(futureType).orElse(null);
+ Type rpcResultArgument = ClassLoaderUtils.getFirstGenericParameter(rpcResultType).orElse(null);
if (rpcResultArgument instanceof Class && !Void.class.equals(rpcResultArgument)) {
return Optional.of((Class) rpcResultArgument);
}
if (List.class.isAssignableFrom(returnType)) {
try {
return ClassLoaderUtils.callWithClassLoader(method.getDeclaringClass().getClassLoader(), () -> {
- Type listResult = ClassLoaderUtils.getFirstGenericParameter(method.getGenericReturnType());
- if (listResult instanceof Class && DataContainer.class.isAssignableFrom((Class) listResult)) {
- return Optional.of((Class) listResult);
- }
- return Optional.empty();
+ return ClassLoaderUtils.getFirstGenericParameter(method.getGenericReturnType()).flatMap(
+ result -> result instanceof Class && DataContainer.class.isAssignableFrom((Class) result)
+ ? Optional.of((Class) result) : Optional.empty());
});
} catch (Exception e) {
/*
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-artifacts</artifactId>
- <version>2.1.8</version>
+ <version>3.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
final DOMMountPoint prev = mountPoints.putIfAbsent(mountPointId, mountPoint);
checkState(prev == null, "Mount point %s already exists as %s", mountPointId, prev);
}
- listeners.forEach(listener -> {
+ listeners.getRegistrations().forEach(listener -> {
try {
listener.getInstance().onMountPointCreated(mountPointId);
} catch (final Exception ex) {
}
}
- listeners.forEach(listener -> {
+ listeners.getRegistrations().forEach(listener -> {
try {
listener.getInstance().onMountPointRemoved(mountPointId);
} catch (final Exception ex) {
@SuppressWarnings("checkstyle:IllegalCatch")
private void notifyListenerTypesChanged(final Set<SchemaPath> typesAfter) {
- final List<ListenerRegistration<DOMNotificationSubscriptionListener>> listenersAfter =
- ImmutableList.copyOf(subscriptionListeners.getListeners());
+ final List<? extends DOMNotificationSubscriptionListener> listenersAfter =
+ subscriptionListeners.getRegistrations().stream().map(ListenerRegistration::getInstance)
+ .collect(ImmutableList.toImmutableList());
executor.execute(() -> {
- for (final ListenerRegistration<DOMNotificationSubscriptionListener> subListener : listenersAfter) {
+ for (final DOMNotificationSubscriptionListener subListener : listenersAfter) {
try {
- subListener.getInstance().onSubscriptionChanged(typesAfter);
+ subListener.onSubscriptionChanged(typesAfter);
} catch (final Exception e) {
- LOG.warn("Uncaught exception during invoking listener {}", subListener.getInstance(), e);
+ LOG.warn("Uncaught exception during invoking listener {}", subListener, e);
}
}
});
final L listener) {
final Set<SchemaPath> initialTypes = listeners.keySet();
executor.execute(() -> listener.onSubscriptionChanged(initialTypes));
- return subscriptionListeners.registerWithType(listener);
+ return subscriptionListeners.register(listener);
}
private ListenableFuture<Void> publish(final long seq, final DOMNotification notification,
@SuppressWarnings("checkstyle:IllegalCatch")
public void notifyListeners(final SchemaContext schemaContext) {
synchronized (lock) {
- for (final ListenerRegistration<SchemaContextListener> registration : listeners) {
+ for (final ListenerRegistration<? extends SchemaContextListener> registration
+ : listeners.getRegistrations()) {
try {
registration.getInstance().onGlobalContextUpdated(schemaContext);
} catch (final Exception e) {
public void removeListener(final SchemaContextListener schemaContextListener) {
synchronized (lock) {
- for (final ListenerRegistration<SchemaContextListener> listenerRegistration : listeners.getListeners()) {
+ for (final ListenerRegistration<? extends SchemaContextListener> listenerRegistration
+ : listeners.getRegistrations()) {
if (listenerRegistration.getInstance().equals(schemaContextListener)) {
listenerRegistration.close();
break;
public boolean hasListeners() {
synchronized (lock) {
- return !Iterables.isEmpty(listeners.getListeners());
+ return !Iterables.isEmpty(listeners.getRegistrations());
}
}
@Override
public void close() {
synchronized (lock) {
- listeners.forEach(ListenerRegistration::close);
+ listeners.getRegistrations().forEach(ListenerRegistration::close);
}
}
}
candidateRoot = candidate.getRootNode();
checkChange(TEST_CONTAINER, TEST_CONTAINER_2, ModificationType.SUBTREE_MODIFIED, candidateRoot);
final DataTreeCandidateNode modifiedChild = candidateRoot.getModifiedChild(
- new YangInstanceIdentifier.NodeIdentifier(TestModel.OUTER_LIST_QNAME));
- assertNotNull(modifiedChild);
+ new YangInstanceIdentifier.NodeIdentifier(TestModel.OUTER_LIST_QNAME)).get();
checkChange(OUTER_LIST, OUTER_LIST_2, ModificationType.WRITE, modifiedChild);
listenerReg.close();
}
assertNotNull(candidate);
candidateRoot = candidate.getRootNode();
checkChange(OUTER_LIST, listAfter, ModificationType.SUBTREE_MODIFIED, candidateRoot);
- final DataTreeCandidateNode entry1Canditate = candidateRoot.getModifiedChild(outerListEntryId1);
+ final DataTreeCandidateNode entry1Canditate = candidateRoot.getModifiedChild(outerListEntryId1).get();
checkChange(outerListEntry1, null, ModificationType.DELETE, entry1Canditate);
- final DataTreeCandidateNode entry2Canditate = candidateRoot.getModifiedChild(outerListEntryId2);
+ final DataTreeCandidateNode entry2Canditate = candidateRoot.getModifiedChild(outerListEntryId2).get();
checkChange(null, outerListEntry2, ModificationType.WRITE, entry2Canditate);
- final DataTreeCandidateNode entry3Canditate = candidateRoot.getModifiedChild(outerListEntryId3);
+ final DataTreeCandidateNode entry3Canditate = candidateRoot.getModifiedChild(outerListEntryId3).get();
checkChange(null, outerListEntry3, ModificationType.WRITE, entry3Canditate);
listenerReg.close();
}
ListenerRegistry<DOMNotificationSubscriptionListener> subscriptionListeners =
domNotificationRouter.subscriptionListeners();
- assertFalse(subscriptionListeners.iterator().hasNext());
+ assertFalse(subscriptionListeners.getRegistrations().iterator().hasNext());
assertNotNull(domNotificationRouter.registerSubscriptionListener(domNotificationSubscriptionListener));
subscriptionListeners = domNotificationRouter.subscriptionListeners();
- assertTrue(subscriptionListeners.iterator().hasNext());
+ assertTrue(subscriptionListeners.getRegistrations().iterator().hasNext());
final DOMNotification domNotification = mock(DOMNotification.class);
doReturn("test").when(domNotification).toString();
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
ImmutableLeafNodeBuilder.<String>create().withNodeIdentifier(
new NodeIdentifier(TestModel.SHARDED_VALUE_2)).withValue("sharded value 2").build();
- final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> containerNodeBuilder =
+ final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> containerNodeBuilder =
ImmutableContainerNodeBuilder.create();
final ContainerNode containerNode =
containerNodeBuilder
// strip nodes we do not need since this listener doesn't have to be registered at the root of the DataTree
DataTreeCandidateNode modifiedChild = dataTree.prepare(modification).getRootNode();
for (final PathArgument pathArgument : listenerPath.getPathArguments()) {
- modifiedChild = modifiedChild.getModifiedChild(pathArgument);
+ modifiedChild = modifiedChild.getModifiedChild(pathArgument).orElse(null);
}
if (modifiedChild == null) {
*/
package org.opendaylight.mdsal.dom.store.inmemory;
-import com.google.common.collect.ImmutableList;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.Executor;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration;
import org.opendaylight.mdsal.dom.spi.shard.ChildShardContext;
import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
-import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager.BatchedInvoker;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataTreeShardChangePublisher.class);
- private static final BatchedInvoker<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
- MANAGER_INVOKER = (listener, notifications) -> {
- final DOMDataTreeChangeListener inst = listener.getInstance();
- if (inst != null) {
- inst.onDataTreeChanged(ImmutableList.copyOf(notifications));
- }
- };
-
private final QueuedNotificationManager<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
notificationManager;
final YangInstanceIdentifier rootPath,
final Map<DOMDataTreeIdentifier, ChildShardContext> childShards) {
super(dataTree, rootPath, childShards);
- notificationManager = QueuedNotificationManager.create(executor, MANAGER_INVOKER, maxQueueSize,
- "DataTreeChangeListenerQueueMgr");
+ notificationManager = QueuedNotificationManager.create(executor, (listener, notifications) -> {
+ // FIXME: we are not checking for listener being closed
+ listener.getInstance().onDataTreeChanged(notifications);
+ }, maxQueueSize, "DataTreeChangeListenerQueueMgr");
}
@Override
import static com.google.common.base.Preconditions.checkState;
-import com.google.common.collect.ImmutableList;
import java.util.Collection;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import org.opendaylight.mdsal.dom.spi.store.AbstractDOMStoreTreeChangePublisher;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
-import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager.BatchedInvoker;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.slf4j.LoggerFactory;
final class InMemoryDOMStoreTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher {
- private static final BatchedInvoker<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
- MANAGER_INVOKER = (listener, notifications) -> {
- final DOMDataTreeChangeListener inst = listener.getInstance();
- if (inst != null) {
- inst.onDataTreeChanged(ImmutableList.copyOf(notifications));
- }
- };
private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMStoreTreeChangePublisher.class);
private final QueuedNotificationManager<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
notificationManager;
InMemoryDOMStoreTreeChangePublisher(final ExecutorService listenerExecutor, final int maxQueueSize) {
- notificationManager = QueuedNotificationManager.create(listenerExecutor, MANAGER_INVOKER, maxQueueSize,
- "DataTreeChangeListenerQueueMgr");
+ notificationManager = QueuedNotificationManager.create(listenerExecutor, (listener, notifications) -> {
+ // FIXME: we are not checking for listener being closed
+ listener.getInstance().onDataTreeChanged(notifications);
+ }, maxQueueSize, "DataTreeChangeListenerQueueMgr");
}
private InMemoryDOMStoreTreeChangePublisher(final QueuedNotificationManager<
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-artifacts</artifactId>
- <version>2.1.8</version>
+ <version>3.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-mdsal-binding-api">
<feature name="odl-mdsal-binding-api">
- <feature version="[2.0.10,3)">odl-yangtools-data-api</feature>
+ <feature version="[3,4)">odl-yangtools-data-api</feature>
</feature>
</features>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-mdsal-binding-base">
<feature name="odl-mdsal-binding-base">
- <feature version="[2.0.10,3)">odl-yangtools-common</feature>
+ <feature version="[3,4)">odl-yangtools-common</feature>
</feature>
</features>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-mdsal-binding-runtime">
<feature name="odl-mdsal-binding-runtime">
<feature version="[5,6)">odl-javassist-3</feature>
- <feature version="[2.1,3)">odl-yangtools-data</feature>
- <feature version="[2.1,3)">odl-yangtools-parser</feature>
+ <feature version="[3,4)">odl-yangtools-data</feature>
+ <feature version="[3,4)">odl-yangtools-parser</feature>
</feature>
</features>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-mdsal-common">
<feature name="odl-mdsal-common">
- <feature version="[2.0.10,3)">odl-yangtools-common</feature>
+ <feature version="[3,4)">odl-yangtools-common</feature>
</feature>
</features>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-mdsal-dom-api">
<feature name="odl-mdsal-dom-api">
- <feature version="[2.0.10,3)">odl-yangtools-data-api</feature>
+ <feature version="[3,4)">odl-yangtools-data-api</feature>
</feature>
</features>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-mdsal-dom-broker">
<feature name="odl-mdsal-dom-broker">
<feature version="[5,6)">odl-lmax-3</feature>
- <feature version="[2.1,3)">odl-yangtools-data</feature>
- <feature version="[2.1,3)">odl-yangtools-parser</feature>
+ <feature version="[3,4)">odl-yangtools-data</feature>
+ <feature version="[3,4)">odl-yangtools-parser</feature>
</feature>
</features>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-mdsal-eos-common">
<feature name="odl-mdsal-eos-common">
- <feature version="[2.0.10,3)">odl-yangtools-data-api</feature>
+ <feature version="[3,4)">odl-yangtools-data-api</feature>
</feature>
</features>
<modelVersion>4.0.0</modelVersion>
<groupId>org.opendaylight.mdsal.model</groupId>
<artifactId>ietf-type-util</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.0</version>
<packaging>bundle</packaging>
<dependencies>