Change nexus values to properties
[appc.git] / app-c / appc / appc-metric / appc-metric-bundle / src / main / java / org / openecomp / appc / metricservice / metric / impl / DefaultPrimitiveCounter.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : APP-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                              reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.openecomp.appc.metricservice.metric.impl;
23
24 import org.openecomp.appc.metricservice.metric.MetricType;
25 import org.openecomp.appc.metricservice.metric.PrimitiveCounter;
26
27
28 public class DefaultPrimitiveCounter  implements PrimitiveCounter{
29     private  String name;
30     private  MetricType metricType;
31     private  long counter;
32
33     public DefaultPrimitiveCounter(String name, MetricType metricType, long counter) {
34         this.name = name;
35         this.metricType = metricType;
36         this.counter = counter;
37     }
38
39     public DefaultPrimitiveCounter(String name, MetricType metricType) {
40         this.counter=0;
41         this.name = name;
42         this.metricType = metricType;
43     }
44
45     @Override
46     public void increment() {
47         increment(1);
48     }
49
50     @Override
51     public void increment(long value) {
52         this.counter+=value;
53     }
54
55     @Override
56     public void decrement() {
57         decrement(1);
58     }
59
60     @Override
61     public void decrement(long value) {
62         this.counter-=value;
63     }
64
65     @Override
66     public long value() {
67         return this.counter;
68     }
69
70     @Override
71     public String name() {
72         return this.name;
73     }
74
75     @Override
76     public void reset() {
77         this.counter=0 ;
78     }
79
80     @Override
81     public String toString() {
82         return "DefaultPrimitiveCounter{" +
83                 "name='" + name + '\'' +
84                 ", metricType=" + metricType +
85                 ", counter=" + counter +
86                 '}';
87     }
88
89     @Override
90     public MetricType type() {
91         return this.metricType;
92     }
93 }