Package com.calebleavell.jatui.templates
Class NumberedList
java.lang.Object
com.calebleavell.jatui.modules.TUIModule.Builder<NumberedList>
com.calebleavell.jatui.modules.ModuleTemplate<NumberedList>
com.calebleavell.jatui.templates.NumberedList
- All Implemented Interfaces:
DirectedGraphNode<TUIModule.Property,TUIModule.Builder<?>, NumberedList>
Handles displaying a list of text as a numbered list.
Example usage:
Outputs:
Example usage:
NumberedList list = NumberedList.builder("list")
.setStart(4)
.setStep(2)
.addListText("item 1", "item 2", "item 3");
list.build().run();
Outputs:
[4] item 1 [6] item 2 [8] item 3
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.calebleavell.jatui.core.DirectedGraphNode
DirectedGraphNode.PropertyUpdateFlag -
Field Summary
Fields inherited from class com.calebleavell.jatui.modules.ModuleTemplate
mainFields inherited from class com.calebleavell.jatui.modules.TUIModule.Builder
ansi, application, children, enableAnsi, logger, name, printStream, propertyUpdateFlags, scanner, type, usedNames -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddListText(String listText) Adds a single list item.addListText(String... listText) Adds zero or more list items.static NumberedListConstructs a newNumberedListbuilder.protected NumberedListGets a fresh instance of this type of Builder.voidshallowCopy(NumberedList original) booleanshallowStructuralEquals(NumberedList first, NumberedList second) Checks equality for properties given by the builder.start(int start) startis the value of the identifier of the first list item (e.g., "[5] item").step(int step) stepdetermines how much to increment the list number after every list item.Methods inherited from class com.calebleavell.jatui.modules.ModuleTemplate
build, deepCopyMethods inherited from class com.calebleavell.jatui.modules.TUIModule.Builder
addChild, addChild, addChildren, addChildren, appendStyle, application, clearChildren, deepCopy, enableAnsi, getAnsi, getAnsiEnabled, getApplication, getChild, getChild, getChildren, getCopy, getDeepCopy, getName, getPrintStream, getPropertyUpdateFlags, getScanner, getType, lockProperty, name, prependStyle, prependToName, printStream, scanner, self, structuralEquals, style, toString, unlockProperty, updateFlag, updatePropertiesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.calebleavell.jatui.core.DirectedGraphNode
abstractSelf, containsNullNode, containsNullNode, dfs, dfs, forEach, forEachChild, structuralEquals, structuralEquals, updateProperty, updateProperty
-
Constructor Details
-
NumberedList
-
NumberedList
protected NumberedList()
-
-
Method Details
-
builder
Constructs a newNumberedListbuilder.- Parameters:
name- The name of the builder.- Returns:
- The new builder.
-
createInstance
Gets a fresh instance of this type of Builder. Note, this is intended only for copying utility and may have unknown consequences if used in other ways.- Specified by:
createInstancein classTUIModule.Builder<NumberedList>- Returns:
- A fresh, empty instance.
-
shallowCopy
- Overrides:
shallowCopyin classTUIModule.Builder<NumberedList>- Parameters:
original- The builder to copy from.
-
addListText
Adds a single list item. Adheres to the start and step set bystart(int)andstep(int).- Parameters:
listText- The item to display (e.g., "[5]listText").- Returns:
- self
-
addListText
Adds zero or more list items. Adheres to the start and step set bystart(int)andstep(int).
Example:NumberedList list = NumberedList.builder("list") .addListText("item 1", "item 2", "item 3"); list.build().run();
Outputs:[1] item 1 [2] item 2 [3] item 3
- Parameters:
listText- The items to display.- Returns:
- self
-
start
startis the value of the identifier of the first list item (e.g., "[5] item").- Parameters:
start- The starting number for the list.- Returns:
- self
-
step
stepdetermines how much to increment the list number after every list item.- Parameters:
step- The amount to increment every list number.- Returns:
- self
-
shallowStructuralEquals
Checks equality for properties given by the builder. ForNumberedList, this includesstart,step, andi, as well as other requirements provided byTUIModule.Builder.shallowStructuralEquals(TUIModule.Builder, TUIModule.Builder).- Specified by:
shallowStructuralEqualsin interfaceDirectedGraphNode<TUIModule.Property,TUIModule.Builder<?>, NumberedList> - Overrides:
shallowStructuralEqualsin classTUIModule.Builder<NumberedList>- Parameters:
first- The first TUIModule to comparesecond- The second TUIModule to compare- Returns:
trueiffirstandsecondare equal according to builder-provided properties
-