blob: 37b51fd24c54b5f452da22484461181cc321820a [file] [log] [blame]
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Thomas Vachuskad24aa7f2015-05-14 18:37:54 -070016package org.onosproject.incubator.net.config;
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070017
18
Thomas Vachuskae2b7e7e2015-05-20 11:11:31 -070019import com.google.common.annotations.Beta;
20
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070021/**
22 * Base abstract factory for creating configurations for the specified subject type.
23 *
24 * @param <S> subject class
25 */
Thomas Vachuskae2b7e7e2015-05-20 11:11:31 -070026@Beta
Thomas Vachuskaf0e1fae2015-04-24 00:51:51 -070027public abstract class ConfigFactory<S> {
28
29 private final Class<S> subjectClass;
30 private final String key;
31
32 /**
33 * Creates a new configuration factory for the specified class of subjects
34 * and bound to the given subject configuration key.
35 *
36 * @param subjectClass subject class
37 * @param key subject configuration key
38 */
39 protected ConfigFactory(Class<S> subjectClass, String key) {
40 this.subjectClass = subjectClass;
41 this.key = key;
42 }
43
44 /**
45 * Returns the class of the subject to which this factory applies.
46 *
47 * @return subject type
48 */
49 public Class<S> subjectClass() {
50 return subjectClass;
51 }
52
53 /**
54 * Returns the key to which produced configurations should be bound.
55 *
56 * @return subject configuration key
57 */
58 public String key() {
59 return key;
60 }
61
62 /**
63 * Creates a new but uninitialized configuration. Framework will initialize
64 * the configuration via {@link Config#init} method.
65 *
66 * @return new uninitialized configuration
67 */
68 public abstract Config<S> createConfig();
69
70}