import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import java.util.Collection;
+import java.util.Set;
import java.util.function.Predicate;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.model.api.stmt.MinElementsStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.PresenceStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.IfFeaturePredicates;
import org.opendaylight.yangtools.yang.parser.spi.source.SupportedFeaturesNamespace;
import org.opendaylight.yangtools.yang.parser.spi.source.SupportedFeaturesNamespace.SupportedFeatures;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.RootStatementContext;
break;
}
- final Predicate<QName> isFeatureSupported = stmtContext.getFromNamespace(SupportedFeaturesNamespace.class,
+ final Set<QName> supportedFeatures = stmtContext.getFromNamespace(SupportedFeaturesNamespace.class,
SupportedFeatures.SUPPORTED_FEATURES);
- if (IfFeaturePredicates.ALL_FEATURES.equals(isFeatureSupported)) {
+ /*
+ * If set of supported features has not been provided, all features are
+ * supported by default.
+ */
+ if (supportedFeatures == null) {
stmtContext.setSupportedByFeatures(true);
return true;
}
- final boolean result = checkFeatureSupport(stmtContext, isFeatureSupported);
+ final boolean result = checkFeatureSupport(stmtContext, supportedFeatures);
stmtContext.setSupportedByFeatures(result);
return result;
}
private static boolean checkFeatureSupport(final StmtContext.Mutable<?, ?, ?> stmtContext,
- final Predicate<QName> isFeatureSupported) {
+ final Set<QName> supportedFeatures) {
boolean isSupported = false;
boolean containsIfFeature = false;
for (final StatementContextBase<?, ?, ?> stmt : stmtContext.declaredSubstatements()) {
if (YangStmtMapping.IF_FEATURE.equals(stmt.getPublicDefinition())) {
containsIfFeature = true;
- if (isFeatureSupported.test((QName) stmt.getStatementArgument())) {
+ if (((Predicate<Set<QName>>) stmt.getStatementArgument()).test(supportedFeatures)) {
isSupported = true;
} else {
isSupported = false;