public final class ReflectionUtils extends ObjectSE
修飾子と型 | クラスと説明 |
---|---|
static class | ReflectionUtils.AnnotationFieldFilter 指定されたアノテーションの ReflectionUtils.FieldFilter 。 |
static interface | ReflectionUtils.DescribedFieldFilter 説明のある ReflectionUtils.FieldFilter 。 |
修飾子と型 | メソッドと説明 |
---|---|
static <T> T | createInstanceIfPresent(StringSE classname, T defaultInstance) 指定された完全修飾名でクラスのインスタンスを作成するか、クラスをロードまたはインスタンス化できない場合は、指定されたデフォルトインスタンスを返します。 |
static OptionalSE<ConstructorSE<?>> | findConstructor(ClassSE<?> type, ObjectSE... constructorArguments) 指定されたコンストラクター引数に一致する、指定された型のコンストラクターを検索します。 |
static FieldSE | findField(ClassSE<?> type, ReflectionUtils.DescribedFieldFilter filter) 指定された ReflectionUtils.DescribedFieldFilter に一致するフィールドを検索します。 |
static FieldSE | findField(ClassSE<?> type, ReflectionUtils.DescribedFieldFilter filter, boolean enforceUniqueness) 指定された ReflectionUtils.DescribedFieldFilter に一致するフィールドを検索します。 |
static FieldSE | findField(ClassSE<?> type, ReflectionUtils.FieldFilter filter) 指定された ReflectionUtils.FieldFilter に一致する指定されたクラスの最初のフィールドを検索します。 |
static FieldSE | findRequiredField(ClassSE<?> type, StringSE name) 指定された型の指定された名前のフィールドを検索します。 |
static MethodSE | findRequiredMethod(ClassSE<?> type, StringSE name, ClassSE<?>... parameterTypes) 指定されたクラスおよびパラメーター型の指定された名前のメソッドを返します。 |
static OptionalSE<MethodSE> | getMethod(ClassSE<?> type, StringSE name, ResolvableType... parameterTypes) 可能な場合は、指定された型で宣言された指定された名前とパラメーターを持つ Method SE を返します。 |
static ObjectSE | getPrimitiveDefault(ClassSE<?> type) プリミティブ型のデフォルト値を取得します。 |
static boolean | isKotlinClass(ClassSE<?> type) 使用すべきではありません。 2.3 以降、代わりに KotlinDetector.isKotlinType(Class) を使用してください。 |
static boolean | isNullable(MethodParameter parameter) 指定された MethodParameter が NULL 可能かどうかを返します。 |
static boolean | isSupportedKotlinClass(ClassSE<?> type) 使用すべきではありません。 2.3 以降、代わりに KotlinReflectionUtils.isSupportedKotlinClass(Class) を使用してください。 |
static boolean | isVoid(ClassSE<?> type) |
static ClassSE<?> | loadIfPresent(StringSE name, ClassLoaderSE classLoader) 指定された ClassLoader SE を使用して、指定された名前でクラスをロードします。 |
static StreamSE<ClassSE<?>> | returnTypeAndParameters(MethodSE method) |
static void | setField(FieldSE field, ObjectSE target, ObjectSE value) 指定されたオブジェクトの指定されたフィールドを指定された値に設定します。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public static <T> T createInstanceIfPresent(StringSE classname, T defaultInstance)
classname
- インスタンスを作成するための完全修飾クラス名。defaultInstance
- 指定されたクラスをロードまたはインスタンス化できない場合にフォールバックするインスタンス。public static boolean isVoid(ClassSE<?> type)
type
- null であってはなりません。@Nullable public static FieldSE findField(ClassSE<?> type, ReflectionUtils.FieldFilter filter)
ReflectionUtils.FieldFilter
に一致する指定されたクラスの最初のフィールドを検索します。type
- null であってはなりません。filter
- null であってはなりません。@Nullable public static FieldSE findField(ClassSE<?> type, ReflectionUtils.DescribedFieldFilter filter)
ReflectionUtils.DescribedFieldFilter
に一致するフィールドを検索します。フィルターに一致するフィールドが 1 つだけであることを確認します。type
- null であってはなりません。filter
- null であってはなりません。ReflectionUtils.DescribedFieldFilter
に一致するフィールド、または見つからない場合は null。IllegalStateExceptionSE
- 一致するフィールドが複数見つかった場合 findField(Class, DescribedFieldFilter, boolean)
@Nullable public static FieldSE findField(ClassSE<?> type, ReflectionUtils.DescribedFieldFilter filter, boolean enforceUniqueness)
ReflectionUtils.DescribedFieldFilter
に一致するフィールドを検索します。enforceUniqueness
が真の場合、フィルターに一致するフィールドが 1 つだけであることを確認します。type
- null であってはなりません。filter
- null であってはなりません。enforceUniqueness
- フィールドの一意性を強制するかどうか ReflectionUtils.DescribedFieldFilter
に一致するフィールド、または見つからない場合は null。IllegalStateExceptionSE
- EnforceUniqueness が true で、一致するフィールドが複数見つかった場合 public static FieldSE findRequiredField(ClassSE<?> type, StringSE name)
type
- null であってはなりません。name
- null または空であってはなりません。IllegalArgumentExceptionSE
- フィールドが見つからない場合。public static void setField(FieldSE field, ObjectSE target, @Nullable ObjectSE value)
field
- null であってはなりません。target
- null であってはなりません。value
-public static OptionalSE<ConstructorSE<?>> findConstructor(ClassSE<?> type, ObjectSE... constructorArguments)
type
- null であってはなりません。constructorArguments
- null であってはなりません。Constructor
SE。public static MethodSE findRequiredMethod(ClassSE<?> type, StringSE name, ClassSE<?>... parameterTypes)
bridge
SE および synthetic
SE の方法よりも通常の方法を優先します。type
- null であってはなりません。name
- null であってはなりません。parameterTypes
- null であってはなりません。IllegalArgumentExceptionSE
- メソッドを解決できない場合。public static StreamSE<ClassSE<?>> returnTypeAndParameters(MethodSE method)
method
- null であってはなりません。public static OptionalSE<MethodSE> getMethod(ClassSE<?> type, StringSE name, ResolvableType... parameterTypes)
Method
SE を返します。type
- null であってはなりません。name
- null または空であってはなりません。parameterTypes
- null であってはなりません。@DeprecatedSE public static boolean isKotlinClass(ClassSE<?> type)
KotlinDetector.isKotlinType(Class)
を使用してください。type
が Kotlin クラスの場合は true。@DeprecatedSE public static boolean isSupportedKotlinClass(ClassSE<?> type)
KotlinReflectionUtils.isSupportedKotlinClass(Class)
を使用してください。type
がサポートされている Kotlin クラスの場合は true。public static boolean isNullable(MethodParameter parameter)
MethodParameter
が NULL 可能かどうかを返します。null 可能パラメーターは、参照型であり、Kotlin でそのように定義されているものです。MethodParameter
が NULL 可能である場合は true。public static ObjectSE getPrimitiveDefault(ClassSE<?> type)
type
- null であってはなりません。@Nullable public static ClassSE<?> loadIfPresent(StringSE name, ClassLoaderSE classLoader)
ClassLoader
SE を使用して、指定された名前でクラスをロードします。name
- ロードするクラスの名前。classLoader
- クラスのロードに使用する ClassLoader
SE。Class
SE、または何らかの理由でクラスをロードできない場合は null。Copyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.