Skip to content

Commit 9e6c7d6

Browse files
committed
fix
1 parent 7f8c25f commit 9e6c7d6

File tree

1 file changed

+68
-27
lines changed

1 file changed

+68
-27
lines changed

api/src/main/java/org/apache/gravitino/stats/StatisticValues.java

Lines changed: 68 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,73 @@
2727
/** A class representing a collection of statistic values. */
2828
public class StatisticValues {
2929

30+
private StatisticValues() {}
31+
32+
/**
33+
* Creates a statistic value that holds a boolean value.
34+
*
35+
* @param value the boolean value to be held by this statistic value
36+
* @return a BooleanValue instance containing the provided boolean value
37+
*/
38+
public static BooleanValue booleanValue(boolean value) {
39+
return new BooleanValue(value);
40+
}
41+
42+
/**
43+
* Creates a statistic value that holds a long value.
44+
*
45+
* @param value the long value to be held by this statistic value
46+
* @return a LongValue instance containing the provided long value
47+
*/
48+
public static LongValue longValue(long value) {
49+
return new LongValue(value);
50+
}
51+
52+
/**
53+
* Creates a statistic value that holds a double value.
54+
*
55+
* @param value the double value to be held by this statistic value
56+
* @return a DoubleValue instance containing the provided double value
57+
*/
58+
public static DoubleValue doubleValue(double value) {
59+
return new DoubleValue(value);
60+
}
61+
62+
/**
63+
* Creates a statistic value that holds a string value.
64+
*
65+
* @param value the string value to be held by this statistic value
66+
* @return a StringValue instance containing the provided string value
67+
*/
68+
public static StringValue stringValue(String value) {
69+
return new StringValue(value);
70+
}
71+
72+
/**
73+
* Creates a statistic value that holds a list of other statistic values.
74+
*
75+
* @param values the list of statistic values to be held by this statistic value
76+
* @return a ListValue instance containing the provided list of statistic values
77+
*/
78+
public static ListValue listValue(List<StatisticValue> values) {
79+
return new ListValue(values);
80+
}
81+
82+
/**
83+
* Creates a statistic value that holds a map of string keys to other statistic values.
84+
*
85+
* @param values the map of string keys to statistic values to be held by this statistic value
86+
* @return an ObjectValue instance containing the provided map of statistic values
87+
*/
88+
public static ObjectValue objectValue(Map<String, StatisticValue> values) {
89+
return new ObjectValue(values);
90+
}
91+
3092
/** A statistic value that holds a Boolean value. */
3193
public static class BooleanValue implements StatisticValue<Boolean> {
3294
private final Boolean value;
3395

34-
public BooleanValue(Boolean value) {
96+
private BooleanValue(Boolean value) {
3597
this.value = value;
3698
}
3799

@@ -50,7 +112,7 @@ public Type dataType() {
50112
public static class LongValue implements StatisticValue<Long> {
51113
private final Long value;
52114

53-
public LongValue(Long value) {
115+
private LongValue(Long value) {
54116
this.value = value;
55117
}
56118

@@ -69,12 +131,7 @@ public Type dataType() {
69131
public static class DoubleValue implements StatisticValue<Double> {
70132
private final Double value;
71133

72-
/**
73-
* Creates a DoubleValue with the given double value.
74-
*
75-
* @param value The double value to be held by this statistic value.
76-
*/
77-
public DoubleValue(Double value) {
134+
private DoubleValue(Double value) {
78135
this.value = value;
79136
}
80137

@@ -93,12 +150,7 @@ public Type dataType() {
93150
public static class StringValue implements StatisticValue<String> {
94151
private final String value;
95152

96-
/**
97-
* Creates a StringValue with the given string value.
98-
*
99-
* @param value The string value to be held by this statistic value.
100-
*/
101-
public StringValue(String value) {
153+
private StringValue(String value) {
102154
this.value = value;
103155
}
104156

@@ -117,12 +169,7 @@ public Type dataType() {
117169
public static class ListValue implements StatisticValue<List<StatisticValue>> {
118170
private final List<StatisticValue> values;
119171

120-
/**
121-
* Creates a ListValue with the given list of statistic values.
122-
*
123-
* @param values A list of StatisticValue instances.
124-
*/
125-
public ListValue(List<StatisticValue> values) {
172+
private ListValue(List<StatisticValue> values) {
126173
Preconditions.checkArgument(
127174
values != null && values.isEmpty(), "Values cannot be null or empty");
128175
this.values = values;
@@ -143,13 +190,7 @@ public Type dataType() {
143190
public static class ObjectValue implements StatisticValue<Map<String, StatisticValue>> {
144191
private final Map<String, StatisticValue> values;
145192

146-
/**
147-
* Creates an ObjectValue with the given map of statistic values.
148-
*
149-
* @param values A map where keys are String identifiers and values are StatisticValue
150-
* instances.
151-
*/
152-
public ObjectValue(Map<String, StatisticValue> values) {
193+
private ObjectValue(Map<String, StatisticValue> values) {
153194
Preconditions.checkArgument(
154195
values != null && !values.isEmpty(), "Values cannot be null or empty");
155196
this.values = values;

0 commit comments

Comments
 (0)