TCA: Replace any openecomp reference by onap
[dcaegen2/analytics/tca.git] / dcae-analytics-model / src / main / java / org / onap / dcae / apod / analytics / model / domain / policy / tca / Direction.java
1 /*
2  * ===============================LICENSE_START======================================
3  *  dcae-analytics
4  * ================================================================================
5  *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *   You may obtain a copy of the License at
10  *
11  *          http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *  Unless required by applicable law or agreed to in writing, software
14  *  distributed under the License is distributed on an "AS IS" BASIS,
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *  See the License for the specific language governing permissions and
17  *  limitations under the License.
18  *  ============================LICENSE_END===========================================
19  */
20
21 package org.onap.dcae.apod.analytics.model.domain.policy.tca;
22
23 import java.math.BigDecimal;
24
25 import javax.annotation.Nonnull;
26
27 /**
28  * <p>
29  *     Enum for Threshold Direction
30  * </p>
31  * @author Rajiv Singla . Creation Date: 11/5/2016.
32  */
33 public enum Direction implements TCAPolicyModel {
34
35     EQUAL {
36         @Override
37         public Boolean operate(@Nonnull BigDecimal value1, @Nonnull BigDecimal value2) {
38             return value1.compareTo(value2) == 0;
39         }
40     },
41     LESS {
42         @Override
43         public Boolean operate(@Nonnull BigDecimal value1, @Nonnull BigDecimal value2) {
44             return value1.compareTo(value2) < 0;
45         }
46     },
47     LESS_OR_EQUAL {
48         @Override
49         public Boolean operate(@Nonnull BigDecimal value1, @Nonnull BigDecimal value2) {
50             return value1.compareTo(value2) <= 0;
51         }
52     },
53     GREATER {
54         @Override
55         public Boolean operate(@Nonnull BigDecimal value1, @Nonnull BigDecimal value2) {
56             return value1.compareTo(value2) > 0;
57         }
58     },
59     GREATER_OR_EQUAL {
60         @Override
61         public Boolean operate(@Nonnull BigDecimal value1, @Nonnull BigDecimal value2) {
62             return value1.compareTo(value2) >= 0;
63         }
64     };
65
66     /**
67      * Configure logic for a particular Direction
68      *
69      * @param value1 left operand for Direction operation
70      * @param value2 right operand for Direction operation
71      *
72      * @return result of operation for the direction logic
73      */
74     public abstract Boolean operate(@Nonnull BigDecimal value1, @Nonnull BigDecimal value2);
75
76 }