Migrate users of Optional.get()
[controller.git] / opendaylight / md-sal / samples / clustering-test-app / provider / src / main / java / org / opendaylight / controller / clustering / it / provider / CarEntryDataTreeCommitCohort.java
index 0d442c1b432afc535023185aa713270b193750fd..c3294bd6c72af2bf716b6316b0de5e8a3d90dc9f 100644 (file)
@@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author Thomas Pantelis
  */
-public class CarEntryDataTreeCommitCohort implements DOMDataTreeCommitCohort {
+public final class CarEntryDataTreeCommitCohort implements DOMDataTreeCommitCohort {
     private static final Logger LOG = LoggerFactory.getLogger(CarEntryDataTreeCommitCohort.class);
 
     private static final QName YEAR_QNAME = QName.create(Cars.QNAME, "year").intern();
@@ -56,13 +56,13 @@ public class CarEntryDataTreeCommitCohort implements DOMDataTreeCommitCohort {
             // ModificationType because dataAfter will not be present. Also dataAfter *should* always contain a
             // MapEntryNode but we verify anyway.
             if (dataAfter.isPresent()) {
-                final NormalizedNode normalizedNode = dataAfter.get();
+                final NormalizedNode normalizedNode = dataAfter.orElseThrow();
                 Verify.verify(normalizedNode instanceof DataContainerNode,
                         "Expected type DataContainerNode, actual was %s", normalizedNode.getClass());
                 DataContainerNode entryNode = (DataContainerNode) normalizedNode;
                 final Optional<DataContainerChild> possibleYear = entryNode.findChildByArg(YEAR_NODE_ID);
                 if (possibleYear.isPresent()) {
-                    final Number year = (Number) possibleYear.get().body();
+                    final Number year = (Number) possibleYear.orElseThrow().body();
 
                     LOG.info("year is {}", year);