blob: fcf24bc6e782f3301114dde4510d0fedfd9fc2b8 [file] [log] [blame]
HIGUCHI Yutad9fe3a32015-11-24 18:52:25 -08001/*
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 */
16package org.onosproject.net.config.basics;
17
18import org.onosproject.net.config.Config;
19
20/**
21 * Base abstraction for configuring feature on subject.
22 *
23 * @param <S> Subject type
24 */
25public abstract class BasicFeatureConfig<S> extends Config<S> {
26
27 private static final String ENABLED = "enabled";
28
29 private final boolean defaultValue;
30
31 protected BasicFeatureConfig(boolean defaultValue) {
32 this.defaultValue = defaultValue;
33 }
34
35 /**
36 * Indicates whether the feature for the subject is enabled.
37 *
38 * @return true if feature is enabled
39 */
40 public boolean enabled() {
41 return get(ENABLED, defaultValue);
42 }
43
44 /**
45 * Specifies whether the feature for the subject is to be enabled.
46 *
47 * @param enabled true to enable; false to disable; null to clear
48 * @return self
49 */
50 public BasicFeatureConfig<S> enabled(Boolean enabled) {
51 return (BasicFeatureConfig<S>) setOrClear(ENABLED, enabled);
52 }
53
54}