diff --git a/src/main/java/com/houarizegai/calculator/util/ColorUtil.java b/src/main/java/com/houarizegai/calculator/util/ColorUtil.java index c2d0e4a..3536f0b 100644 --- a/src/main/java/com/houarizegai/calculator/util/ColorUtil.java +++ b/src/main/java/com/houarizegai/calculator/util/ColorUtil.java @@ -13,11 +13,14 @@ private ColorUtil() { * Converts a hexadecimal color code to a Color object. * * @param colorHex the hexadecimal color code to convert - * @return the Color object representing the hexadecimal color code, or null if the input is null + * @return the Color object representing the given hexadecimal color code, or null if the input is null * @throws NumberFormatException if the input is not a valid hexadecimal color code - * @example - * Color color = hex2Color("#FF0000"); - * // color is now a Color object representing the color red + * @throws StringIndexOutOfBoundsException if the input is not of the expected length + * + * Example: + *
{@code
+ * Color color = hex2Color("FFA500");
+ * }
*/
public static Color hex2Color(String colorHex) {
// test 1
@@ -27,6 +30,20 @@ public static Color hex2Color(String colorHex) {
Integer.valueOf(colorHex.substring(2, 4), 16),
Integer.valueOf(colorHex.substring(4, 6), 16)))
.orElse(null);
+ /**
+ * Converts a hexadecimal color code to a Color object.
+ *
+ * @param colorHex the hexadecimal color code to convert
+ * @param dType the type of color representation
+ * @return the Color object representing the given hexadecimal color code, or null if the input is null
+ * @throws NumberFormatException if the input hexadecimal color code is not in the expected format
+ * @throws NullPointerException if the input colorHex is null
+ *
+ * Example:
+ * {@code
+ * Color color = hex2Color("FFA500", "RGB");
+ * }
+ */
}