Bug 3670 (part 1/5): Use of new statement parser in yang-maven-plugin
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / EffectiveStatementBase.java
index b0a342916656fcf8763365144d3da78b075e709e..5b0c94cc98d9c97b31c63a787375d56950150bcc 100644 (file)
@@ -165,4 +165,19 @@ abstract public class EffectiveStatementBase<A, D extends DeclaredStatement<A>>
         }
         return result;
     }
+
+    protected final <R> R firstSubstatementOfType(Class<?> type,
+            Class<R> returnType) {
+        R result = null;
+        try {
+            result = returnType.cast(Iterables.find(
+                    substatements,
+                    Predicates.and(Predicates.instanceOf(type),
+                            Predicates.instanceOf(returnType))));
+        } catch (NoSuchElementException e) {
+            result = null;
+        }
+        return result;
+    }
+
 }