diff --git a/src/main/java/com/houarizegai/calculator/util/ColorUtil.java b/src/main/java/com/houarizegai/calculator/util/ColorUtil.java index 6ddff86..3c23fb2 100644 --- a/src/main/java/com/houarizegai/calculator/util/ColorUtil.java +++ b/src/main/java/com/houarizegai/calculator/util/ColorUtil.java @@ -19,6 +19,20 @@ private ColorUtil() { * Color color = hex2Color("#FF0000"); * // color is now a Color object representing the color red */ + /** + * Converts a hexadecimal color code to a Color object. + * + * @param colorHex the hexadecimal color code to convert + * @param dType the type of color code (e.g., "RGB", "CMYK") + * @return the Color object representing the hexadecimal color code, or null if the input is null + * @throws NumberFormatException if the input hexadecimal color code is not in the correct format + * @throws NullPointerException if the dType parameter is null + * + * Example: + *
{@code
+ * Color color = hex2Color("FFA500", "RGB");
+ * }
+ */
public static Color hex2Color(String colorHex) {
return Optional.ofNullable(colorHex )
.map(hex -> new Color (
@@ -29,6 +43,20 @@ public static Color hex2Color(String colorHex) {
}
+ /**
+ * Converts a hexadecimal color code to a Color object.
+ *
+ * @param colorHex the hexadecimal color code to convert
+ * @param dType the type of color representation (e.g. "RGB", "CMYK")
+ * @return the Color object representing the given hexadecimal color code
+ * @throws NumberFormatException if the input hexadecimal color code is invalid
+ * @throws NullPointerException if the input colorHex is null
+ *
+ * Example:
+ * {@code
+ * Color color = hex2Color("FFA500", "RGB");
+ * }
+ */
public static Color hex2Color(String colorHex, String dType) {
return Optional.ofNullable(colorHex )
.map(hex -> new Color (