c548a98e28db5c4863f66a8b0d8619b9dabd121f
[ccsdk/features.git] /
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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
15  * the License.
16  * ============LICENSE_END==========================================================================
17  ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.database.types;
19
20 import java.util.Collections;
21 import java.util.Map;
22 import org.eclipse.jdt.annotation.Nullable;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.maintenance.mode.g.filter.Definition;
24 import org.opendaylight.yangtools.yang.binding.Augmentation;
25 import org.opendaylight.yangtools.yang.binding.DataContainer;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28
29 import com.fasterxml.jackson.annotation.JsonIgnore;
30 import com.fasterxml.jackson.annotation.JsonProperty;
31
32 public class EsMaintenanceFilterDefinition implements Definition {
33
34     private static final Logger LOG = LoggerFactory.getLogger(EsMaintenanceFilterDefinition.class);
35     private static final String ALL = "";
36
37     //yang tools
38     @JsonIgnore
39     private final Map<java.lang.Class<? extends Augmentation<Definition>>, Augmentation<Definition>> augmentation = Collections.emptyMap();
40
41     private String objectIdRef = ALL;
42     private String problem = ALL;
43
44     public EsMaintenanceFilterDefinition() {
45     }
46
47     public EsMaintenanceFilterDefinition(Definition definition) {
48         objectIdRef = definition.getObjectIdRef();
49         problem = definition.getProblem();
50     }
51
52     @Override
53     @JsonProperty("object-id-ref")
54     public String getObjectIdRef() {
55         return objectIdRef;
56     }
57
58     @JsonProperty("object-id-ref")
59     public void setObjectIdRef(String objectIdRef) {
60         this.objectIdRef = objectIdRef == null ? ALL : objectIdRef;
61     }
62
63     @Override
64     @JsonProperty("problem")
65     public String getProblem() {
66         return problem;
67     }
68
69     @JsonProperty("problem")
70     public void setProblem(String pProblem) {
71         this.problem = pProblem == null ? ALL : pProblem;
72     }
73
74     public boolean appliesToObjectReference(String pObjectIdRef, String pProblem) {
75         boolean res = (pObjectIdRef.isEmpty() || pObjectIdRef.contains(pObjectIdRef)) && (pProblem.isEmpty() || pProblem.contains(pProblem));
76         LOG.debug("Check result applies {}: {} {} against: {}",res, pObjectIdRef, pProblem, this);
77         return res;
78     }
79
80     @Override
81     public String toString() {
82         return "EsMaintenanceFilterDefinition [objectIdRef=" + objectIdRef + ", problem=" + problem + "]";
83     }
84
85     @Override
86     public Class<? extends DataContainer> getImplementedInterface() {
87         return Definition.class;
88     }
89
90     @Override
91     public <E extends Augmentation<Definition>> @Nullable E augmentation(Class<E> augmentationType) {
92         return null;
93     }
94
95
96
97 }