public class ReflectUtil extends Object
コンストラクタと説明 |
---|
ReflectUtil() |
修飾子とタイプ | メソッドと説明 |
---|---|
static Object |
executeGetter(Method method,
Object object)
getter実行
|
static void |
executeSetter(Method method,
Object object,
Object value)
setter実行
|
static List |
getDeclaredMethodsList(Object object,
String regex)
objectに定義されているメソッドの中から、正規表現regexに該当するメソッドを取得する
|
static List |
getMethodsList(Object object,
String regex)
objectに定義されているメソッドの中から、正規表現regexに該当するメソッドを取得する
|
static boolean |
isCorrectGetter(Method method)
methodがpublic String getter()であることをチェックする
getterメソッドの対象を抽出した上で、このメソッドを呼ぶこと |
static boolean |
isCorrectSetter(Method method)
methodがpublic void setter(String)であることをチェックする
setterメソッドの対象を抽出した上で、このメソッドを呼ぶこと |
static boolean |
matchedMethod(String methodName,
String regex)
指定のメソッド名が正規表現パターンにマッチするかをチェックする。
|
public static List getMethodsList(Object object, String regex)
object
- メソッド取得対象となるオブジェクトregex
- メソッドを抽出するための正規表現文字列List
オブジェクトpublic static List getDeclaredMethodsList(Object object, String regex)
object
- メソッド取得対象となるオブジェクトregex
- メソッドを抽出するための正規表現文字列List
オブジェクトpublic static boolean matchedMethod(String methodName, String regex)
methodName
- メソッド名文字列regex
- メソッドを抽出するための正規表現文字列public static boolean isCorrectGetter(Method method)
method
- チェック対象となるメソッドString
かString配列、Dtoクラスpublic static boolean isCorrectSetter(Method method)
method
- チェック対象となるメソッドString
、String配列、Dtoクラス、Dtoクラス配列public static Object executeGetter(Method method, Object object) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
method
- 実行対象となるgetterのMethod
object
- getterを保有するObject
Object
InvocationTargetException
IllegalAccessException
IllegalArgumentException
public static void executeSetter(Method method, Object object, Object value) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
method
- 実行対象となるsetterのMethod
object
- setterを保有するObject
value
- 設定する値Object
IllegalArgumentException
IllegalAccessException
InvocationTargetException
Copyright © 2024. All rights reserved.