From aa3213cbbee881ad13b21876be1cc7f6a7306870 Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Tue, 19 Sep 2023 08:51:42 +0800 Subject: [PATCH] refactor(devkit-utils): Changed the location of some codes. --- .../codecrafters/devkit/utils/MapUtil.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/MapUtil.java b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/MapUtil.java index ef54782..68ab6d4 100644 --- a/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/MapUtil.java +++ b/devkit-utils/src/main/java/cn/org/codecrafters/devkit/utils/MapUtil.java @@ -178,6 +178,22 @@ public final class MapUtil { method.invoke(obj, fieldValue); } + /** + * Casts the specified value to the required type. + * + * @param value the value to be cast + * @param requiredType the type to which the value should be cast + * @param the type to which the value should be cast + * @return the cast value, or null if the value cannot be cast to the + * required type + */ + public static T cast(Object value, Class requiredType) { + if (requiredType.isInstance(value)) { + return requiredType.cast(value); + } + return null; + } + /** * Constructs a method name based on the given prefix and field name. * @@ -203,20 +219,4 @@ public final class MapUtil { return String.valueOf(obj); } } - - /** - * Casts the specified value to the required type. - * - * @param value the value to be cast - * @param requiredType the type to which the value should be cast - * @param the type to which the value should be cast - * @return the cast value, or null if the value cannot be cast to the - * required type - */ - public static T cast(Object value, Class requiredType) { - if (requiredType.isInstance(value)) { - return requiredType.cast(value); - } - return null; - } }