@@ -30,6 +30,7 @@ import com.highcapable.kavaref.condition.type.Modifiers
3030import com.highcapable.kavaref.resolver.MethodResolver
3131import com.highcapable.kavaref.resolver.processor.MemberProcessor
3232import java.lang.reflect.Method
33+ import java.lang.reflect.Type
3334
3435/* *
3536 * Condition for [Method] of [MethodResolver].
@@ -42,6 +43,12 @@ class MethodCondition<T : Any> : ExecutableCondition<Method, MethodResolver<T>,
4243 /* * @see Method.getReturnType */
4344 var returnTypeCondition: ((Class <* >) -> Boolean )? = null
4445
46+ /* * @see Method.getGenericReturnType */
47+ var genericReturnType: TypeMatcher ? = null
48+
49+ /* * @see Method.getGenericReturnType */
50+ var genericReturnTypeCondition: ((Type ) -> Boolean )? = null
51+
4552 /* * @see Method.isBridge */
4653 var isBridge: Boolean? = null
4754
@@ -54,6 +61,12 @@ class MethodCondition<T : Any> : ExecutableCondition<Method, MethodResolver<T>,
5461 /* * @see Method.isDefault */
5562 var isDefaultNot: Boolean? = null
5663
64+ /* * @see Method.getDefaultValue */
65+ var defaultValue: Any? = null
66+
67+ /* * @see Method.getDefaultValue */
68+ var defaultValueCondition: ((Any? ) -> Boolean )? = null
69+
5770 override fun name (name : String ) = apply { super .name(name) }
5871 override fun name (condition : (String ) -> Boolean ) = apply { super .name(condition) }
5972 override fun modifiers (vararg modifiers : Modifiers ) = apply { super .modifiers(* modifiers) }
@@ -105,6 +118,16 @@ class MethodCondition<T : Any> : ExecutableCondition<Method, MethodResolver<T>,
105118 this .returnTypeCondition = condition
106119 }
107120
121+ /* * @see Method.getGenericReturnType */
122+ fun genericReturnType (type : TypeMatcher ) = apply {
123+ this .genericReturnType = type
124+ }
125+
126+ /* * @see Method.getGenericReturnType */
127+ fun genericReturnType (condition : (Type ) -> Boolean ) = apply {
128+ this .genericReturnTypeCondition = condition
129+ }
130+
108131 /* * @see Method.isBridge */
109132 fun isBridge (isBridge : Boolean ) = apply {
110133 this .isBridge = isBridge
@@ -125,16 +148,30 @@ class MethodCondition<T : Any> : ExecutableCondition<Method, MethodResolver<T>,
125148 this .isDefaultNot = isDefault
126149 }
127150
151+ /* * @see Method.getDefaultValue */
152+ fun defaultValue (value : Any? ) = apply {
153+ this .defaultValue = value
154+ }
155+
156+ /* * @see Method.getDefaultValue */
157+ fun defaultValue (condition : (Any? ) -> Boolean ) = apply {
158+ this .defaultValueCondition = condition
159+ }
160+
128161 override fun initializeCopiedData (newSelf : MemberCondition <Method , MethodResolver <T >, T >) {
129162 super .initializeCopiedData(newSelf)
130163
131164 (newSelf as ? MethodCondition )?.also {
132165 it.returnType = returnType
133166 it.returnTypeCondition = returnTypeCondition
167+ it.genericReturnType = genericReturnType
168+ it.genericReturnTypeCondition = genericReturnTypeCondition
134169 it.isBridge = isBridge
135170 it.isBridgeNot = isBridgeNot
136171 it.isDefault = isDefault
137172 it.isDefaultNot = isDefaultNot
173+ it.defaultValue = defaultValue
174+ it.defaultValueCondition = defaultValueCondition
138175 }
139176 }
140177
@@ -144,10 +181,14 @@ class MethodCondition<T : Any> : ExecutableCondition<Method, MethodResolver<T>,
144181 (other as ? MethodCondition )?.also { condition ->
145182 condition.returnType?.let { returnType = it }
146183 condition.returnTypeCondition?.let { returnTypeCondition = it }
184+ condition.genericReturnType?.let { genericReturnType = it }
185+ condition.genericReturnTypeCondition?.let { genericReturnTypeCondition = it }
147186 condition.isBridge?.let { isBridge = it }
148187 condition.isBridgeNot?.let { isBridgeNot = it }
149188 condition.isDefault?.let { isDefault = it }
150189 condition.isDefaultNot?.let { isDefaultNot = it }
190+ condition.defaultValue?.let { defaultValue = it }
191+ condition.defaultValueCondition?.let { defaultValueCondition = it }
151192 }
152193 }
153194
@@ -164,18 +205,26 @@ class MethodCondition<T : Any> : ExecutableCondition<Method, MethodResolver<T>,
164205 get() = super .conditionStringMap + mapOf (
165206 RETURN_TYPE to returnType,
166207 RETURN_TYPE_CONDITION to returnTypeCondition,
208+ GENERIC_RETURN_TYPE to genericReturnType,
209+ GENERIC_RETURN_TYPE_CONDITION to genericReturnTypeCondition,
167210 IS_BRIDGE to isBridge,
168211 IS_BRIDGE_NOT to isBridgeNot,
169212 IS_DEFAULT to isDefault,
170- IS_DEFAULT_NOT to isDefaultNot
213+ IS_DEFAULT_NOT to isDefaultNot,
214+ DEFAULT_VALUE to defaultValue,
215+ DEFAULT_VALUE_CONDITION to defaultValueCondition
171216 )
172217
173218 companion object {
174219 const val RETURN_TYPE = " returnType"
175220 const val RETURN_TYPE_CONDITION = " returnTypeCondition"
221+ const val GENERIC_RETURN_TYPE = " genericReturnType"
222+ const val GENERIC_RETURN_TYPE_CONDITION = " genericReturnTypeCondition"
176223 const val IS_BRIDGE = " isBridge"
177224 const val IS_BRIDGE_NOT = " isBridgeNot"
178225 const val IS_DEFAULT = " isDefault"
179226 const val IS_DEFAULT_NOT = " isDefaultNot"
227+ const val DEFAULT_VALUE = " defaultValue"
228+ const val DEFAULT_VALUE_CONDITION = " defaultValueCondition"
180229 }
181230}
0 commit comments