diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/Base64Util.java b/devkit-utils/src/main/java/com/onixbyte/devkit/utils/Base64Util.java index c10ce0e..41a0cc3 100644 --- a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/Base64Util.java +++ b/devkit-utils/src/main/java/com/onixbyte/devkit/utils/Base64Util.java @@ -23,15 +23,14 @@ import java.util.Objects; /** - * The {@link Base64Util} class provides static methods to encode and decode - * strings with Base64 encoding. It utilizes the {@link Base64} class from the - * Java standard library for performing the encoding and decoding operations. - * This utility class offers convenient methods to encode and decode strings - * with different character sets. + * The {@link Base64Util} class provides static methods to encode and decode strings with Base64 + * encoding. It utilizes the {@link Base64} class from the Java standard library for performing the + * encoding and decoding operations. This utility class offers convenient methods to encode and + * decode strings with different character sets. *
- * This class is designed as a final class with a private constructor to - * prevent instantiation. All methods in this class are static, allowing easy - * access to the Base64 encoding and decoding functionality. + * This class is designed as a final class with a private constructor to prevent instantiation. + * All methods in this class are static, allowing easy access to the Base64 encoding and + * decoding functionality. *
* Example usage: *
@@ -46,9 +45,9 @@
* System.out.println("Decoded string: " + decoded);
*
* - * Note: This utility class uses the default charset (UTF-8) if no - * specific charset is provided. It is recommended to specify the charset - * explicitly to ensure consistent encoding and decoding. + * Note: This utility class uses the default charset (UTF-8) if no specific charset is + * provided. It is recommended to specify the charset explicitly to ensure consistent + * encoding and decoding. * * @author Zihlu Wang * @version 1.1.0 diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/BranchUtil.java b/devkit-utils/src/main/java/com/onixbyte/devkit/utils/BranchUtil.java index 14c1dd3..84a3204 100644 --- a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/BranchUtil.java +++ b/devkit-utils/src/main/java/com/onixbyte/devkit/utils/BranchUtil.java @@ -23,14 +23,13 @@ import java.util.function.Supplier; /** - * The {@link BranchUtil} class provides static methods to simplify conditional - * logic in Java development by leveraging lambda expressions. It offers - * convenient methods to replace verbose {@code if...else} statements with more - * concise and expressive functional constructs. + * The {@link BranchUtil} class provides static methods to simplify conditional logic in Java + * development by leveraging lambda expressions. It offers convenient methods to replace verbose + * {@code if...else} statements with more concise and expressive functional constructs. *
- * Developers can use methods in this utility class to streamline their code, - * enhance readability, and promote a more functional style of programming when - * dealing with branching logic and conditional statements. + * Developers can use methods in this utility class to streamline their code, enhance readability, + * and promote a more functional style of programming when dealing with branching logic and + * conditional statements. *
* Example: *
@@ -64,11 +63,11 @@ **
* Note:
- * The {@link #and(Boolean...)} and {@link #or(Boolean...)} methods accept any
- * number of boolean expressions.
+ * The {@link #and(Boolean...)} and {@link #or(Boolean...)} methods accept any number of boolean
+ * expressions.
*
* @param
- * If the result is {@code true}, the {@code ifHandler} is executed. If the
- * result is {@code false} and an {@code elseHandler} is provided, it is
- * executed.
+ * If the result is {@code true}, the {@code ifHandler} is executed. If the result is
+ * {@code false} and an {@code elseHandler} is provided, it is executed.
*
* Returns the result of the executed handler.
*
- * @param ifHandler the handler to be executed if the result is
- * {@code true}
- * @param elseHandler the handler to be executed if the result is
- * {@code false} (optional)
- * @return the result of the executed handler, or {@code null} if no
- * {@code elseHandler} is provided and the result of the evaluation is
- * {@code false}
+ * @param ifHandler the handler to be executed if the result is {@code true}
+ * @param elseHandler the handler to be executed if the result is {@code false} (optional)
+ * @return the result of the executed handler, or {@code null} if no {@code elseHandler} is
+ * provided and the result of the evaluation is {@code false}
*/
public T handle(Supplier
* Returns the result of the executed handler.
*
- * @param ifHandler the handler to be executed if the result is
- * {@code true}
- * @return the result of the executed handler, or {@code null} if result of
- * evaluation is {@code false}
+ * @param ifHandler the handler to be executed if the result is {@code true}
+ * @return the result of the executed handler, or {@code null} if result of evaluation is
+ * {@code false}
*/
public T handle(Supplier
- * If the result is {@code true}, the {@code ifHandler} is executed. If the
- * result is {@code false} and an {@code elseHandler} is provided, it is
- * executed.
+ * If the result is {@code true}, the {@code ifHandler} is executed. If the result is
+ * {@code false} and an {@code elseHandler} is provided, it is executed.
*
- * @param ifHandler the handler to be executed if the result is
- * {@code true}
- * @param elseHandler the handler to be executed if the result is
- * {@code false} (optional)
+ * @param ifHandler the handler to be executed if the result is {@code true}
+ * @param elseHandler the handler to be executed if the result is {@code false} (optional)
*/
public void handle(Runnable ifHandler, Runnable elseHandler) {
if (this.result && Objects.nonNull(ifHandler)) {
@@ -224,11 +211,10 @@ public void handle(Runnable ifHandler, Runnable elseHandler) {
}
/**
- * Handles the result of the boolean expressions by executing the provided
- * handler if the result is {@code true}.
+ * Handles the result of the boolean expressions by executing the provided handler if the
+ * result is {@code true}.
*
- * @param ifHandler the handler to be executed if the result is
- * {@code true}
+ * @param ifHandler the handler to be executed if the result is {@code true}
*/
public void handle(Runnable ifHandler) {
handle(ifHandler, null);
diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/ChainedCalcUtil.java b/devkit-utils/src/main/java/com/onixbyte/devkit/utils/ChainedCalcUtil.java
index 30f21e9..a8f395e 100644
--- a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/ChainedCalcUtil.java
+++ b/devkit-utils/src/main/java/com/onixbyte/devkit/utils/ChainedCalcUtil.java
@@ -26,12 +26,11 @@
import java.util.function.Function;
/**
- * The {@code ChainedCalcUtil} class provides a convenient way to perform
- * chained high-precision calculations using {@link BigDecimal}. It allows
- * users to perform mathematical operations such as addition, subtraction,
- * multiplication, and division with customisable precision and scale. By using
- * this utility class, developers can achieve accurate results and avoid
- * precision loss in their calculations.
+ * The {@code ChainedCalcUtil} class provides a convenient way to perform chained high-precision
+ * calculations using {@link BigDecimal}. It allows users to perform mathematical operations such
+ * as addition, subtraction, multiplication, and division with customisable precision and scale.
+ * By using this utility class, developers can achieve accurate results and avoid precision loss
+ * in their calculations.
*
* Usage:
*
* Note:
- * The {@code ChainedCalcUtil} class internally uses {@link BigDecimal} to
- * handle high-precision calculations. It is important to note that {@link
- * BigDecimal} operations can be memory-intensive and may have performance
- * implications for extremely large numbers or complex calculations.
+ * The {@code ChainedCalcUtil} class internally uses {@link BigDecimal} to handle high-precision
+ * calculations. It is important to note that {@link BigDecimal} operations can be memory-intensive
+ * and may have performance implications for extremely large numbers or complex calculations.
*
* @author sunzsh
* @version 1.1.0
@@ -96,8 +94,7 @@
public final class ChainedCalcUtil {
/**
- * Creates a {@code ChainedCalcUtil} instance with the specified initial
- * value.
+ * Creates a {@code ChainedCalcUtil} instance with the specified initial value.
*
* @param value the initial value for the calculation
*/
@@ -126,8 +123,7 @@ public ChainedCalcUtil add(Number other) {
}
/**
- * Adds the specified value to the current value with a specified scale
- * before the operation.
+ * Adds the specified value to the current value with a specified scale before the operation.
*
* @param other the value to be added
* @param beforeOperateScale the scale to be applied before the operation
@@ -148,8 +144,8 @@ public ChainedCalcUtil subtract(Number other) {
}
/**
- * Subtracts the specified value from the current value with a specified
- * scale before the operation.
+ * Subtracts the specified value from the current value with a specified scale before
+ * the operation.
*
* @param other the value to be subtracted
* @param beforeOperateScale the scale to be applied before the operation
@@ -170,8 +166,8 @@ public ChainedCalcUtil multiply(Number other) {
}
/**
- * Multiplies the current value by the specified value with a specified
- * scale before the operation.
+ * Multiplies the current value by the specified value with a specified scale before
+ * the operation.
*
* @param other the value to be multiplied by
* @param beforeOperateScale the scale to be applied before the operation
@@ -192,8 +188,7 @@ public ChainedCalcUtil divide(Number other) {
}
/**
- * Divides the current value by the specified value with a specified scale
- * before the operation.
+ * Divides the current value by the specified value with a specified scale before the operation.
*
* @param other the value to divide by
* @param beforeOperateScale the scale to be applied before the operation
@@ -216,8 +211,8 @@ public ChainedCalcUtil divideWithScale(Number other, Integer scale) {
}
/**
- * Divides the current value by the specified value with a specified scale
- * and a scale applied before the operation.
+ * Divides the current value by the specified value with a specified scale and a scale applied
+ * before the operation.
*
* @param other the value to divide by
* @param scale the scale for the result
@@ -225,7 +220,9 @@ public ChainedCalcUtil divideWithScale(Number other, Integer scale) {
* @return a {@code ChainedCalcUtil} instance with the updated value
*/
public ChainedCalcUtil divideWithScale(Number other, Integer scale, Integer beforeOperateScale) {
- return baseOperator(otherValue -> this.value.divide(otherValue, scale, RoundingMode.HALF_UP), other, beforeOperateScale);
+ return baseOperator((otherValue) ->
+ this.value.divide(otherValue, scale, RoundingMode.HALF_UP),
+ other, beforeOperateScale);
}
/**
@@ -276,8 +273,7 @@ public Integer getInteger() {
}
/**
- * Applies the specified operator function to the current value and another
- * value.
+ * Applies the specified operator function to the current value and another value.
*
* @param operator the operator function to apply
* @param otherValue the value to apply the operator with
@@ -288,8 +284,8 @@ private ChainedCalcUtil operator(BiFunction
* Note:
- * The hash functions provided by the HashUtil class are one-way hash
- * functions, meaning the original data cannot be retrieved from the hash
- * value. These hash functions are commonly used for data integrity checks and
- * password storage, but they should not be used for encryption purposes.
+ * The hash functions provided by the HashUtil class are one-way hash functions, meaning the
+ * original data cannot be retrieved from the hash value. These hash functions are commonly used
+ * for data integrity checks and password storage, but they should not be used for
+ * encryption purposes.
*
* @author Zihlu Wang
* @version 1.1.0
@@ -70,12 +69,10 @@
public final class HashUtil {
/**
- * Calculates the MD2 hash value of the specified string using the given
- * charset.
+ * Calculates the MD2 hash value of the specified string using the given charset.
*
* @param value the string to calculate with the MD2 algorithm
- * @param charset the charset to use for encoding the string (default is
- * UTF-8 if null)
+ * @param charset the charset to use for encoding the string (default is UTF-8 if null)
* @return the MD2 hash value as a hexadecimal string
*/
public static String md2(String value, Charset charset) {
@@ -84,8 +81,7 @@ public static String md2(String value, Charset charset) {
}
/**
- * Calculates the MD2 hash value of the specified string using the UTF-8
- * charset.
+ * Calculates the MD2 hash value of the specified string using the UTF-8 charset.
*
* @param value the string to calculate with the MD2 algorithm
* @return the MD2 hash value as a hexadecimal string
@@ -95,12 +91,10 @@ public static String md2(String value) {
}
/**
- * Calculates the MD5 hash value of the specified string using the given
- * charset.
+ * Calculates the MD5 hash value of the specified string using the given charset.
*
* @param value the string to calculate with the MD5 algorithm
- * @param charset the charset to use for encoding the string (default is
- * UTF-8 if null)
+ * @param charset the charset to use for encoding the string (default is UTF-8 if null)
* @return the MD5 hash value as a hexadecimal string
*/
public static String md5(String value, Charset charset) {
@@ -109,8 +103,7 @@ public static String md5(String value, Charset charset) {
}
/**
- * Calculates the MD5 hash value of the specified string using the UTF-8
- * charset.
+ * Calculates the MD5 hash value of the specified string using the UTF-8 charset.
*
* @param value the string to calculate with the MD5 algorithm
* @return the MD5 hash value as a hexadecimal string
@@ -120,12 +113,10 @@ public static String md5(String value) {
}
/**
- * Calculates the SHA-1 hash value of the specified string using the given
- * charset.
+ * Calculates the SHA-1 hash value of the specified string using the given charset.
*
* @param value the string to calculate with the SHA-1 algorithm
- * @param charset the charset to use for encoding the string (default is
- * UTF-8 if null)
+ * @param charset the charset to use for encoding the string (default is UTF-8 if null)
* @return the SHA-1 hash value as a hexadecimal string
*/
public static String sha1(String value, Charset charset) {
@@ -134,8 +125,7 @@ public static String sha1(String value, Charset charset) {
}
/**
- * Calculates the SHA-1 hash value of the specified string using the UTF-8
- * charset.
+ * Calculates the SHA-1 hash value of the specified string using the UTF-8 charset.
*
* @param value the string to calculate with the SHA-1 algorithm
* @return the SHA-1 hash value as a hexadecimal string
@@ -145,12 +135,10 @@ public static String sha1(String value) {
}
/**
- * Calculates the SHA-224 hash value of the specified string using the
- * given charset.
+ * Calculates the SHA-224 hash value of the specified string using the given charset.
*
* @param value the string to calculate with the SHA-225 algorithm
- * @param charset the charset to use for encoding the string (default is
- * UTF-8 if null)
+ * @param charset the charset to use for encoding the string (default is UTF-8 if null)
* @return the SHA-224 hash value as a hexadecimal string
*/
public static String sha224(String value, Charset charset) {
@@ -174,8 +162,7 @@ public static String sha224(String value) {
* given charset.
*
* @param value the string to calculate with the SHA-256 algorithm
- * @param charset the charset to use for encoding the string (default is
- * UTF-8 if null)
+ * @param charset the charset to use for encoding the string (default is UTF-8 if null)
* @return the SHA-256 hash value as a hexadecimal string
*/
public static String sha256(String value, Charset charset) {
@@ -184,8 +171,7 @@ public static String sha256(String value, Charset charset) {
}
/**
- * Calculates the SHA-256 hash value of the specified string using the
- * UTF-8 charset.
+ * Calculates the SHA-256 hash value of the specified string using the UTF-8 charset.
*
* @param value the string to calculate with the SHA-256 algorithm
* @return the SHA-256 hash value as a hexadecimal string
@@ -195,12 +181,10 @@ public static String sha256(String value) {
}
/**
- * Calculates the SHA-384 hash value of the specified string using the
- * given charset.
+ * Calculates the SHA-384 hash value of the specified string using the given charset.
*
* @param value the string to calculate with the SHA-384 algorithm
- * @param charset the charset to use for encoding the string (default is
- * UTF-8 if null)
+ * @param charset the charset to use for encoding the string (default is UTF-8 if null)
* @return the SHA-384 hash value as a hexadecimal string
*/
public static String sha384(String value, Charset charset) {
@@ -209,8 +193,7 @@ public static String sha384(String value, Charset charset) {
}
/**
- * Calculates the SHA-384 hash value of the specified string using the
- * UTF-8 charset.
+ * Calculates the SHA-384 hash value of the specified string using the UTF-8 charset.
*
* @param value the string to calculate with the SHA-384 algorithm
* @return the SHA-384 hash value as a hexadecimal string
@@ -220,12 +203,10 @@ public static String sha384(String value) {
}
/**
- * Calculates the SHA-512 hash value of the specified string using the
- * given charset.
+ * Calculates the SHA-512 hash value of the specified string using the given charset.
*
* @param value the string to calculate with the SHA-512 algorithm
- * @param charset the charset to use for encoding the string (default is
- * UTF-8 if null)
+ * @param charset the charset to use for encoding the string (default is UTF-8 if null)
* @return the SHA-512 hash value as a hexadecimal string
*/
public static String sha512(String value, Charset charset) {
@@ -234,8 +215,7 @@ public static String sha512(String value, Charset charset) {
}
/**
- * Calculates the SHA-512 hash value of the specified string using the
- * UTF-8 charset.
+ * Calculates the SHA-512 hash value of the specified string using the UTF-8 charset.
*
* @param value the string to calculate with the SHA-512 algorithm
* @return the SHA-512 hash value as a hexadecimal string
@@ -256,12 +236,11 @@ private HashUtil() {
*
* @param method the hash algorithm to use
* @param value the string to calculate the hash value for
- * @param charset the charset to use for encoding the string (default is
- * UTF-8 if null)
- * @return the hash value as a hexadecimal string, or an empty string if
- * the algorithm is not available
- * @throws RuntimeException if an unknown algorithm name is provided
- * (should not occur under controlled usage)
+ * @param charset the charset to use for encoding the string (default is UTF-8 if null)
+ * @return the hash value as a hexadecimal string, or an empty string if the algorithm is
+ * not available
+ * @throws RuntimeException if an unknown algorithm name is provided (should not occur under
+ * controlled usage)
*/
private static String hash(String method, String value, Charset charset) {
try {
diff --git a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/MapUtil.java b/devkit-utils/src/main/java/com/onixbyte/devkit/utils/MapUtil.java
index b929cee..aa23699 100644
--- a/devkit-utils/src/main/java/com/onixbyte/devkit/utils/MapUtil.java
+++ b/devkit-utils/src/main/java/com/onixbyte/devkit/utils/MapUtil.java
@@ -28,7 +28,7 @@
* to objects.
*
* Note: Since version 1.4.2, this util class removed reflection API and transferred to a safer API.
- * Please see documentation for more information.
+ * Please see documentation for more information.
*
* @author Zihlu Wang
* @version 1.4.2
@@ -41,7 +41,9 @@ public final class MapUtil {
/**
* Converts an object to a map by mapping the field names to their corresponding values.
*
- * @param entity the object to be converted to a map
+ * @param
- * It also provides methods for getting and setting field values using
- * reflection.
+ * It also provides methods for getting and setting field values using reflection.
*
* @author zihluwang
* @version 1.4.2
@@ -38,13 +37,11 @@
public final class ReflectMapUtil {
/**
- * Converts an object to a map by mapping the field names to their
- * corresponding values.
+ * Converts an object to a map by mapping the field names to their corresponding values.
*
* @param obj the object to be converted to a map
* @return a map representing the fields and their values of the object
- * @throws IllegalAccessException if an error occurs while accessing the
- * fields of the object
+ * @throws IllegalAccessException if an error occurs while accessing the fields of the object
*/
public static Map
- * If Spring does not have a bean of type
- * {@link GuidCreator} named {@code jtiCreator}
- * in the application context, then create {@code jtiCreator}.
+ * If Spring does not have a bean of type {@link GuidCreator} named {@code jtiCreator} in the
+ * application context, then create {@code jtiCreator}.
*
* @param context the spring application context
- * @param metadata the metadata of the {@link org.springframework.core.type.AnnotationMetadata class}
- * or {@link org.springframework.core.type.MethodMetadata method} being checked
+ * @param metadata the metadata of the {@link org.springframework.core.type.AnnotationMetadata
+ * class} or {@link org.springframework.core.type.MethodMetadata method}
+ * being checked
*/
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
diff --git a/simple-jwt-spring-boot-starter/src/main/java/com/onixbyte/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java b/simple-jwt-spring-boot-starter/src/main/java/com/onixbyte/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java
index f34019b..47d121e 100644
--- a/simple-jwt-spring-boot-starter/src/main/java/com/onixbyte/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java
+++ b/simple-jwt-spring-boot-starter/src/main/java/com/onixbyte/simplejwt/autoconfiguration/properties/SimpleJwtProperties.java
@@ -25,21 +25,20 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
- * {@code SimpleJwtProperties} is a configuration properties class used to
- * store the properties related to Simple JWT library configurations. These
- * properties can be configured in the application's properties file (e.g.,
- * application.properties) with the prefix "code-crafters.simple-jwt".
+ * {@code SimpleJwtProperties} is a configuration properties class used to store the properties
+ * related to Simple JWT library configurations. These properties can be configured in the
+ * application's properties file (e.g., application.properties) with the prefix
+ * "onixbyte.simple-jwt".
*
- * {@code SimpleJwtProperties} provides configuration options for the JWT
- * algorithm, issuer, and secret. The properties are used by the {@link
- * AuthzeroTokenResolverAutoConfiguration} and {@link
- * JjwtTokenResolver} to set up the
- * necessary configurations for JWT generation and validation.
+ * {@code SimpleJwtProperties} provides configuration options for the JWT algorithm, issuer,
+ * and secret. The properties are used by the {@link AuthzeroTokenResolverAutoConfiguration} and
+ * {@link JjwtTokenResolver} to set up the necessary configurations for JWT generation
+ * and validation.
*
- * Developers can customise the JWT algorithm, issuer, and secret by setting
- * the corresponding properties in the application's properties file. The
- * {@code SimpleJwtAutoConfiguration} class reads these properties and uses
- * them to create the TokenResolver bean with the desired configuration.
+ * Developers can customise the JWT algorithm, issuer, and secret by setting the corresponding
+ * properties in the application's properties file. The {@code SimpleJwtAutoConfiguration} class
+ * reads these properties and uses them to create the TokenResolver bean with the
+ * desired configuration.
*
* @author Zihlu Wang
* @version 1.1.0
@@ -49,6 +48,12 @@
@ConfigurationProperties(prefix = "onixbyte.simple-jwt")
public class SimpleJwtProperties {
+ /**
+ * Default constructor.
+ */
+ public SimpleJwtProperties() {
+ }
+
/**
* The algorithm used for JWT generation and validation. Default value is
* {@link TokenAlgorithm#HS256}
@@ -56,15 +61,13 @@ public class SimpleJwtProperties {
private TokenAlgorithm algorithm = TokenAlgorithm.HS256;
/**
- * The issuer value to be included in the generated JWT. Default value is
- * an empty String.
+ * The issuer value to be included in the generated JWT. Default value is an empty String.
*/
private String issuer = "";
/**
- * The secret key used for JWT generation and validation. Default value is
- * the result of call to {@link
- * SecretCreator#createSecret(int, boolean, boolean, boolean)}.
+ * The secret key used for JWT generation and validation. Default value is the result of call to
+ * {@link SecretCreator#createSecret(int, boolean, boolean, boolean)}.
*/
private String secret = SecretCreator.createSecret(32, true, true, true);
@@ -82,10 +81,9 @@
* {@code ChainedCalcUtil} class.
*
@@ -53,14 +52,14 @@
* // Perform SHA-512 hash operation
* String sha512Hash = HashUtil.sha512("someString");
*
- * The above examples demonstrate how to use the {@code HashUtil} class to
- * calculate hash values for a given string using different algorithms.
+ * The above examples demonstrate how to use the {@code HashUtil} class to calculate hash values
+ * for a given string using different algorithms.
*