return;
}
- final DataTreeCandidateNode modifiedAttrs = table.getModifiedChild(ATTRIBUTES_NID);
- if (modifiedAttrs != null) {
+ table.getModifiedChild(ATTRIBUTES_NID).ifPresent(modifiedAttrs -> {
final YangInstanceIdentifier effAttrsPath = effectiveTablePath.node(ATTRIBUTES_NID);
final Optional<NormalizedNode<?, ?>> optAttrsAfter = modifiedAttrs.getDataAfter();
if (optAttrsAfter.isPresent()) {
} else {
tx.delete(LogicalDatastoreType.OPERATIONAL, effAttrsPath);
}
- }
+ });
- final DataTreeCandidateNode modifiedRoutes = table.getModifiedChild(ROUTES_NID);
- if (modifiedRoutes != null) {
+ table.getModifiedChild(ROUTES_NID).ifPresent(modifiedRoutes -> {
final RIBSupport<?, ?, ?, ?> ribSupport = ribContext.getRibSupport();
switch (modifiedRoutes.getModificationType()) {
case APPEARED:
LOG.warn("Ignoring modified routes {}", modifiedRoutes);
break;
}
- }
+ });
}
private void writeTable(final DOMDataWriteTransaction tx, final RIBSupportContext ribContext,
@Override
public final Collection<DataTreeCandidateNode> changedRoutes(final DataTreeCandidateNode routes) {
- final DataTreeCandidateNode myRoutes = routes.getModifiedChild(this.routesContainerIdentifier);
- if (myRoutes == null) {
- return Collections.emptySet();
- }
- final DataTreeCandidateNode routesMap = myRoutes.getModifiedChild(routeNid());
- if (routesMap == null) {
- return Collections.emptySet();
- }
- // Well, given the remote possibility of augmentation, we should perform a filter here,
- // to make sure the type matches what routeType() reports.
- return routesMap.getChildNodes();
+ return routes.getModifiedChild(this.routesContainerIdentifier)
+ .flatMap(myRoutes -> myRoutes.getModifiedChild(routeNid()))
+ // Well, given the remote possibility of augmentation, we should perform a filter here,
+ // to make sure the type matches what routeType() reports.
+ .map(DataTreeCandidateNode::getChildNodes)
+ .orElse(Collections.emptySet());
}
@Override
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
this.subTree = Mockito.mock(DataTreeCandidateNode.class);
final DataTreeCandidateNode emptyNode = Mockito.mock(DataTreeCandidateNode.class);
final DataTreeCandidateNode node = Mockito.mock(DataTreeCandidateNode.class);
- doReturn(null).when(this.emptyTree).getModifiedChild(IPV4_ROUTES_IDENTIFIER);
+ doReturn(Optional.empty()).when(this.emptyTree).getModifiedChild(IPV4_ROUTES_IDENTIFIER);
- doReturn(emptyNode).when(this.emptySubTree).getModifiedChild(IPV4_ROUTES_IDENTIFIER);
- doReturn(null).when(emptyNode).getModifiedChild(new NodeIdentifier(Ipv4Route.QNAME));
+ doReturn(Optional.of(emptyNode)).when(this.emptySubTree).getModifiedChild(IPV4_ROUTES_IDENTIFIER);
+ doReturn(Optional.empty()).when(emptyNode).getModifiedChild(new NodeIdentifier(Ipv4Route.QNAME));
- doReturn(node).when(this.subTree).getModifiedChild(IPV4_ROUTES_IDENTIFIER);
- doReturn(node).when(node).getModifiedChild(new NodeIdentifier(Ipv4Route.QNAME));
+ doReturn(Optional.of(node)).when(this.subTree).getModifiedChild(IPV4_ROUTES_IDENTIFIER);
+ doReturn(Optional.of(node)).when(node).getModifiedChild(new NodeIdentifier(Ipv4Route.QNAME));
final Collection<DataTreeCandidateNode> emptyCollection = new HashSet<>();
doReturn(emptyCollection).when(node).getChildNodes();
<configuration>
<propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
</configuration>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>checkstyle-logging</artifactId>
- <version>2.1.8</version>
- </dependency>
- </dependencies>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.annotation.concurrent.GuardedBy;
-import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
.findDataSchemaNode(this.schemaContext, config.getSchemaPath());
try (XmlParserStream xmlParser = XmlParserStream.create(streamWriter, this.schemaContext, schemaNode)) {
xmlParser.parse(reader);
- } catch (final URISyntaxException | XMLStreamException | IOException | ParserConfigurationException
- | SAXException e) {
+ } catch (final URISyntaxException | XMLStreamException | IOException | SAXException e) {
LOG.warn("Failed to parse xml", e);
} finally {
reader.close();
-->
<features name="odl-bgpcep-bgp-dependencies-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<feature name="odl-bgpcep-bgp-dependencies" version="${project.version}">
- <feature version="[2.1,3)">odl-yangtools-data-api</feature>
+ <feature version="[3,4)">odl-yangtools-data-api</feature>
</feature>
</features>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-artifacts</artifactId>
- <version>2.1.8</version>
+ <version>3.0.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>checkstyle-logging</artifactId>
- <version>2.1.8</version>
- </dependency>
- </dependencies>
<configuration>
<propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
</configuration>
<configuration>
<propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
</configuration>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>checkstyle-logging</artifactId>
- <version>2.1.8</version>
- </dependency>
- </dependencies>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>