クラス ReflectionUtils
java.lang.ObjectSE
org.springframework.data.util.ReflectionUtils
Spring Data 固有のリフレクションユーティリティのメソッドとクラス。
- 導入:
- 1.5
- 作成者:
- Oliver Gierke, Thomas Darimont, Christoph Strobl, Mark Paluch, Johannes Englmeier
ネストされたクラスの要約
ネストされたクラス修飾子と型クラス説明static class指定されたアノテーションのReflectionUtils.FieldFilter。static interface説明のあるReflectionUtils.FieldFilter。メソッドのサマリー
修飾子と型メソッド説明static <T> @Nullable ConstructorSE<T> findConstructor(ClassSE<T> type, ObjectSE... constructorArguments) 指定されたコンストラクター引数に一致する、指定された型のコンストラクターを検索します。static @Nullable FieldSEfindField(ClassSE<?> type, ReflectionUtils.DescribedFieldFilter filter) 指定されたReflectionUtils.DescribedFieldFilterに一致するフィールドを検索します。static @Nullable FieldSEfindField(ClassSE<?> type, ReflectionUtils.DescribedFieldFilter filter, boolean enforceUniqueness) 指定されたReflectionUtils.DescribedFieldFilterに一致するフィールドを検索します。static @Nullable FieldSEfindField(ClassSE<?> type, ReflectionUtils.FieldFilter filter) 指定されたReflectionUtils.FieldFilterに一致する指定されたクラスの最初のフィールドを検索します。static @Nullable MethodSEfindMethod(ClassSE<?> type, StringSE name, ResolvableType... parameterTypes) 可能な場合は、指定された型で宣言された指定された名前とパラメーターを持つMethodSE を返します。static MethodSEfindRequiredMethod(ClassSE<?> type, StringSE name, ClassSE<?>... parameterTypes) 使用すべきではありません。static intgetParameterCount(MethodSE method, PredicateSE<ClassSE<?>> predicate) PredicateSE の一致するパラメーターMethodSE の数を返します。static ObjectSEgetPrimitiveDefault(ClassSE<?> type) プリミティブ型のデフォルト値を取得します。static FieldSEgetRequiredField(ClassSE<?> type, StringSE name) 指定された型で指定された名前の必須フィールドを取得するか、見つからない場合はIllegalArgumentExceptionSE をスローします。static MethodSEgetRequiredMethod(ClassSE<?> type, StringSE name, ClassSE<?>... parameterTypes) 指定されたクラスおよびパラメーター型の指定された名前のメソッドを返します。static booleanhasParameterAssignableToType(MethodSE method, ClassSE<?> type) 指定されたMethodSE に、指定された型に割り当て可能なパラメーターがあるかどうかを返します。static booleanhasParameterOfType(MethodSE method, ClassSE<?> type) 指定されたMethodSE に指定された型のパラメーターがあるかどうかを返します。static booleanisNullable(MethodParameter parameter) 指定されたMethodParameterが NULL 可能かどうかを返します。static booleanreturnTypeAndParameters(MethodSE method) static void指定されたオブジェクトの指定されたフィールドを指定された値に設定します。static StringSE完全修飾クラス名を使用して、指定されたメソッドの名前とパラメーターを含む文字列表現を返します。static StringSEtoString(MethodSE method, FunctionSE<ClassSE<?>, StringSE> typeNameMapper) Returns a string representation of the given method including its name and parameter types.
メソッドの詳細
hasParameterOfType
hasParameterAssignableToType
getParameterCount
PredicateSE の一致するパラメーターMethodSE の数を返します。isVoid
findField
指定されたReflectionUtils.FieldFilterに一致する指定されたクラスの最初のフィールドを検索します。- パラメーター:
type- null であってはなりません。filter- null であってはなりません。- 戻り値:
- フィルターに一致するフィールド。フィールドが見つからなかった場合は null。
findField
public static @Nullable FieldSE findField(ClassSE<?> type, ReflectionUtils.DescribedFieldFilter filter) 指定されたReflectionUtils.DescribedFieldFilterに一致するフィールドを検索します。フィルターに一致するフィールドが 1 つだけであることを確認します。- パラメーター:
type- null であってはなりません。filter- null であってはなりません。- 戻り値:
- 指定された
ReflectionUtils.DescribedFieldFilterに一致するフィールド、または見つからない場合は null。 - 例外:
IllegalStateExceptionSE- 一致するフィールドが複数見つかった場合- 関連事項:
findField
public static @Nullable FieldSE findField(ClassSE<?> type, ReflectionUtils.DescribedFieldFilter filter, boolean enforceUniqueness) 指定されたReflectionUtils.DescribedFieldFilterに一致するフィールドを検索します。enforceUniquenessが真の場合、フィルターに一致するフィールドが 1 つだけであることを確認します。- パラメーター:
type- null であってはなりません。filter- null であってはなりません。enforceUniqueness- フィールドの一意性を強制するかどうか- 戻り値:
- 指定された
ReflectionUtils.DescribedFieldFilterに一致するフィールド、または見つからない場合は null。 - 例外:
IllegalStateExceptionSE- enforceUniqueness が真で、一致するフィールドが複数見つかった場合
getRequiredField
指定された型で指定された名前の必須フィールドを取得するか、見つからない場合はIllegalArgumentExceptionSE をスローします。- パラメーター:
type- null であってはなりません。name- null または空であってはなりません。- 戻り値:
- 必須フィールド。
- 例外:
IllegalArgumentExceptionSE- フィールドが見つからない場合。
setField
findConstructor
public static <T> @Nullable ConstructorSE<T> findConstructor(ClassSE<T> type, ObjectSE... constructorArguments) 指定されたコンストラクター引数に一致する、指定された型のコンストラクターを検索します。- パラメーター:
type- null であってはなりません。constructorArguments- null であってはなりません。- 戻り値:
- 指定された引数と互換性のある
ConstructorSE。
findRequiredMethod
@DeprecatedSE public static MethodSE findRequiredMethod(ClassSE<?> type, StringSE name, ClassSE<?>... parameterTypes) 使用すべきではありません。3.5 以降、代わりにgetRequiredMethod(Class, String, Class[])を使用してください。- パラメーター:
type- null であってはなりません。name- null であってはなりません。parameterTypes- null であってはなりません。- 戻り値:
- メソッドオブジェクト。
- 例外:
IllegalArgumentExceptionSE- メソッドを解決できない場合。
getRequiredMethod
public static MethodSE getRequiredMethod(ClassSE<?> type, StringSE name, ClassSE<?>... parameterTypes) - パラメーター:
type- null であってはなりません。name- null であってはなりません。parameterTypes- null であってはなりません。- 戻り値:
- メソッドオブジェクト。
- 例外:
IllegalArgumentExceptionSE- メソッドを解決できない場合。- 導入:
- 3.5
returnTypeAndParameters
findMethod
public static @Nullable MethodSE findMethod(ClassSE<?> type, StringSE name, ResolvableType... parameterTypes) 可能な場合は、指定された型で宣言された指定された名前とパラメーターを持つMethodSE を返します。- パラメーター:
type- null であってはなりません。name- null または空であってはなりません。parameterTypes- null であってはなりません。- 戻り値:
- 必要な方法。
- 導入:
- 3.5
toString
完全修飾クラス名を使用して、指定されたメソッドの名前とパラメーターを含む文字列表現を返します。In contrast to
Method.toString()this method omits the declaring type, the return type, any generics and modifiers.- パラメーター:
method- the method to render to string.- 戻り値:
- a string representation of the given method, i.e.
toString(java.lang.reflect.Method). - 導入:
- 4.0
toString
Returns a string representation of the given method including its name and parameter types.In contrast to
Method.toString()this method omits the declaring type, the return type, any generics and modifiers.- パラメーター:
method- the method to render to string.typeNameMapper- mapping function to obtain the type name from aClassSE。- 戻り値:
- a string representation of the given method, i.e.
toString(java.lang.reflect.Method)when using aType::getTypeName typeNameMapper. - 導入:
- 4.0
isNullable
指定されたMethodParameterが NULL 可能かどうかを返します。null 可能パラメーターは、参照型であり、Kotlin でそのように定義されているものです。- 戻り値:
MethodParameterが NULL 可能である場合は true。- 導入:
- 2.0
getPrimitiveDefault
getRequiredMethod(Class, String, Class[])を使用してください。