Package com.alibaba.fastjson2.util
Class BeanUtils
java.lang.Object
com.alibaba.fastjson2.util.BeanUtils
- Author:
- Bob Lee, Jesse Wilson, Shaojin Wen
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidannotationMethods(Class objectClass, Consumer<Method> methodConsumer) static GenericArrayTypeReturns an array type whose elements are all instances ofcomponentType.static MethodbuildMethod(Class objectClass, String methodName) static Typecanonicalize(Type type) Returns a type that is functionally equal but not necessarily equal according toObject.equals().static voidcleanupCache(Class objectClass) static voidcleanupCache(ClassLoader classLoader) static voidconstructor(Class objectClass, Consumer<Constructor> constructorConsumer) static voiddeclaredFields(Class objectClass, Consumer<Field> fieldConsumer) ignore static fieldsstatic booleanReturns true ifaandbare equal.static Stringstatic voidstatic <A extends Annotation>
AfindAnnotation(Annotation annotation, Class<A> annotationType) If theannotation's annotationType is notannotationType, then to find the first annotation ofannotationTypethat is either directly present, meta-present, or indirectly present on the suppliedelement.static <A extends Annotation>
AfindAnnotation(AnnotatedElement element, Class<A> annotationType) Find the first annotation ofannotationTypethat is either directly present, meta-present, or indirectly present on the suppliedelement.static MethodfluentSetter(Class objectClass, String methodName, Class paramType) static Annotation[]getAnnotations(AnnotatedElement element) static Constructor[]getConstructor(Class objectClass) static FieldgetDeclaredField(Class objectClass, String fieldName) static ConstructorgetDefaultConstructor(Class objectClass, boolean includeNoneStaticMember) static String[]getEnumAnnotationNames(Class enumClass) static MembergetEnumValueField(Class enumClass, ObjectCodecProvider mixinProvider) static Fieldstatic TypegetFieldType(TypeReference typeReference, Class<?> raw, Member field, Type fieldType) static Methodstatic Methodstatic TypegetParamType(TypeReference type, Class<?> raw, Class declaringClass, Parameter field, Type fieldType) static Class<?>getRawType(Type type) static String[]getRecordFieldNames(Class<?> recordType) static Methodstatic StringgetterName(Method method, boolean kotlin, String namingStrategy) static StringgetterName(Method method, String namingStrategy) static StringgetterName(String methodName, String namingStrategy) static voidstatic voidstatic voidstatic booleanhasPublicDefaultConstructor(Class objectClass) static booleanisExtendedMap(Class objectClass) static booleanisNoneStaticMemberClass(Class objectClass, Class memberClass) static booleanstatic booleanisWriteEnumAsJavaBean(Class clazz) static ParameterizedTypenewParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments) Returns a new parameterized type, applyingtypeArgumentstorawTypeand enclosed byownerType.static voidprocessGsonSerializedName(FieldInfo fieldInfo, Annotation annotation) static voidprocessJacksonJsonFormat(BeanInfo beanInfo, Annotation annotation) static voidprocessJacksonJsonFormat(FieldInfo fieldInfo, Annotation annotation) static voidprocessJacksonJsonIgnore(FieldInfo fieldInfo, Annotation annotation) static voidprocessJacksonJsonInclude(BeanInfo beanInfo, Annotation annotation) static voidprocessJacksonJsonInclude(FieldInfo fieldInfo, Annotation annotation) static voidprocessJacksonJsonSubTypesType(BeanInfo beanInfo, int index, Annotation annotation) static voidprocessJacksonJsonTypeName(BeanInfo beanInfo, Annotation annotation) static voidprocessJacksonJsonUnwrapped(FieldInfo fieldInfo, Annotation annotation) static voidprocessJSONType1x(BeanInfo beanInfo, Annotation jsonType1x, Method method) static Typestatic voidsetNoneStaticMemberClassParent(Object object, Object parent) static StringsetterName(String methodName, int prefixLength) static StringsetterName(String methodName, String namingStrategy) static voidstatic voidstatic voidstatic voidstatic voidstaticMethod(Class objectClass, Consumer<Method> methodConsumer) static WildcardTypeReturns a type that represents an unknown type that extendsbound.static WildcardTypesupertypeOf(Type bound) Returns a type that represents an unknown supertype ofbound.static StringtypeToString(Type type)
-
Field Details
-
SUPER
- See Also:
-
-
Constructor Details
-
BeanUtils
public BeanUtils()
-
-
Method Details
-
getRecordFieldNames
-
fields
-
getMethod
-
fluentSetter
-
getMethod
-
getDeclaredField
-
getSetter
-
declaredFields
ignore static fields -
staticMethod
-
buildMethod
-
constructor
-
getConstructor
-
hasPublicDefaultConstructor
-
getDefaultConstructor
-
setters
-
setters
-
setters
-
setters
-
annotationMethods
-
isWriteEnumAsJavaBean
-
getEnumAnnotationNames
-
getEnumValueField
-
getters
-
getters
-
getters
-
isRecord
-
setterName
-
setterName
-
getterName
-
getterName
-
getField
-
getterName
-
fieldName
-
getFieldType
public static Type getFieldType(TypeReference typeReference, Class<?> raw, Member field, Type fieldType) -
getParamType
-
newParameterizedTypeWithOwner
public static ParameterizedType newParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments) Returns a new parameterized type, applyingtypeArgumentstorawTypeand enclosed byownerType.- Returns:
- a
serializableparameterized type.
-
arrayOf
Returns an array type whose elements are all instances ofcomponentType.- Returns:
- a
serializablegeneric array type.
-
subtypeOf
Returns a type that represents an unknown type that extendsbound. For example, ifboundisCharSequence.class, this returns? extends CharSequence. IfboundisObject.class, this returns?, which is shorthand for? extends Object. -
supertypeOf
Returns a type that represents an unknown supertype ofbound. For example, ifboundisString.class, this returns? super String. -
canonicalize
Returns a type that is functionally equal but not necessarily equal according toObject.equals(). The returned type isSerializable. -
getRawType
-
equals
Returns true ifaandbare equal. -
typeToString
-
resolve
-
findAnnotation
public static <A extends Annotation> A findAnnotation(AnnotatedElement element, Class<A> annotationType) Find the first annotation ofannotationTypethat is either directly present, meta-present, or indirectly present on the suppliedelement.If the element is a class and the annotation is neither directly present nor meta-present on the class, this method will additionally search on interfaces implemented by the class before finding an annotation that is indirectly present on the class.
- Type Parameters:
A- the annotation- Parameters:
element- the element on which to search for the annotationannotationType- the annotation type of need to search- Returns:
- the searched annotation type
-
findAnnotation
public static <A extends Annotation> A findAnnotation(Annotation annotation, Class<A> annotationType) If theannotation's annotationType is notannotationType, then to find the first annotation ofannotationTypethat is either directly present, meta-present, or indirectly present on the suppliedelement.- Type Parameters:
A- the searched annotation type- Parameters:
annotation- annotationannotationType- the annotation type of need to search- Returns:
- the searched annotation
-
getAnnotations
-
processJacksonJsonIgnore
-
isNoneStaticMemberClass
-
setNoneStaticMemberClassParent
-
cleanupCache
-
cleanupCache
-
processJSONType1x
-
processJacksonJsonFormat
-
processJacksonJsonFormat
-
processJacksonJsonInclude
-
processJacksonJsonInclude
-
processJacksonJsonUnwrapped
-
processJacksonJsonTypeName
-
processJacksonJsonSubTypesType
public static void processJacksonJsonSubTypesType(BeanInfo beanInfo, int index, Annotation annotation) -
processGsonSerializedName
-
isExtendedMap
-