パッケージ org.springframework.core

クラス MethodParameter

java.lang.ObjectSE
org.springframework.core.MethodParameter
既知の直属サブクラス
SynthesizingMethodParameter

public class MethodParameter extends ObjectSE
メソッドパラメーターの仕様をカプセル化するヘルパークラス。つまり、MethodSE または ConstructorSE に加えて、宣言されたジェネリクス型のパラメーターインデックスとネストされた型インデックス。渡すための仕様オブジェクトとして有用です。

4.2 の時点で、属性エイリアスを使用してアノテーションを合成する SynthesizingMethodParameter サブクラスが利用可能です。そのサブクラスは、特に Web およびメッセージエンドポイントの処理に使用されます。

導入:
2.0
作成者:
Juergen Hoeller, Rob Harrop, Andy Clement, Sam Brannen, Sebastien Deleuze, Phillip Webb
関連事項:
  • コンストラクターの詳細

    • MethodParameter

      public MethodParameter(MethodSE method, int parameterIndex)
      ネストレベル 1 で、指定されたメソッドの新しい MethodParameter を作成します。
      パラメーター:
      method - パラメーターを指定するメソッド
      parameterIndex - パラメーターのインデックス: メソッドの戻り値の型の場合は -1。最初のメソッドパラメーターの場合は 0。2 番目のメソッドパラメーターなどの場合は 1
    • MethodParameter

      public MethodParameter(MethodSE method, int parameterIndex, int nestingLevel)
      指定されたメソッドの新しい MethodParameter を作成します。
      パラメーター:
      method - パラメーターを指定するメソッド
      parameterIndex - パラメーターのインデックス: メソッドの戻り値の型の場合は -1。最初のメソッドパラメーターの場合は 0。2 番目のメソッドパラメーターなどの場合は 1
      nestingLevel - ターゲット型のネストレベル (通常 1。たとえばリストのリストの場合、1 はネストされたリストを示し、2 はネストされたリストの要素を示します)
    • MethodParameter

      public MethodParameter(ConstructorSE<?> constructor, int parameterIndex)
      ネストレベル 1 で、指定されたコンストラクターの新しい MethodParameter を作成します。
      パラメーター:
      constructor - パラメーターを指定するコンストラクター
      parameterIndex - パラメーターのインデックス
    • MethodParameter

      public MethodParameter(ConstructorSE<?> constructor, int parameterIndex, int nestingLevel)
      指定されたコンストラクターの新しい MethodParameter を作成します。
      パラメーター:
      constructor - パラメーターを指定するコンストラクター
      parameterIndex - パラメーターのインデックス
      nestingLevel - ターゲット型のネストレベル (通常 1。たとえばリストのリストの場合、1 はネストされたリストを示し、2 はネストされたリストの要素を示します)
    • MethodParameter

      public MethodParameter(MethodParameter original)
      コピーコンストラクター。元のオブジェクトと同じメタデータとキャッシュ状態に基づいて、独立した MethodParameter オブジェクトを作成します。
      パラメーター:
      original - コピー元の MethodParameter オブジェクト
  • メソッドの詳細

    • getMethod

      @Nullable public MethodSE getMethod()
      ラップされたメソッドがあれば返します。

      メモ: Method または Constructor のいずれかを使用できます。

      戻り値:
      メソッド、または存在しない場合は null 
    • getConstructor

      @Nullable public ConstructorSE<?> getConstructor()
      ラップされたコンストラクターがある場合はそれを返します。

      メモ: Method または Constructor のいずれかを使用できます。

      戻り値:
      コンストラクター、または存在しない場合は null 
    • getDeclaringClass

      public ClassSE<?> getDeclaringClass()
      基になるメソッドまたはコンストラクターを宣言するクラスを返します。
    • getMember

      public MemberSE getMember()
      ラップされたメンバーを返します。
      戻り値:
      メンバーとしてのメソッドまたはコンストラクター
    • getAnnotatedElement

      public AnnotatedElementSE getAnnotatedElement()
      ラップされたアノテーション付き要素を返します。

      メモ: このメソッドは、メソッド / コンストラクター自体で(つまり、パラメーターレベルではなく、メソッド / コンストラクターレベルで)宣言されたアノテーションを公開します。

      AnnotatedElementSE をパラメーターレベルで取得するには、getParameter() を使用します。

      戻り値:
      AnnotatedElement としてのメソッドまたはコンストラクター
    • getExecutable

      public ExecutableSE getExecutable()
      ラップされた実行可能ファイルを返します。
      戻り値:
      メソッドまたはコンストラクターを実行可能ファイルとして
      導入:
      5.0
    • getParameter

      public ParameterSE getParameter()
      メソッド / コンストラクターパラメーターの ParameterSE 記述子を返します。
      導入:
      5.0
    • getParameterIndex

      public int getParameterIndex()
      メソッド / コンストラクターパラメーターのインデックスを返します。
      戻り値:
      パラメーターインデックス (-1 戻り型の場合)
    • increaseNestingLevel

      @DeprecatedSE public void increaseNestingLevel()
      使用すべきではありません。
      5.2 以降、nested(Integer) を推奨
      このパラメーターのネストレベルを上げます。
      関連事項:
    • decreaseNestingLevel

      @DeprecatedSE public void decreaseNestingLevel()
      使用すべきではありません。
      5.2 は元の MethodParameter を保持し、ネストが必要な場合は nested(Integer) を使用するため
      このパラメーターのネストレベルを下げます。
      関連事項:
    • getNestingLevel

      public int getNestingLevel()
      ターゲット型のネストレベルを返します(通常 1。たとえば、リストのリストの場合、1 はネストされたリストを示し、2 はネストされたリストの要素を示します)。
    • withTypeIndex

      public MethodParameter withTypeIndex(int typeIndex)
      現在のレベルの型を指定された値に設定して、この MethodParameter のバリアントを返します。
      パラメーター:
      typeIndex - 新しい型のインデックス
      導入:
      5.2
    • setTypeIndexForCurrentLevel

      @DeprecatedSE public void setTypeIndexForCurrentLevel(int typeIndex)
      使用すべきではありません。
      5.2 以降、withTypeIndex(int) を推奨
      現在のネストレベルの型インデックスを設定します。
      パラメーター:
      typeIndex - 対応する型インデックス (または、デフォルトの型インデックスの場合は null )
      関連事項:
    • getTypeIndexForCurrentLevel

      @Nullable public IntegerSE getTypeIndexForCurrentLevel()
      現在のネストレベルの型インデックスを返します。
      戻り値:
      対応する型インデックス、または指定されていない場合は null (デフォルトの型インデックスを示す)
      関連事項:
    • getTypeIndexForLevel

      @Nullable public IntegerSE getTypeIndexForLevel(int nestingLevel)
      指定されたネストレベルの型インデックスを返します。
      パラメーター:
      nestingLevel - チェックするネストレベル
      戻り値:
      対応する型インデックス、または指定されていない場合は null (デフォルトの型インデックスを示す)
    • nested

      public MethodParameter nested()
      この MethodParameter のバリアントを返します。これは、同じパラメーターを指しますが、ネストレベルが 1 つ深くなります。
      導入:
      4.3
    • nested

      public MethodParameter nested(@Nullable IntegerSE typeIndex)
      この MethodParameter のバリアントを返します。これは、同じパラメーターを指しますが、ネストレベルが 1 つ深くなります。
      パラメーター:
      typeIndex - 新しいネストレベルの型インデックス
      導入:
      5.2
    • isOptional

      public boolean isOptional()
      このメソッドが不要なパラメーターを示しているかどうかを返します: Java 8 の OptionalSE の形式、パラメーターレベルの Nullable アノテーション(JSR-305 または FindBugs のアノテーションセットなど)のいずれかの形式、または言語レベルの nullable Kotlin の型宣言または Continuation パラメーター。
      導入:
      4.3
    • nestedIfOptional

      public MethodParameter nestedIfOptional()
      OptionalSE 宣言の場合、同じパラメーターを指しますが、ネストレベルが 1 つ深いこの MethodParameter のバリアントを返します。
      導入:
      4.3
      関連事項:
    • withContainingClass

      public MethodParameter withContainingClass(@Nullable ClassSE<?> containingClass)
      指定された包含クラスを参照するこの MethodParameter のバリアントを返します。
      パラメーター:
      containingClass - 特定の包含クラス (潜在的に宣言クラスのサブクラス、たとえば型変数の置換)
      導入:
      5.2
      関連事項:
    • getContainingClass

      public ClassSE<?> getContainingClass()
      このメソッドパラメーターの包含クラスを返します。
      戻り値:
      特定の包含クラス(潜在的に宣言クラスのサブクラス)、または単に宣言クラス自体
      関連事項:
    • getParameterType

      public ClassSE<?> getParameterType()
      メソッド / コンストラクターのパラメーターの型を返します。
      戻り値:
      パラメーター型 (非 null)
    • getGenericParameterType

      public TypeSE getGenericParameterType()
      メソッド / コンストラクターパラメーターのジェネリクス型を返します。
      戻り値:
      パラメーター型 (非 null)
      導入:
      3.0
    • getNestedParameterType

      public ClassSE<?> getNestedParameterType()
      メソッド / コンストラクターパラメーターのネストされた型を返します。
      戻り値:
      パラメーター型 (非 null)
      導入:
      3.1
      関連事項:
    • getNestedGenericParameterType

      public TypeSE getNestedGenericParameterType()
      メソッド / コンストラクターパラメーターのネストされたジェネリクス型を返します。
      戻り値:
      パラメーター型 (非 null)
      導入:
      4.2
      関連事項:
    • getMethodAnnotations

      public AnnotationSE[] getMethodAnnotations()
      ターゲットメソッド / コンストラクター自体に関連付けられているアノテーションを返します。
    • getMethodAnnotation

      @Nullable public <A extends AnnotationSE> A getMethodAnnotation(ClassSE<A> annotationType)
      可能な場合、指定された型のメソッド / コンストラクターアノテーションを返します。
      パラメーター:
      annotationType - 検索するアノテーション型
      戻り値:
      アノテーションオブジェクト、または見つからない場合は null 
    • hasMethodAnnotation

      public <A extends AnnotationSE> boolean hasMethodAnnotation(ClassSE<A> annotationType)
      メソッド / コンストラクターに指定された型のアノテーションが付けられているかどうかを返します。
      パラメーター:
      annotationType - 検索するアノテーション型
      導入:
      4.3
      関連事項:
    • getParameterAnnotations

      public AnnotationSE[] getParameterAnnotations()
      特定のメソッド / コンストラクターパラメーターに関連付けられているアノテーションを返します。
    • hasParameterAnnotations

      public boolean hasParameterAnnotations()
      パラメーターに少なくとも 1 つのアノテーションがある場合は true を返し、ない場合は false を返します。
      関連事項:
    • getParameterAnnotation

      @Nullable public <A extends AnnotationSE> A getParameterAnnotation(ClassSE<A> annotationType)
      使用可能な場合、指定された型のパラメーターアノテーションを返します。
      パラメーター:
      annotationType - 検索するアノテーション型
      戻り値:
      アノテーションオブジェクト、または見つからない場合は null 
    • hasParameterAnnotation

      public <A extends AnnotationSE> boolean hasParameterAnnotation(ClassSE<A> annotationType)
      指定されたアノテーション型でパラメーターが宣言されているかどうかを返します。
      パラメーター:
      annotationType - 検索するアノテーション型
      関連事項:
    • initParameterNameDiscovery

      public void initParameterNameDiscovery(@Nullable ParameterNameDiscoverer parameterNameDiscoverer)
      このメソッドパラメーターのパラメーター名の検出を初期化します。

      このメソッドは、実際にはこの時点でパラメーター名を取得しようとしません。アプリケーションが getParameterName() を呼び出したときにディスカバリが発生するようにします(もしあれば)。

    • getParameterName

      @Nullable public StringSE getParameterName()
      メソッド / コンストラクターのパラメーターの名前を返します。
      戻り値:
      パラメーター名 (クラスファイルにパラメーター名のメタデータが含まれていない場合、または ParameterNameDiscoverer が始まるように設定されていない場合は、null になります。)
    • adaptAnnotation

      protected <A extends AnnotationSE> A adaptAnnotation(A annotation)
      呼び出し元に返す前に特定のアノテーションインスタンスを後処理するテンプレートメソッド。

      デフォルトの実装は、指定されたアノテーションをそのまま返すだけです。

      パラメーター:
      annotation - 返されるアノテーション
      戻り値:
      後処理されたアノテーション (または単に元のもの)
      導入:
      4.2
    • adaptAnnotationArray

      protected AnnotationSE[] adaptAnnotationArray(AnnotationSE[] annotations)
      呼び出し元に返す前に特定のアノテーション配列を後処理するテンプレートメソッド。

      デフォルトの実装は、指定されたアノテーション配列をそのまま返すだけです。

      パラメーター:
      annotations - 返されようとしているアノテーション配列
      戻り値:
      後処理されたアノテーション配列 (または単に元のもの)
      導入:
      4.2
    • equals

      public boolean equals(@Nullable ObjectSE other)
      オーバーライド:
      クラス ObjectSEequalsSE 
    • hashCode

      public int hashCode()
      オーバーライド:
      クラス ObjectSEhashCode 
    • toString

      public StringSE toString()
      オーバーライド:
      クラス ObjectSEtoString 
    • clone

      public MethodParameter clone()
      オーバーライド:
      クラス ObjectSEclone 
    • forMethodOrConstructor

      @DeprecatedSE public static MethodParameter forMethodOrConstructor(ObjectSE methodOrConstructor, int parameterIndex)
      使用すべきではありません。
      指定されたメソッドまたはコンストラクターの新しい MethodParameter を作成します。

      これは、メソッドまたはコンストラクターの参照が一般的な方法で処理されるシナリオの便利なファクトリメソッドです。

      パラメーター:
      methodOrConstructor - パラメーターを指定するメソッドまたはコンストラクター
      parameterIndex - パラメーターのインデックス
      戻り値:
      対応する MethodParameter インスタンス
    • forExecutable

      public static MethodParameter forExecutable(ExecutableSE executable, int parameterIndex)
      指定されたメソッドまたはコンストラクターの新しい MethodParameter を作成します。

      これは、メソッドまたはコンストラクターの参照が一般的な方法で処理されるシナリオの便利なファクトリメソッドです。

      パラメーター:
      executable - パラメーターを指定するメソッドまたはコンストラクター
      parameterIndex - パラメーターのインデックス
      戻り値:
      対応する MethodParameter インスタンス
      導入:
      5.0
    • forParameter

      public static MethodParameter forParameter(ParameterSE parameter)
      指定されたパラメーター記述子の新しい MethodParameter を作成します。

      これは、Java 8 ParameterSE 記述子がすでに利用可能なシナリオの便利なファクトリメソッドです。

      パラメーター:
      parameter - パラメーター記述子
      戻り値:
      対応する MethodParameter インスタンス
      導入:
      5.0
    • findParameterIndex

      protected static int findParameterIndex(ParameterSE parameter)
    • forFieldAwareConstructor

      public static MethodParameter forFieldAwareConstructor(ConstructorSE<?> ctor, int parameterIndex, StringSE fieldName)
      指定されたフィールド対応コンストラクターに対して新しい MethodParameter を作成します。データクラスまたはレコード型に基づいて。

      フィールド対応メソッドパラメーターは、フィールド名がパラメーター名と一致する限り、フィールドアノテーションも検出します。

      パラメーター:
      ctor - パラメーターを指定するコンストラクター
      parameterIndex - パラメーターのインデックス
      fieldName - コンストラクターのパラメーター名と一致する、基になるフィールドの名前
      戻り値:
      対応する MethodParameter インスタンス
      導入:
      6.1