DeclaredStatements can contain default implementations
[yangtools.git] / yang / yang-parser-spi / src / main / java / org / opendaylight / yangtools / yang / parser / spi / meta / AbstractDeclaredStatement.java
index 185888e099eef34cdc5dc79a698ea6cf9b2c2e98..cd10de86ca09558d6de0ac9899f5c6fdfb2a5f8e 100644 (file)
@@ -41,8 +41,16 @@ public abstract class AbstractDeclaredStatement<A> implements DeclaredStatement<
             StmtContext::buildDeclared));
     }
 
+    /**
+     * Find first declared substatement of a particular type.
+     *
+     * @param type {@link DeclaredStatement} type
+     * @return First effective substatement, or null if no match is found.
+     * @deprecated Use {@link #findFirstDeclaredSubstatement(Class)} instead.
+     */
+    @Deprecated
     protected final <S extends DeclaredStatement<?>> S firstDeclared(final Class<S> type) {
-        return substatements.stream().filter(type::isInstance).findFirst().map(type::cast).orElse(null);
+        return findFirstDeclaredSubstatement(type).orElse(null);
     }
 
     @Override
@@ -73,7 +81,17 @@ public abstract class AbstractDeclaredStatement<A> implements DeclaredStatement<
         return source;
     }
 
+    /**
+     * Returns collection of explicitly declared child statements, while preserving its original ordering from original
+     * source.
+     *
+     * @param type {@link DeclaredStatement} type
+     * @return Collection of statements, which were explicitly declared in source of model.
+     * @throws NullPointerException if {@code type} is null
+     * @deprecated Use {@link #declaredSubstatements(Class)} instead.
+     */
+    @Deprecated
     protected final <S extends DeclaredStatement<?>> Collection<? extends S> allDeclared(final Class<S> type) {
-        return Collections2.transform(Collections2.filter(substatements, type::isInstance), type::cast);
+        return declaredSubstatements(type);
     }
 }