java.lang.Object
org.autogui.base.type.GuiTypeBuilder
- Direct Known Subclasses:
GuiTypeBuilder.GuiTypeBuilderRelaxed
the factory for
GuiTypeElement
. get(Type)
can obtain a GuiTypeElement
from Type
.
it's targets are members attached [at]GuiIncluded
.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
another type-builder with relaxed rules: including non-public (without access-modifiers) members.static class
a temporarily created member group increateObjectFromClass(Class,Type)
static class
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionforClass
:createFromClass(Class)
forParameterizedType
: obtain the raw class and check it is aCollection
with a type arg <T>.createCollectionArrayFromClass
(Class<?> cls, Type genericTypeOfCls) createFromClass
(Class<?> cls) createFromClass
(Class<?> cls, Type genericTypeOfCls) void
createMember
(GuiTypeObject objType, GuiTypeBuilder.MemberDefinitions definitions) if the definitions has a field, a getter or a setter, create a property.void
createMemberAction
(GuiTypeObject objType, String name, Method method, boolean isList) void
createMemberProperty
(GuiTypeObject objType, String name, Field fld, Method getter, Method setter) void
createMemberProperty
(GuiTypeObject objType, String name, Field fld, Method getter, Method setter, GuiTypeMemberProperty property) void
createMemberPropertyNotifier
(GuiTypeObject objType, String name, Field fld, Method getter, Method setter) createObjectFromClass
(Class<?> cls, Type genericTypeOfCls) create aGuiTypeObject
, register it, and construct field and method members.createValueFromClass
(Class<?> cls, Type genericTypeOfCls) reuse a constructed type element, orcreate(Type)
.Class<?>
Class
, raw type ofParameterizedType
, LUB ofWildcardType
, LUB ofTypeVariable
, Object[] forGenericArrayType
, or ObjectgetNameSuffix
(String head, String name) boolean
boolean
boolean
Note: it might conflict withisAccessorMethod(Method)
boolean
isExcludedType
(Class<?> cls) boolean
boolean
boolean
isIncludedClass
(Class<?> cls) boolean
boolean
boolean
boolean
boolean
isValueType
(Class<?> cls) listFields
(Class<?> cls) listMethods
(Class<?> cls) protected void
put
(Type type, GuiTypeElement e) void
setValueTypes
(List<Class<?>> valueTypes)
-
Field Details
-
typeElements
-
langValueTypes
-
valueTypes
-
-
Constructor Details
-
GuiTypeBuilder
public GuiTypeBuilder() -
GuiTypeBuilder
-
-
Method Details
-
setValueTypes
-
getValueTypes
- Returns:
- the default value types which are boxed primitive types:
Integer
etc.
-
get
reuse a constructed type element, orcreate(Type)
. the reusing can avoid infinity recursion- Parameters:
type
- for the element- Returns:
- the created type element
-
create
- for
Class
:createFromClass(Class)
- for
ParameterizedType
: obtain the raw class and check it is aCollection
with a type arg <T>. then,createCollectionFromType(ParameterizedType)
, otherwisecreateFromClass(Class)
for the raw type - otherwise obtains the raw-type of the type, and
createFromClass(Class, Type)
- if no raw-type, returns null
- Parameters:
type
- for creation- Returns:
- nullable
- for
-
createFromClass
- Parameters:
cls
- the target class- Returns:
- if array class and
isIncludedClass(Class)
,createCollectionArrayFromClass(Class,Type)
. ifisValueType(Class)
orisExcludedType(Class)
thencreateValueFromClass(Class,Type)
elsecreateObjectFromClass(Class,Type)
-
createFromClass
-
isIncludedClass
- Parameters:
cls
- the target class- Returns:
- if array class, recursively checks component type.
otherwise,
isValueType(Class)
or non-isExcludedType(Class)
-
createValueFromClass
- Parameters:
cls
- the target typegenericTypeOfCls
- a generic type version of cls, which will also be registered. nullable.- Returns:
- a new
GuiTypeValue
with registering it
-
createCollectionFromType
- Parameters:
type
- the target type- Returns:
- a new
GuiTypeCollection
with the raw type and the element type
-
createCollectionArrayFromClass
-
createObjectFromClass
create aGuiTypeObject
, register it, and construct field and method members. those members are grouped by their names and passed tocreateMember(GuiTypeObject, MemberDefinitions)
. the rules for finding members areisMemberField(Field)
andisMemberMethod(Method)
.//example @
GuiIncluded
class C { @GuiIncluded
(index=1) public int fld; @GuiIncluded
(index=2, description="read-only value") public String getReadOnlyProp() { ... } @GuiIncluded
(index=3, description="property by setter and getter") public String getValue() { ... } public void setValue(String v) { ... } @GuiIncluded
(index=4, description="action") public void action() { ... } }- Parameters:
cls
- the object classgenericTypeOfCls
- a generic type of cls, which is also registered. nullable- Returns:
- an object type for the class
-
listFields
-
listMethods
-
put
-
isValueType
- Parameters:
cls
- the tested class- Returns:
- primitive or
valueTypes
-
isExcludedType
-
isGuiIncludedEnabled
- Parameters:
e
- the target member- Returns:
- true if e has the annotation
GuiIncluded.value()
==true - Since:
- 1.2
-
createMember
if the definitions has a field, a getter or a setter, create a property. otherwise create actions. Note: any methods starting with "get", "set" or "is" are collected as aGuiTypeBuilder.MemberDefinitions
. So, getM() and setM() are MemberDefinitions("m") and here create actions "Get M" and "Set M".- Parameters:
objType
- the owner objectdefinitions
- the members
-
createMemberProperty
public void createMemberProperty(GuiTypeObject objType, String name, Field fld, Method getter, Method setter) -
createMemberPropertyNotifier
public void createMemberPropertyNotifier(GuiTypeObject objType, String name, Field fld, Method getter, Method setter) -
createMemberProperty
public void createMemberProperty(GuiTypeObject objType, String name, Field fld, Method getter, Method setter, GuiTypeMemberProperty property) -
getMemberOrdinalIndex
-
getMemberOrdinalIndex
-
createMemberAction
-
isMemberField
- Parameters:
f
- the tested field- Returns:
- true if
GuiIncluded
is attached and non-static
-
getMemberNameFromField
- Parameters:
f
- the field- Returns:
- the field name itself or attached
GuiIncluded.name()
-
isMemberMethod
- Parameters:
m
- the tested method- Returns:
- true if
GuiIncluded
attached and non-static with excludingisNotifierSetterMethod(Method)
-
getMemberNameFromMethod
- Parameters:
m
- a method- Returns:
getMemberNameFromMethodName(String)
or attachedGuiIncluded.name()
-
getMemberNameFromMethodForAction
- Parameters:
m
- a method- Returns:
- the name of the method or attached
GuiIncluded.name()
-
getMemberNameFromMethodName
- Parameters:
name
- a method name- Returns:
- suffix of get..., is.... or set..., or name itself
-
getNameSuffix
-
isGetterMethod
- Parameters:
m
- the tested method- Returns:
- true if boolean is...() or V get...()
-
isAccessorMethod
- Parameters:
m
- the tested method- Returns:
- true if T m(), no annotation
GuiListSelectionUpdater
andGuiIncluded.action()
==false (or noGuiIncluded
) - Since:
- 1.2
-
isSetterMethod
- Parameters:
m
- the tested method- Returns:
- set...(V v)
-
isActionMethod
Note: it might conflict withisAccessorMethod(Method)
- Parameters:
m
- the tested method- Returns:
- true if m()
-
isActionListMethod
- Parameters:
m
- the tested method- Returns:
- m(L<E>) and L is a super type of
List
except for Object. or, m(L<E>, String)
-
getClass
Class
, raw type ofParameterizedType
, LUB ofWildcardType
, LUB ofTypeVariable
, Object[] forGenericArrayType
, or Object- Parameters:
type
- the type for extraction- Returns:
- an extracted class or Object.class
-
isNotifierSetterMethod
- Parameters:
m
- the tested method- Returns:
- true if the method is non-static and has
GuiNotifierSetter
with taking aRunnable
argument
-