classafBeanUtils::ReflectUtils

sys::Obj
  afBeanUtils::ReflectUtils

@Js

Static methods for finding fields, methods and ctors that match given parameter types.

_findCtor

Source

static Method? _findCtor(Slot? ctor, Type[] params)

_findMethod

Source

static Method? _findMethod(Slot? method, Type[] params, Bool? isStatic, Type? returnType)

argTypesFitFunc

Source

static Bool argTypesFitFunc(Type?[] argTypes, Func func)

Returns true if the given parameter types fit the given func.

argTypesFitMethod

Source

static Bool argTypesFitMethod(Type?[] argTypes, Method method)

Returns true if the given parameter types fit the method signature.

findCtor

Source

static Method? findCtor(Type type, Str ctorName, Type[]? params := null)

Finds a named ctor with the given parameter types.

Returns null if not found.

findCtors

Source

static Method[] findCtors(Type type, Type[]? params := null)

Find ctors with the given parameter types.

findField

Source

static Field? findField(Type type, Str fieldName, Type? fieldType := null, Bool? isStatic := null)

Finds a named field.

Returns null if not found.

findFields

Source

static Field[] findFields(Type type, Type fieldType, Bool? isStatic := null)

Find fields.

findMethod

Source

static Method? findMethod(Type type, Str methodName, Type[]? params := null, Bool? isStatic := null, Type? returnType := null)

Finds a named method with the given parameter types.

Returns null if not found.

findMethods

Source

static Method[] findMethods(Type type, Type[]? params := null, Bool? isStatic := null, Type? returnType := null)

Find methods with the given parameter types.

fits

Source

static Bool fits(Type? typeA, Type? typeB)

A replacement for Type.fits() that takes into account type inference for Lists and Maps, and fixes Famtom bugs. Returns true if typeA fits into typeB.

Standard usage:

Str#.fits(Obj#)                // --> true
ReflectUtils.fits(Str#, Obj#)  // --> true

List (and Map) type checking:

Int[]#.fits(Obj[]#)                // --> true
ReflectUtils.fits(Int[]#, Obj[]#)  // --> true

List (and Map) type inference. Items in Obj[] may fit into Int[].

Obj[]#.fits(Int[]#)                // --> false
ReflectUtils.fits(Obj[]#, Int[]#)  // --> true

This is particularly important when calling methods, for many Lists and Maps are defined by the shortcuts [,] and [:] which create Obj?[] and Obj:Obj? respectively.

But List (and Map) types than can never fit still return false:

Str[]#.fits(Int[]#)                // --> false
ReflectUtils.fits(Str[]#, Int[]#)  // --> false

Fantom (nullable) bug fix for Lists (and Maps):

Int[]#.fits(Int[]?#)                // --> false
ReflectUtils.fits(Int[]#, Int[]?#)  // --> true

See List Types and Nullability for bug details.