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=2d7347cc4699259035504a7d0cc6c43720511c3b;hpb=24b697d9f464bf5557796c2a7a6bfc5c14f50796;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 2d7347cc46..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 @@ -1,12 +1,13 @@ /* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ 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; @@ -25,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); } /** @@ -57,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)); } }