refactor(devkit-utils): Changed the location of some codes.
This commit is contained in:
@@ -178,6 +178,22 @@ public final class MapUtil {
|
|||||||
method.invoke(obj, fieldValue);
|
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 <T> 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> T cast(Object value, Class<T> requiredType) {
|
||||||
|
if (requiredType.isInstance(value)) {
|
||||||
|
return requiredType.cast(value);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a method name based on the given prefix and field name.
|
* Constructs a method name based on the given prefix and field name.
|
||||||
*
|
*
|
||||||
@@ -203,20 +219,4 @@ public final class MapUtil {
|
|||||||
return String.valueOf(obj);
|
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 <T> 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> T cast(Object value, Class<T> requiredType) {
|
|
||||||
if (requiredType.isInstance(value)) {
|
|
||||||
return requiredType.cast(value);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user