Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 1 | /* |
| 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 Vachuska | d24aa7f | 2015-05-14 18:37:54 -0700 | [diff] [blame] | 16 | package org.onosproject.incubator.net.config; |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 17 | |
| 18 | |
Thomas Vachuska | e2b7e7e | 2015-05-20 11:11:31 -0700 | [diff] [blame] | 19 | import com.google.common.annotations.Beta; |
| 20 | |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 21 | /** |
| 22 | * Base abstract factory for creating configurations for the specified subject type. |
| 23 | * |
| 24 | * @param <S> subject class |
| 25 | */ |
Thomas Vachuska | e2b7e7e | 2015-05-20 11:11:31 -0700 | [diff] [blame] | 26 | @Beta |
Thomas Vachuska | f0e1fae | 2015-04-24 00:51:51 -0700 | [diff] [blame] | 27 | public 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 | } |