From c3b05558c529e463293699a442933407ff7ee316 Mon Sep 17 00:00:00 2001 From: Lucy Ciara Herud-Thomassen <86323303+LucyCiara@users.noreply.github.com> Date: Thu, 9 Apr 2026 11:20:20 +0200 Subject: [PATCH] style[ParameterValidator]: make code conform to google checks --- .../group5/app/utils/ParameterValidator.java | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/group5/app/utils/ParameterValidator.java b/src/main/java/edu/group5/app/utils/ParameterValidator.java index 1a44e46..996bf6e 100644 --- a/src/main/java/edu/group5/app/utils/ParameterValidator.java +++ b/src/main/java/edu/group5/app/utils/ParameterValidator.java @@ -1,21 +1,24 @@ package edu.group5.app.utils; import java.math.BigDecimal; + /** - * ParameterValidator is a utility class that provides static methods for validating various types of parameters. - * It includes methods for checking strings, integers, objects, and BigDecimal values to ensure they meet specific - * criteria such as not being null, not being blank, or being positive. - * + * ParameterValidator is a utility class that provides static methods for validating various types + * of parameters. + * It includes methods for checking strings, integers, objects, and BigDecimal values to ensure + * they meet specific criteria such as not being null, not being blank, or being positive. */ public final class ParameterValidator { /** * Validates that a string parameter is not null and not blank. + * * @param stringArg the string parameter to validate * @param variableName the name of the variable being validated, used in exception messages * @throws IllegalArgumentException if the string is null or blank */ - public static final void stringChecker(String stringArg, String variableName) throws IllegalArgumentException { + public static final void stringChecker(String stringArg, String variableName) + throws IllegalArgumentException { nullCheck(stringArg, variableName); if (stringArg.isBlank()) { throw new IllegalArgumentException(String.format("%s can't be blank", variableName)); @@ -24,33 +27,41 @@ public static final void stringChecker(String stringArg, String variableName) th /** * Validates that an integer parameter is not null and is a positive integer. + * * @param intArg the integer parameter to validate * @param variableName the name of the variable being validated, used in exception messages * @throws IllegalArgumentException if the integer is null or not a positive integer */ - public static final void intChecker(int intArg, String variableName) throws IllegalArgumentException { + public static final void intChecker(int intArg, String variableName) + throws IllegalArgumentException { if (intArg <= 0) { - throw new IllegalArgumentException(String.format("%s must be a positive integer", variableName)); + throw new IllegalArgumentException( + String.format("%s must be a positive integer", variableName) + ); } } /** * Validates that an object parameter is not null. + * * @param objectArg the object parameter to validate * @param variableName the name of the variable being validated, used in exception messages * @throws IllegalArgumentException if the object is null */ - public static final void objectChecker(Object objectArg, String variableName) throws IllegalArgumentException { + public static final void objectChecker(Object objectArg, String variableName) + throws IllegalArgumentException { nullCheck(objectArg, variableName); } /** * Validates that a BigDecimal parameter is not null and is greater than zero. + * * @param bigDecimalArg the BigDecimal parameter to validate * @param variableName the name of the variable being validated, used in exception messages * @throws IllegalArgumentException if the BigDecimal is null or not greater than zero */ - public static final void bigDecimalChecker(BigDecimal bigDecimalArg, String variableName) throws IllegalArgumentException { + public static final void bigDecimalChecker(BigDecimal bigDecimalArg, String variableName) + throws IllegalArgumentException { nullCheck(bigDecimalArg, variableName); if (bigDecimalArg.compareTo(BigDecimal.ZERO) <= 0) { throw new IllegalArgumentException(String.format("%s must be larger than 0", variableName)); @@ -58,12 +69,15 @@ public static final void bigDecimalChecker(BigDecimal bigDecimalArg, String vari } /** - * Helper method to check if a variable is null and throw an IllegalArgumentException with a formatted message if it is. + * Helper method to check if a variable is null and throw an IllegalArgumentException with a + * formatted message if it is. + * * @param variable the variable to check for null * @param variableName the name of the variable being checked, used in the exception message * @throws IllegalArgumentException if the variable is null */ - private static final void nullCheck(Object variable, String variableName) throws IllegalArgumentException { + private static final void nullCheck(Object variable, String variableName) + throws IllegalArgumentException { if (variable == null) { throw new IllegalArgumentException(String.format("%s can't be null", variableName)); }