Use lombok in xacml-pdp
[policy/xacml-pdp.git] / main / src / main / java / org / onap / policy / pdpx / main / rest / XacmlPdpStatisticsManager.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.pdpx.main.rest;
22
23 import lombok.Getter;
24 import lombok.Setter;
25
26 /**
27  * Class to hold statistical data for xacmlPdp component.
28  *
29  */
30 @Getter
31 public class XacmlPdpStatisticsManager {
32     @Getter
33     @Setter
34     private static XacmlPdpStatisticsManager current = null;
35
36     private long totalPolicyTypesCount;
37     private long totalPoliciesCount;
38     private long errorCount;
39     private long permitDecisionsCount;
40     private long denyDecisionsCount;
41     private long indeterminantDecisionsCount;
42     private long notApplicableDecisionsCount;
43
44     /**
45      * Method to set the xacml pdp total policy types count. This
46      * doesn't really increment, it depends on the applications
47      * that are loaded. Which can be dynamic.
48      *
49      * @return the total
50      */
51     public long setTotalPolicyTypesCount(long newCount) {
52         totalPolicyTypesCount = newCount;
53         return totalPolicyTypesCount;
54     }
55
56     /**
57      * Method to set the xacml pdp total policies count. This
58      * doesn't really increment, it depends on the applications
59      * that are loaded. Which can be dynamic.
60      *
61      * @return the total
62      */
63     public long setTotalPolicyCount(long newCount) {
64         totalPoliciesCount = newCount;
65         return totalPoliciesCount;
66     }
67
68     /**
69      * Method to update the number of error decisions.
70      *
71      * @return the errorDecisionsCount
72      */
73     public long updateErrorCount() {
74         return ++errorCount;
75     }
76
77     /**
78      * Method to update the number of permit decisions.
79      *
80      * @return the permitDecisionsCount
81      */
82     public long updatePermitDecisionsCount() {
83         return ++permitDecisionsCount;
84     }
85
86     /**
87      * Method to update the number of deny decisions.
88      *
89      * @return the denyDecisionsCount
90      */
91     public long updateDenyDecisionsCount() {
92         return ++denyDecisionsCount;
93     }
94
95     /**
96      * Method to update the number of indeterminant decisions.
97      *
98      * @return the indeterminantDecisionsCount
99      */
100     public long updateIndeterminantDecisionsCount() {
101         return ++indeterminantDecisionsCount;
102     }
103
104     /**
105      * Method to update the number of not applicable decisions.
106      *
107      * @return the notApplicableDecisionsCount
108      */
109     public long updateNotApplicableDecisionsCount() {
110         return ++notApplicableDecisionsCount;
111     }
112
113     /**
114      * Reset all the statistics counts to 0.
115      */
116     public void resetAllStatistics() {
117         totalPolicyTypesCount = 0L;
118         totalPoliciesCount = 0L;
119         errorCount = 0L;
120         permitDecisionsCount = 0L;
121         denyDecisionsCount = 0L;
122         indeterminantDecisionsCount = 0L;
123         notApplicableDecisionsCount = 0L;
124     }
125 }