java.lang.Object
org.autogui.base.type.GuiTypeMember
org.autogui.base.type.GuiTypeMemberProperty
org.autogui.swing.LambdaProperty<T>
- Type Parameters:
T- the value type
- All Implemented Interfaces:
GuiTypeElement
Lambda-based property panes.
The LambdaProperty class itself is a property for a pair of
Supplier and Consumer, and
member types of the class are concrete property panes.
Example:
public class StrObj {
private String str;
public void setStr(String s) { str = s; }
public String getStr() { return str; }
}
StrObj s = new StrObj();
LambdaStringPane strPane = new LambdaStringPane(s::getStr, s::setStr);
//a pane creating holding a LambdaProperty with Supplier and Consumer
strPane.setText("update1"); //this will cause s.setStr("update")
s.setStr("update2");
strPane.updateSwingViewSource(); //update the pane with s.getStr()
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classstatic classthe lambda-based version of string-panestatic classNested classes/interfaces inherited from class org.autogui.base.type.GuiTypeMember
GuiTypeMember.MemberOrdinal -
Field Summary
FieldsModifier and TypeFieldDescriptionFields inherited from class org.autogui.base.type.GuiTypeMemberProperty
description, field, fieldName, getterName, history, keyStroke, setterName, typeFields inherited from class org.autogui.base.type.GuiTypeMember
name, ordinal, owner -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> GuiMappingContextcreate(Class<?> type, Supplier<T> getter, Consumer<T> setter, GuiRepresentation repr) static <T> GuiMappingContextstatic <T> GuiMappingContextcreateAndBuild(String name, Class<?> type, Supplier<T> getter, Consumer<T> setter) static <T> GuiMappingContextcreateList(Class<? extends List> listType, Class<?> elementType, Supplier<T> getter, Consumer<T> setter, GuiRepresentation repr) static <T> GuiMappingContextcreateList(String name, Class<? extends List> listType, Class<?> elementType, Supplier<T> getter, Consumer<T> setter, GuiRepresentation repr) executeGet(Object target) execute the property method or obtain the value of the property fieldexecuteSet(Object target, Object value) execute the setter method or set the value of the property field if the target is null, nothing will happen.booleanMethods inherited from class org.autogui.base.type.GuiTypeMemberProperty
compareGet, description, executeGet, getAcceleratorKeyStroke, getChildren, getDescription, getField, getFieldName, getGetter, getGetterName, getInits, getSetter, getSetterName, getType, history, isHistoryValueSupported, join, keyStroke, select, select, setField, setFieldName, setGetter, setGetterName, setSetter, setSetterName, setType, toStringMethods inherited from class org.autogui.base.type.GuiTypeMember
findOwnerMethod, getName, getOrdinal, getOwner, setOrdinal, setOwner
-
Field Details
-
getter
-
setter
-
NONE
-
-
Constructor Details
-
LambdaProperty
-
LambdaProperty
-
LambdaProperty
- Parameters:
name- the property nametype- the property typegetter- the supplier for the propertysetter- the consumer for the property- Since:
- 1.7
-
LambdaProperty
public LambdaProperty(String name, Class<? extends List> listType, Class<?> elementType, Supplier<T> getter, Consumer<T> setter) - Parameters:
name- the property namelistType- the property list typeelementType- the explicit element type of the list, will be constructed asGuiTypeValuegetter- the supplier for the entire list propertysetter- the consumer for the entire list property- Since:
- 1.7
-
-
Method Details
-
executeSet
Description copied from class:GuiTypeMemberPropertyexecute the setter method or set the value of the property field if the target is null, nothing will happen.- Overrides:
executeSetin classGuiTypeMemberProperty- Parameters:
target- the field or setter targetvalue- the value to be set- Returns:
- value, or null if error
-
executeGet
Description copied from class:GuiTypeMemberPropertyexecute the property method or obtain the value of the property field- Overrides:
executeGetin classGuiTypeMemberProperty- Parameters:
target- the property holder, nullable.- Returns:
- the property value or
GuiUpdatedValue.NO_UPDATEif the target is null or the property is static
-
isWritable
public boolean isWritable()- Overrides:
isWritablein classGuiTypeMemberProperty- Returns:
- true if it has a setter or a field
-
createAndBuild
public static <T> GuiMappingContext createAndBuild(String name, Class<?> type, Supplier<T> getter, Consumer<T> setter) - Type Parameters:
T- the value type; T.class can beClass<T>- Parameters:
type- the value typegetter- supplier for a value of the typesetter- consumer for the type and update the value returned by the getter- Returns:
- the context recursively constructed by
GuiSwingMapperSet.getReprDefaultSet().GuiRepresentation.matchAndSetNotifiersAsInit(GuiMappingContext) - Since:
- 1.7
-
create
public static <T> GuiMappingContext create(Class<?> type, Supplier<T> getter, Consumer<T> setter, GuiRepresentation repr) -
create
public static <T> GuiMappingContext create(String name, Class<?> type, Supplier<T> getter, Consumer<T> setter, GuiRepresentation repr) - Type Parameters:
T- the value-type of the property- Parameters:
name- the proeprty nametype- the value-type of the propertygetter- the getter for the property valuesetter- the setter for the property valuerepr- the representation for the property- Returns:
- a new context for the property
- Since:
- 1.7
-
createList
public static <T> GuiMappingContext createList(Class<? extends List> listType, Class<?> elementType, Supplier<T> getter, Consumer<T> setter, GuiRepresentation repr) -
createList
public static <T> GuiMappingContext createList(String name, Class<? extends List> listType, Class<?> elementType, Supplier<T> getter, Consumer<T> setter, GuiRepresentation repr) - Type Parameters:
T- the list type- Parameters:
name- the property namelistType- the list type of the propertyelementType- the element type of the propertygetter- the getter for the entire listsetter- the setter for the entire listrepr- the representation of the element of the list- Returns:
- a context for the list property
- Since:
- 1.7
-