1 /*******************************************************************************
2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
17 ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl;
20 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile;
21 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.IniConfigurationFile.ConfigurationException;
22 import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.BaseSubConfig;
23 import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.ISubConfigHandler;
25 public class ToggleAlarmConfig extends BaseSubConfig{
27 private static final String SECTION_MARKER_TA = "toggleAlarmFilter";
28 private static final String PROPERTY_KEY_ENABLED = "taEnabled";
29 private static final String PROPERTY_KEY_DELAY = "taDelay";
31 private static final boolean DEFAULT_VALUE_ENABLED = true;
32 private static final long DEFAULT_VALUE_DELAY = 3000; //in ms
33 private static ToggleAlarmConfig taConfig;
34 private boolean enabled;
37 public boolean isEnabled() {
40 public long getDelay() {
43 private ToggleAlarmConfig() {
45 this.enabled = DEFAULT_VALUE_ENABLED;
46 this.delay=DEFAULT_VALUE_DELAY;
48 public ToggleAlarmConfig(IniConfigurationFile config, ISubConfigHandler configHandler) throws ConfigurationException {
49 this(config, configHandler, true);
52 public ToggleAlarmConfig(IniConfigurationFile config, ISubConfigHandler configHandler, boolean save)
53 throws ConfigurationException {
55 super(config, configHandler, SECTION_MARKER_TA);
57 this.enabled = this.getBoolean(PROPERTY_KEY_ENABLED, DEFAULT_VALUE_ENABLED);
58 this.delay = this.getLong(PROPERTY_KEY_DELAY,DEFAULT_VALUE_DELAY);
60 config.setProperty(SECTION_MARKER_TA + "." + PROPERTY_KEY_ENABLED, this.enabled);
61 config.setProperty(SECTION_MARKER_TA + "." + PROPERTY_KEY_DELAY, this.delay);
68 public int hashCode() {
71 result = prime * result + (int) (delay ^ delay >>> 32);
72 result = prime * result + (enabled ? 1231 : 1237);
76 public boolean equals(Object obj) {
83 if (getClass() != obj.getClass()) {
86 ToggleAlarmConfig other = (ToggleAlarmConfig) obj;
87 if (delay != other.delay) {
90 if (enabled != other.enabled) {
97 public String toString() {
98 return "ToggleAlarmConfig [enabled=" + enabled + ", delay=" + delay + "]";
101 public static ToggleAlarmConfig getDefaultConfiguration() {
102 ToggleAlarmConfig c = new ToggleAlarmConfig();
103 c.enabled = DEFAULT_VALUE_ENABLED;
104 c.delay = DEFAULT_VALUE_DELAY;
107 public static boolean isInstantiated() {
108 return taConfig != null;
111 public static ToggleAlarmConfig getTa(IniConfigurationFile config, ISubConfigHandler configHandler) {
112 if (taConfig == null) {
114 taConfig = new ToggleAlarmConfig(config, configHandler);
115 } catch (ConfigurationException e) {
116 taConfig = ToggleAlarmConfig.getDefaultConfiguration();
122 public static ToggleAlarmConfig reload() {
123 if (taConfig == null) {
126 ToggleAlarmConfig tmpConfig;
128 tmpConfig = new ToggleAlarmConfig(taConfig.getConfig(), taConfig.getConfigHandler(), false);
129 } catch (ConfigurationException e) {
130 tmpConfig = ToggleAlarmConfig.getDefaultConfiguration();
132 taConfig = tmpConfig;
136 public static void clear() {