Package org.skr.common.util
Class BeanUtil
java.lang.Object
org.skr.common.util.BeanUtil
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <R> RcallMethod(Class<?> clazz, Object object, @NonNull String methodName, Object... parameters) This method doesn't always function as expected.static <R,O> R callMethod(O object, @NonNull String methodName, Object... parameters) static <E> voidcopyFields(E source, E target) Copy Objectsourceto Objecttarget.static <E> voidcopyFields(E source, E target, boolean ignoreNullField, boolean includeOrExclude, String... fields) static <E> voidcopyFieldsExcluding(E source, E target, String... fields) static <E> voidcopyFieldsIncluding(E source, E target, String... fields) static <T extends Serializable>
TdeepClone(T o) static Class<?>getCollectionParameterizeType(@NonNull Parameter parameter) static MethodgetDeclaredMethod(@NonNull Class<?> clazz, @NonNull String methodName, Class<?>... parameterTypes) static Class<?>getFieldClass(@NonNull Object target, @NonNull String fieldName) static <T> TgetFieldValue(@NotNull Object target, @NotNull String path) static Methodstatic booleanisPrimitive(@NonNull Class<?> clazz) static booleanisPrimitive(Object val) static voidsetFieldValue(@NonNull Object target, @NonNull String fieldName, Object value)
-
Field Details
-
PRIMITIVE_TYPES
-
-
Constructor Details
-
BeanUtil
public BeanUtil()
-
-
Method Details
-
isPrimitive
-
isPrimitive
-
getCollectionParameterizeType
-
copyFields
public static <E> void copyFields(@NonNull E source, @NonNull E target) Copy Objectsourceto Objecttarget. This coping is not recursive. If a source field isCollection, it's element will beCollection.addAll(Collection)to corresponding target field, instead of copy theCollectionreference. Hence if target'sCollectionis not initialized and remains null, it won't be copied. -
copyFieldsExcluding
- Parameters:
fields- to be excluded for copying- See Also:
-
copyFieldsIncluding
- Parameters:
fields- to be included for copying- See Also:
-
copyFields
public static <E> void copyFields(@NonNull E source, @NonNull E target, boolean ignoreNullField, boolean includeOrExclude, String... fields) -
getFieldValue
-
getFieldClass
-
setFieldValue
-
deepClone
-
getDeclaredMethod
-
getMethod
-
callMethod
-
callMethod
public static <R> R callMethod(Class<?> clazz, Object object, @NonNull @NonNull String methodName, Object... parameters) This method doesn't always function as expected. Be 100% sure and tested when you use it. As known, this method is not worked for following case: * parameter type is primitive number, e.g. int.class * parameter type is general type, e.g. Object.class
-