Merge branch 'master' of ../controller
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / repo / util / AbstractSchemaSourceRegistration.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.model.repo.util;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.base.MoreObjects.ToStringHelper;
13 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
14 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
15 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
16 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
17 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistration;
18
19 public abstract class AbstractSchemaSourceRegistration<T extends SchemaSourceRepresentation>
20         extends AbstractObjectRegistration<PotentialSchemaSource<T>> implements SchemaSourceRegistration<T> {
21     private final SchemaSourceProvider<?> provider;
22
23     protected AbstractSchemaSourceRegistration(final SchemaSourceProvider<?> provider,
24             final PotentialSchemaSource<T> source) {
25         super(source);
26         this.provider = requireNonNull(provider);
27     }
28
29     public final SchemaSourceProvider<?> getProvider() {
30         return provider;
31     }
32
33     @Override
34     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
35         return super.addToStringAttributes(toStringHelper).add("provider", provider);
36     }
37 }