View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * 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,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.client.console.rest;
20  
21  import com.fasterxml.jackson.annotation.JsonIgnore;
22  import java.io.Serializable;
23  import java.util.ArrayList;
24  import java.util.List;
25  import java.util.Optional;
26  
27  public class SRAStatistics implements Serializable {
28  
29      private static final long serialVersionUID = 25070367703725L;
30  
31      public static class Measurement implements Serializable {
32  
33          private static final long serialVersionUID = 24933964529045L;
34  
35          private String statistic;
36  
37          private Float value;
38  
39          public String getStatistic() {
40              return statistic;
41          }
42  
43          public void setStatistic(final String statistic) {
44              this.statistic = statistic;
45          }
46  
47          public Float getValue() {
48              return value;
49          }
50  
51          public void setValue(final Float value) {
52              this.value = value;
53          }
54      }
55  
56      public static class Tag implements Serializable {
57  
58          private static final long serialVersionUID = 25010610267446L;
59  
60          private String tag;
61  
62          private final List<String> values = new ArrayList<>();
63  
64          public String getTag() {
65              return tag;
66          }
67  
68          public void setTag(final String tag) {
69              this.tag = tag;
70          }
71  
72          public List<String> getValues() {
73              return values;
74          }
75      }
76  
77      private String name;
78  
79      private String description;
80  
81      private String baseUnit;
82  
83      private final List<Measurement> measurements = new ArrayList<>();
84  
85      private final List<Tag> availableTags = new ArrayList<>();
86  
87      public String getName() {
88          return name;
89      }
90  
91      public void setName(final String name) {
92          this.name = name;
93      }
94  
95      public String getDescription() {
96          return description;
97      }
98  
99      public void setDescription(final String description) {
100         this.description = description;
101     }
102 
103     public String getBaseUnit() {
104         return baseUnit;
105     }
106 
107     public void setBaseUnit(final String baseUnit) {
108         this.baseUnit = baseUnit;
109     }
110 
111     @JsonIgnore
112     public Optional<Float> getMeasurement(final String statistic) {
113         return measurements.stream().filter(m -> statistic.equals(m.getStatistic())).
114                 findFirst().map(Measurement::getValue);
115     }
116 
117     public List<Measurement> getMeasurements() {
118         return measurements;
119     }
120 
121     public List<Tag> getAvailableTags() {
122         return availableTags;
123     }
124 }