X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-model-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fmodel%2Frepo%2Fspi%2FPotentialSchemaSource.java;h=57e69ee67544bc3e614f963af158fac050eda29a;hb=fdb2fcbad36160d53a90e23e00f030a155645632;hp=fae44679e2a750b413980003dddaa93b94d5cc25;hpb=df568194d106efa63c3138f0cc699dd53735cf44;p=yangtools.git diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/spi/PotentialSchemaSource.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/spi/PotentialSchemaSource.java index fae44679e2..57e69ee675 100644 --- a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/spi/PotentialSchemaSource.java +++ b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/spi/PotentialSchemaSource.java @@ -3,13 +3,15 @@ * * 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/eplv10.html + * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.yangtools.yang.model.repo.spi; import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; +import org.opendaylight.yangtools.objcache.ObjectCache; +import org.opendaylight.yangtools.objcache.ObjectCacheFactory; import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation; import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; @@ -62,6 +64,7 @@ public final class PotentialSchemaSource { } } + private static final ObjectCache CACHE = ObjectCacheFactory.getObjectCache(PotentialSchemaSource.class); private final Class representation; private final SourceIdentifier sourceIdentifier; private final int cost; @@ -73,10 +76,19 @@ public final class PotentialSchemaSource { this.cost = cost; } - public static final PotentialSchemaSource create(final SourceIdentifier sourceIdentifier, final Class representation, final int cost) { + public static PotentialSchemaSource create(final SourceIdentifier sourceIdentifier, final Class representation, final int cost) { return new PotentialSchemaSource<>(sourceIdentifier, representation, cost); } + /** + * Return a cached reference to an object equal to this object. + * + * @return A potentially shared reference, not guaranteed to be unique. + */ + public PotentialSchemaSource cachedReference() { + return CACHE.getReference(this); + } + public SourceIdentifier getSourceIdentifier() { return sourceIdentifier; }