Class AbstractMenuItemVisitor<T>
- java.lang.Object
-
- com.thecoderscorner.menu.domain.util.AbstractMenuItemVisitor<T>
-
- Type Parameters:
T-
- All Implemented Interfaces:
MenuItemVisitor
public abstract class AbstractMenuItemVisitor<T> extends java.lang.Object implements MenuItemVisitor
Abstract version of the interface MenuItemVisitor, it implements all the methods by defaulting the behaviour to the anyItem() method.- See Also:
MenuItemVisitor
-
-
Constructor Summary
Constructors Constructor Description AbstractMenuItemVisitor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidanyItem(MenuItem item)Whenever a visit method is not implemented, then anyItem is called instead.java.util.Optional<T>getResult()Returns the result previously stored by set result.protected voidsetResult(T res)Stores the result within a visit call, normally used with visitWithResultvoidvisit(ActionMenuItem item)This will be called during visit for an action itemvoidvisit(AnalogMenuItem item)This will be called during visit for an analog itemvoidvisit(BooleanMenuItem item)This will be called during visit for a boolean itemvoidvisit(EditableTextMenuItem item)This will be called during visit for a text itemvoidvisit(EnumMenuItem item)This will be called during visit for an enumeration itemvoidvisit(FloatMenuItem item)This will be called during visit for an floating point itemvoidvisit(RuntimeListMenuItem listItem)this will be called during visit for a list itemvoidvisit(SubMenuItem item)This will be called during visit for sub menu
-
-
-
Method Detail
-
visit
public void visit(AnalogMenuItem item)
Description copied from interface:MenuItemVisitorThis will be called during visit for an analog item- Specified by:
visitin interfaceMenuItemVisitor- Parameters:
item- the item
-
visit
public void visit(BooleanMenuItem item)
Description copied from interface:MenuItemVisitorThis will be called during visit for a boolean item- Specified by:
visitin interfaceMenuItemVisitor- Parameters:
item- the item
-
visit
public void visit(EnumMenuItem item)
Description copied from interface:MenuItemVisitorThis will be called during visit for an enumeration item- Specified by:
visitin interfaceMenuItemVisitor- Parameters:
item- the item
-
visit
public void visit(SubMenuItem item)
Description copied from interface:MenuItemVisitorThis will be called during visit for sub menu- Specified by:
visitin interfaceMenuItemVisitor- Parameters:
item- the item
-
visit
public void visit(EditableTextMenuItem item)
Description copied from interface:MenuItemVisitorThis will be called during visit for a text item- Specified by:
visitin interfaceMenuItemVisitor- Parameters:
item- the item
-
visit
public void visit(ActionMenuItem item)
Description copied from interface:MenuItemVisitorThis will be called during visit for an action item- Specified by:
visitin interfaceMenuItemVisitor- Parameters:
item- the item
-
visit
public void visit(FloatMenuItem item)
Description copied from interface:MenuItemVisitorThis will be called during visit for an floating point item- Specified by:
visitin interfaceMenuItemVisitor- Parameters:
item- the item
-
visit
public void visit(RuntimeListMenuItem listItem)
Description copied from interface:MenuItemVisitorthis will be called during visit for a list item- Specified by:
visitin interfaceMenuItemVisitor- Parameters:
listItem- the list item
-
anyItem
public void anyItem(MenuItem item)
Whenever a visit method is not implemented, then anyItem is called instead. Default behaviour is to throw an exception.- Parameters:
item- the item
-
getResult
public java.util.Optional<T> getResult()
Returns the result previously stored by set result.- Returns:
- the result or empty if not set.
- See Also:
MenuItemHelper
-
setResult
protected void setResult(T res)
Stores the result within a visit call, normally used with visitWithResult- Parameters:
res- the result to store- See Also:
MenuItemHelper
-
-