X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-model-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fmodel%2Frepo%2Futil%2FAbstractSchemaSourceCache.java;h=f7bc8f73c9471e77f8c7a05e55e922d1196771eb;hb=918cb5c770f4c2309330cc95f8cb4bcc2ecd4775;hp=b665f43c58d0c86fdd832444a561beeb5df4bdfc;hpb=7e571648e27863df485ac2d709d00cf0e5f9f6fe;p=yangtools.git diff --git a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/repo/util/AbstractSchemaSourceCache.java b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/repo/util/AbstractSchemaSourceCache.java index b665f43c58..f7bc8f73c9 100644 --- a/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/repo/util/AbstractSchemaSourceCache.java +++ b/yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/repo/util/AbstractSchemaSourceCache.java @@ -7,7 +7,7 @@ */ package org.opendaylight.yangtools.yang.model.repo.util; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation; import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; @@ -26,15 +26,17 @@ import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry; * * @param Cached schema source type. */ -public abstract class AbstractSchemaSourceCache implements SchemaSourceListener, SchemaSourceProvider { +public abstract class AbstractSchemaSourceCache + implements SchemaSourceListener, SchemaSourceProvider { private final SchemaSourceRegistry consumer; private final Class representation; private final Costs cost; - protected AbstractSchemaSourceCache(final SchemaSourceRegistry consumer, final Class representation, final Costs cost) { - this.consumer = Preconditions.checkNotNull(consumer); - this.representation = Preconditions.checkNotNull(representation); - this.cost = Preconditions.checkNotNull(cost); + protected AbstractSchemaSourceCache(final SchemaSourceRegistry consumer, final Class representation, + final Costs cost) { + this.consumer = requireNonNull(consumer); + this.representation = requireNonNull(representation); + this.cost = requireNonNull(cost); } /** @@ -58,16 +60,15 @@ public abstract class AbstractSchemaSourceCache register(final SourceIdentifier sourceIdentifier) { - final PotentialSchemaSource src = PotentialSchemaSource.create(sourceIdentifier, representation, cost.getValue()); + final PotentialSchemaSource src = PotentialSchemaSource.create(sourceIdentifier, representation, + cost.getValue()); return consumer.registerSchemaSource(this, src); } @Override public void schemaSourceEncountered(final SchemaSourceRepresentation source) { if (representation.isAssignableFrom(source.getType())) { - @SuppressWarnings("unchecked") - final T src = (T)source; - offer(src); + offer(representation.cast(source)); } }