Skip to content

Commit 23e9cc8

Browse files
committed
docs: added JavaDoc
1 parent da23cf1 commit 23e9cc8

File tree

15 files changed

+216
-238
lines changed

15 files changed

+216
-238
lines changed

devkit-utils/src/main/java/com/onixbyte/devkit/utils/Base64Util.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@
2323
import java.util.Objects;
2424

2525
/**
26-
* The {@link Base64Util} class provides static methods to encode and decode
27-
* strings with Base64 encoding. It utilizes the {@link Base64} class from the
28-
* Java standard library for performing the encoding and decoding operations.
29-
* This utility class offers convenient methods to encode and decode strings
30-
* with different character sets.
26+
* The {@link Base64Util} class provides static methods to encode and decode strings with Base64
27+
* encoding. It utilizes the {@link Base64} class from the Java standard library for performing the
28+
* encoding and decoding operations. This utility class offers convenient methods to encode and
29+
* decode strings with different character sets.
3130
* <p>
32-
* This class is designed as a final class with a private constructor to
33-
* prevent instantiation. All methods in this class are static, allowing easy
34-
* access to the Base64 encoding and decoding functionality.
31+
* This class is designed as a final class with a private constructor to prevent instantiation.
32+
* All methods in this class are static, allowing easy access to the Base64 encoding and
33+
* decoding functionality.
3534
* <p>
3635
* Example usage:
3736
* <pre>
@@ -46,9 +45,9 @@
4645
* System.out.println("Decoded string: " + decoded);
4746
* </pre>
4847
* <p>
49-
* <b>Note:</b> This utility class uses the default charset (UTF-8) if no
50-
* specific charset is provided. It is recommended to specify the charset
51-
* explicitly to ensure consistent encoding and decoding.
48+
* <b>Note:</b> This utility class uses the default charset (UTF-8) if no specific charset is
49+
* provided. It is recommended to specify the charset explicitly to ensure consistent
50+
* encoding and decoding.
5251
*
5352
* @author Zihlu Wang
5453
* @version 1.1.0

devkit-utils/src/main/java/com/onixbyte/devkit/utils/BranchUtil.java

Lines changed: 43 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@
2323
import java.util.function.Supplier;
2424

2525
/**
26-
* The {@link BranchUtil} class provides static methods to simplify conditional
27-
* logic in Java development by leveraging lambda expressions. It offers
28-
* convenient methods to replace verbose {@code if...else} statements with more
29-
* concise and expressive functional constructs.
26+
* The {@link BranchUtil} class provides static methods to simplify conditional logic in Java
27+
* development by leveraging lambda expressions. It offers convenient methods to replace verbose
28+
* {@code if...else} statements with more concise and expressive functional constructs.
3029
* <p>
31-
* Developers can use methods in this utility class to streamline their code,
32-
* enhance readability, and promote a more functional style of programming when
33-
* dealing with branching logic and conditional statements.
30+
* Developers can use methods in this utility class to streamline their code, enhance readability,
31+
* and promote a more functional style of programming when dealing with branching logic and
32+
* conditional statements.
3433
* <p>
3534
* <b>Example:</b>
3635
* <pre>
@@ -64,11 +63,11 @@
6463
* </pre>
6564
* <p>
6665
* <b>Note:</b>
67-
* The {@link #and(Boolean...)} and {@link #or(Boolean...)} methods accept any
68-
* number of boolean expressions.
66+
* The {@link #and(Boolean...)} and {@link #or(Boolean...)} methods accept any number of boolean
67+
* expressions.
6968
*
7069
* @param <T> the type of the result to be handled by the methods
71-
* @author Zihlu Wang
70+
* @author zihluwang
7271
* @version 1.1.0
7372
* @see java.util.function.Supplier
7473
* @see java.util.function.BooleanSupplier
@@ -87,13 +86,12 @@ private BranchUtil(boolean result) {
8786
}
8887

8988
/**
90-
* Creates a {@code BranchUtil} instance to evaluate a logical OR operation
91-
* on the provided boolean expressions.
89+
* Creates a {@code BranchUtil} instance to evaluate a logical OR operation on the provided
90+
* boolean expressions.
9291
*
9392
* @param booleans the boolean expressions to be evaluated
9493
* @param <T> the type of the result to be handled by the methods
95-
* @return a {@code BranchUtil} instance representing the result of the
96-
* logical OR operation
94+
* @return a {@code BranchUtil} instance representing the result of the logical OR operation
9795
*/
9896
public static <T> BranchUtil<T> or(Boolean... booleans) {
9997
var result = Arrays.stream(booleans)
@@ -103,13 +101,12 @@ public static <T> BranchUtil<T> or(Boolean... booleans) {
103101
}
104102

105103
/**
106-
* Creates a {@code BranchUtil} instance to evaluate a logical AND
107-
* operation on the provided boolean expressions.
104+
* Creates a {@code BranchUtil} instance to evaluate a logical AND operation on the provided
105+
* boolean expressions.
108106
*
109107
* @param booleans the boolean expressions to be evaluated
110108
* @param <T> the type of the result to be handled by the methods
111-
* @return a {@code BranchUtil} instance representing the result of the
112-
* logical AND operation
109+
* @return a {@code BranchUtil} instance representing the result of the logical AND operation
113110
*/
114111
public static <T> BranchUtil<T> and(Boolean... booleans) {
115112
var result = Arrays.stream(booleans)
@@ -119,12 +116,11 @@ public static <T> BranchUtil<T> and(Boolean... booleans) {
119116
}
120117

121118
/**
122-
* Creates a {@code BranchUtil} instance to evaluate a logical OR operation
123-
* on the provided boolean suppliers.
119+
* Creates a {@code BranchUtil} instance to evaluate a logical OR operation on the provided
120+
* boolean suppliers.
124121
*
125122
* @param booleanSuppliers the boolean suppliers to be evaluated
126-
* @param <T> the type of the result to be handled by the
127-
* methods
123+
* @param <T> the type of the result to be handled by the methods
128124
* @return a {@code BranchUtil} instance representing the result of the
129125
* logical OR operation
130126
*/
@@ -136,12 +132,11 @@ public static <T> BranchUtil<T> or(BooleanSupplier... booleanSuppliers) {
136132
}
137133

138134
/**
139-
* Creates a {@code BranchUtil} instance to evaluate a logical AND
140-
* operation on the provided boolean suppliers.
135+
* Creates a {@code BranchUtil} instance to evaluate a logical AND operation on the provided
136+
* boolean suppliers.
141137
*
142138
* @param booleanSuppliers the boolean suppliers to be evaluated
143-
* @param <T> the type of the result to be handled by the
144-
* methods
139+
* @param <T> the type of the result to be handled by the methods
145140
* @return a {@code BranchUtil} instance representing the result of the
146141
* logical AND operation
147142
*/
@@ -153,22 +148,18 @@ public static <T> BranchUtil<T> and(BooleanSupplier... booleanSuppliers) {
153148
}
154149

155150
/**
156-
* Handles the result of the boolean expressions by executing the
157-
* appropriate handler based on the result.
151+
* Handles the result of the boolean expressions by executing the appropriate handler based
152+
* on the result.
158153
* <p>
159-
* If the result is {@code true}, the {@code ifHandler} is executed. If the
160-
* result is {@code false} and an {@code elseHandler} is provided, it is
161-
* executed.
154+
* If the result is {@code true}, the {@code ifHandler} is executed. If the result is
155+
* {@code false} and an {@code elseHandler} is provided, it is executed.
162156
* <p>
163157
* Returns the result of the executed handler.
164158
*
165-
* @param ifHandler the handler to be executed if the result is
166-
* {@code true}
167-
* @param elseHandler the handler to be executed if the result is
168-
* {@code false} (optional)
169-
* @return the result of the executed handler, or {@code null} if no
170-
* {@code elseHandler} is provided and the result of the evaluation is
171-
* {@code false}
159+
* @param ifHandler the handler to be executed if the result is {@code true}
160+
* @param elseHandler the handler to be executed if the result is {@code false} (optional)
161+
* @return the result of the executed handler, or {@code null} if no {@code elseHandler} is
162+
* provided and the result of the evaluation is {@code false}
172163
*/
173164
public T handle(Supplier<T> ifHandler, Supplier<T> elseHandler) {
174165
if (this.result && Objects.nonNull(ifHandler)) {
@@ -183,32 +174,28 @@ public T handle(Supplier<T> ifHandler, Supplier<T> elseHandler) {
183174
}
184175

185176
/**
186-
* Handles the result of the boolean expressions by executing the provided
187-
* handler if the result is {@code true}.
177+
* Handles the result of the boolean expressions by executing the provided handler if the
178+
* result is {@code true}.
188179
* <p>
189180
* Returns the result of the executed handler.
190181
*
191-
* @param ifHandler the handler to be executed if the result is
192-
* {@code true}
193-
* @return the result of the executed handler, or {@code null} if result of
194-
* evaluation is {@code false}
182+
* @param ifHandler the handler to be executed if the result is {@code true}
183+
* @return the result of the executed handler, or {@code null} if result of evaluation is
184+
* {@code false}
195185
*/
196186
public T handle(Supplier<T> ifHandler) {
197187
return handle(ifHandler, null);
198188
}
199189

200190
/**
201-
* Handles the result of the boolean expressions by executing the
202-
* appropriate handler based on the result.
191+
* Handles the result of the boolean expressions by executing the appropriate handler based
192+
* on the result.
203193
* <p>
204-
* If the result is {@code true}, the {@code ifHandler} is executed. If the
205-
* result is {@code false} and an {@code elseHandler} is provided, it is
206-
* executed.
194+
* If the result is {@code true}, the {@code ifHandler} is executed. If the result is
195+
* {@code false} and an {@code elseHandler} is provided, it is executed.
207196
*
208-
* @param ifHandler the handler to be executed if the result is
209-
* {@code true}
210-
* @param elseHandler the handler to be executed if the result is
211-
* {@code false} (optional)
197+
* @param ifHandler the handler to be executed if the result is {@code true}
198+
* @param elseHandler the handler to be executed if the result is {@code false} (optional)
212199
*/
213200
public void handle(Runnable ifHandler, Runnable elseHandler) {
214201
if (this.result && Objects.nonNull(ifHandler)) {
@@ -224,11 +211,10 @@ public void handle(Runnable ifHandler, Runnable elseHandler) {
224211
}
225212

226213
/**
227-
* Handles the result of the boolean expressions by executing the provided
228-
* handler if the result is {@code true}.
214+
* Handles the result of the boolean expressions by executing the provided handler if the
215+
* result is {@code true}.
229216
*
230-
* @param ifHandler the handler to be executed if the result is
231-
* {@code true}
217+
* @param ifHandler the handler to be executed if the result is {@code true}
232218
*/
233219
public void handle(Runnable ifHandler) {
234220
handle(ifHandler, null);

devkit-utils/src/main/java/com/onixbyte/devkit/utils/ChainedCalcUtil.java

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@
2626
import java.util.function.Function;
2727

2828
/**
29-
* The {@code ChainedCalcUtil} class provides a convenient way to perform
30-
* chained high-precision calculations using {@link BigDecimal}. It allows
31-
* users to perform mathematical operations such as addition, subtraction,
32-
* multiplication, and division with customisable precision and scale. By using
33-
* this utility class, developers can achieve accurate results and avoid
34-
* precision loss in their calculations.
29+
* The {@code ChainedCalcUtil} class provides a convenient way to perform chained high-precision
30+
* calculations using {@link BigDecimal}. It allows users to perform mathematical operations such
31+
* as addition, subtraction, multiplication, and division with customisable precision and scale.
32+
* By using this utility class, developers can achieve accurate results and avoid precision loss
33+
* in their calculations.
3534
* <p>
3635
* <b>Usage:</b>
3736
* <pre>
@@ -82,10 +81,9 @@
8281
* {@code ChainedCalcUtil} class.
8382
* <p>
8483
* <b>Note:</b>
85-
* The {@code ChainedCalcUtil} class internally uses {@link BigDecimal} to
86-
* handle high-precision calculations. It is important to note that {@link
87-
* BigDecimal} operations can be memory-intensive and may have performance
88-
* implications for extremely large numbers or complex calculations.
84+
* The {@code ChainedCalcUtil} class internally uses {@link BigDecimal} to handle high-precision
85+
* calculations. It is important to note that {@link BigDecimal} operations can be memory-intensive
86+
* and may have performance implications for extremely large numbers or complex calculations.
8987
*
9088
* @author sunzsh
9189
* @version 1.1.0
@@ -96,8 +94,7 @@
9694
public final class ChainedCalcUtil {
9795

9896
/**
99-
* Creates a {@code ChainedCalcUtil} instance with the specified initial
100-
* value.
97+
* Creates a {@code ChainedCalcUtil} instance with the specified initial value.
10198
*
10299
* @param value the initial value for the calculation
103100
*/
@@ -126,8 +123,7 @@ public ChainedCalcUtil add(Number other) {
126123
}
127124

128125
/**
129-
* Adds the specified value to the current value with a specified scale
130-
* before the operation.
126+
* Adds the specified value to the current value with a specified scale before the operation.
131127
*
132128
* @param other the value to be added
133129
* @param beforeOperateScale the scale to be applied before the operation
@@ -148,8 +144,8 @@ public ChainedCalcUtil subtract(Number other) {
148144
}
149145

150146
/**
151-
* Subtracts the specified value from the current value with a specified
152-
* scale before the operation.
147+
* Subtracts the specified value from the current value with a specified scale before
148+
* the operation.
153149
*
154150
* @param other the value to be subtracted
155151
* @param beforeOperateScale the scale to be applied before the operation
@@ -170,8 +166,8 @@ public ChainedCalcUtil multiply(Number other) {
170166
}
171167

172168
/**
173-
* Multiplies the current value by the specified value with a specified
174-
* scale before the operation.
169+
* Multiplies the current value by the specified value with a specified scale before
170+
* the operation.
175171
*
176172
* @param other the value to be multiplied by
177173
* @param beforeOperateScale the scale to be applied before the operation
@@ -192,8 +188,7 @@ public ChainedCalcUtil divide(Number other) {
192188
}
193189

194190
/**
195-
* Divides the current value by the specified value with a specified scale
196-
* before the operation.
191+
* Divides the current value by the specified value with a specified scale before the operation.
197192
*
198193
* @param other the value to divide by
199194
* @param beforeOperateScale the scale to be applied before the operation
@@ -216,16 +211,18 @@ public ChainedCalcUtil divideWithScale(Number other, Integer scale) {
216211
}
217212

218213
/**
219-
* Divides the current value by the specified value with a specified scale
220-
* and a scale applied before the operation.
214+
* Divides the current value by the specified value with a specified scale and a scale applied
215+
* before the operation.
221216
*
222217
* @param other the value to divide by
223218
* @param scale the scale for the result
224219
* @param beforeOperateScale the scale to be applied before the operation
225220
* @return a {@code ChainedCalcUtil} instance with the updated value
226221
*/
227222
public ChainedCalcUtil divideWithScale(Number other, Integer scale, Integer beforeOperateScale) {
228-
return baseOperator(otherValue -> this.value.divide(otherValue, scale, RoundingMode.HALF_UP), other, beforeOperateScale);
223+
return baseOperator((otherValue) ->
224+
this.value.divide(otherValue, scale, RoundingMode.HALF_UP),
225+
other, beforeOperateScale);
229226
}
230227

231228
/**
@@ -276,8 +273,7 @@ public Integer getInteger() {
276273
}
277274

278275
/**
279-
* Applies the specified operator function to the current value and another
280-
* value.
276+
* Applies the specified operator function to the current value and another value.
281277
*
282278
* @param operator the operator function to apply
283279
* @param otherValue the value to apply the operator with
@@ -288,8 +284,8 @@ private ChainedCalcUtil operator(BiFunction<BigDecimal, BigDecimal, BigDecimal>
288284
}
289285

290286
/**
291-
* Applies the specified operator function to the current value and another
292-
* value with a specified scale before the operation.
287+
* Applies the specified operator function to the current value and another value with a
288+
* specified scale before the operation.
293289
*
294290
* @param operator the operator function to apply
295291
* @param other the value to apply the operator with
@@ -298,7 +294,10 @@ private ChainedCalcUtil operator(BiFunction<BigDecimal, BigDecimal, BigDecimal>
298294
* @return a ChainedCalcUtil instance with the updated value
299295
*/
300296
private ChainedCalcUtil operator(BiFunction<BigDecimal, BigDecimal, BigDecimal> operator, Object other, Integer beforeOperateScale) {
301-
return baseOperator((otherValue) -> operator.apply(this.value, otherValue), other, beforeOperateScale);
297+
return baseOperator((otherValue) ->
298+
operator.apply(this.value, otherValue),
299+
other,
300+
beforeOperateScale);
302301
}
303302

304303
/**
@@ -328,8 +327,7 @@ private synchronized ChainedCalcUtil baseOperator(Function<BigDecimal, BigDecima
328327
* Converts the specified value to a {@link BigDecimal}.
329328
*
330329
* @param value the value to convert
331-
* @param scale the scale to apply to the resulting BigDecimal, or null if
332-
* not applicable
330+
* @param scale the scale to apply to the resulting BigDecimal, or null if not applicable
333331
* @return the converted BigDecimal value
334332
*/
335333
private BigDecimal convertBigDecimal(Object value, Integer scale) {

0 commit comments

Comments
 (0)