blob: fbda7227fe7eefbf67538e40e7a2448ced044356 [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
19/**
20 * Base abstract factory for creating configurations for the specified subject type.
21 *
22 * @param <S> subject class
23 */
24public abstract class ConfigFactory<S> {
25
26 private final Class<S> subjectClass;
27 private final String key;
28
29 /**
30 * Creates a new configuration factory for the specified class of subjects
31 * and bound to the given subject configuration key.
32 *
33 * @param subjectClass subject class
34 * @param key subject configuration key
35 */
36 protected ConfigFactory(Class<S> subjectClass, String key) {
37 this.subjectClass = subjectClass;
38 this.key = key;
39 }
40
41 /**
42 * Returns the class of the subject to which this factory applies.
43 *
44 * @return subject type
45 */
46 public Class<S> subjectClass() {
47 return subjectClass;
48 }
49
50 /**
51 * Returns the key to which produced configurations should be bound.
52 *
53 * @return subject configuration key
54 */
55 public String key() {
56 return key;
57 }
58
59 /**
60 * Creates a new but uninitialized configuration. Framework will initialize
61 * the configuration via {@link Config#init} method.
62 *
63 * @return new uninitialized configuration
64 */
65 public abstract Config<S> createConfig();
66
67}