package org.opendaylight.yangtools.yang.model.util.repo; import com.google.common.base.Optional; import com.google.common.base.Preconditions; import org.opendaylight.yangtools.concepts.Delegator; /** * * Utility Source Provider implementation which uses delegate to retrieve * sources and transformation function to convert sources to different * representation. * * * @param * Representation of schema sources used by delegate * @param * Representation of schema sources exposed by this provider * * @deprecated Replaced with {@link org.opendaylight.yangtools.yang.model.repo.util.SchemaSourceTransformer} */ @Deprecated public final class TransformingSourceProvider implements // AdvancedSchemaSourceProvider, Delegator> { private final AdvancedSchemaSourceProvider delegate; private final SchemaSourceTransformation transformation; /** * Creates instance of transforming schema source provider which uses * supplied delegate to retrieve sources and transformation to change * sources to different representation. * * @param delegate * Delegate which provides sources. * @param transformation * Transformation function which converts sources * @return Instance of TransformingSourceProvider * @throws NullPointerException * if any of arguments is null. */ public static final TransformingSourceProvider create(final AdvancedSchemaSourceProvider delegate, final SchemaSourceTransformation transformation) { return new TransformingSourceProvider<>(delegate, transformation); } private TransformingSourceProvider(final AdvancedSchemaSourceProvider delegate, final SchemaSourceTransformation transformation) { this.delegate = Preconditions.checkNotNull(delegate, "delegate must not be null"); this.transformation = Preconditions.checkNotNull(transformation, "transformation must not be null"); } @Override public AdvancedSchemaSourceProvider getDelegate() { return delegate; } @Override public Optional getSchemaSource(final SourceIdentifier sourceIdentifier) { Optional potentialSource = getDelegate().getSchemaSource(sourceIdentifier); if (potentialSource.isPresent()) { I inputSource = potentialSource.get(); return Optional. of(transformation.transform(inputSource)); } return Optional.absent(); } @Override public Optional getSchemaSource(final String moduleName, final Optional revision) { return getSchemaSource(SourceIdentifier.create(moduleName, revision)); } }