2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.model.repo.api;
10 import com.google.common.annotations.Beta;
11 import com.google.common.collect.ImmutableList;
12 import com.google.common.util.concurrent.FluentFuture;
13 import com.google.common.util.concurrent.ListenableFuture;
14 import org.opendaylight.yangtools.util.concurrent.FluentFutures;
17 * A filter of schema sources. This is used to restrict which sources representation instances are allowed
18 * to participate in construction of a schema context. This allows, for example, to create an non-shared island,
19 * or require the sources to be certified before use.
22 public interface SchemaSourceFilter {
24 * A {@link SchemaSourceFilter} which accepts any schema source it is presented with.
26 SchemaSourceFilter ALWAYS_ACCEPT = new SchemaSourceFilter() {
27 private final Iterable<Class<? extends SchemaSourceRepresentation>> representations =
28 ImmutableList.of(SchemaSourceRepresentation.class);
31 public Iterable<Class<? extends SchemaSourceRepresentation>> supportedRepresentations() {
32 return representations;
36 public FluentFuture<Boolean> apply(final SchemaSourceRepresentation schemaSource) {
37 return FluentFutures.immediateTrueFluentFuture();
42 * Get the representations this filter supports. A schema source is translated
43 * into one of these representations before it is presented for filtering.
45 * @return Set of supported representations.
47 Iterable<Class<? extends SchemaSourceRepresentation>> supportedRepresentations();
50 * Check if a particular schema source is acceptable to the filter. The process
51 * of checking may be asynchronous, but at some point it needs to produce an
52 * affirmative or negative answer before the schema context construction can
55 * @param schemaSource Schema source to be filtered
56 * @return Promise of a filtering decision. The result should be {@link Boolean#TRUE}
57 * if the source is acceptable.
59 // FIXME: 3.0.0: require FluentFuture
60 ListenableFuture<Boolean> apply(SchemaSourceRepresentation schemaSource);