Package com.j3d.engine.interact.cmd.args
Class TaggedArgValue<T>
java.lang.Object
com.j3d.engine.interact.cmd.args.TaggedArgValue<T>
- Type Parameters:
T- The expected type of the argument's value.
Represents an instance of a parsed tagged argument, holding its name, its value,
and its expected type.
This class serves as the data container for a single key-value pair identified by the
TaggedArgUtil. An ArrayList of these objects is passed to a command's
run method for processing.
- Author:
- Lehlogonolo Poole
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTaggedArgValue(Class<?> type) Constructs a shell for a tagged argument, defining its expected type.TaggedArgValue(T v) -
Method Summary
Modifier and TypeMethodDescriptioncopy(Object val, boolean errorToLabel, SafeJLabel label) Creates a new, populated instance of aTaggedArgValuewith a parsed value.error()Marks this tagged argument instance as having a parsing error.booleanisEmpty()Checks if this instance is an un-parsed shell.booleanisErr()Checks if a parsing error occurred while creating this instance.Sets the name for this tagged argument.Sets the expected type for this tagged argument.toString()
-
Field Details
-
taggedArgName
-
value
-
type
-
isEmpty
private boolean isEmpty -
err
private boolean err
-
-
Constructor Details
-
TaggedArgValue
-
TaggedArgValue
Constructs a shell for a tagged argument, defining its expected type. This is used to populate theTaggedArgUtil.acceptedTagsmap.- Parameters:
type- TheClassof the value this tag expects.
-
-
Method Details
-
setName
Sets the name for this tagged argument.- Parameters:
name- The tag's name (the "key" in the key-value pair).- Returns:
- This instance for method chaining.
-
error
Marks this tagged argument instance as having a parsing error.- Returns:
- This instance for method chaining.
-
setType
Sets the expected type for this tagged argument.- Parameters:
clazz- TheClassof the value.- Returns:
- This instance for method chaining.
-
copy
Creates a new, populated instance of aTaggedArgValuewith a parsed value.This method validates that the provided value's type matches the expected type for this tag.
- Parameters:
val- The parsed value object.errorToLabel- A boolean to log errors to the SafeJLabellabel- ASafeJLabelfor reporting type mismatch errors.- Returns:
- A new, populated
TaggedArgValueinstance, or an error-marked instance if types are incompatible.
-
isEmpty
public boolean isEmpty()Checks if this instance is an un-parsed shell.- Returns:
trueif the instance is empty,falseotherwise.
-
isErr
public boolean isErr()Checks if a parsing error occurred while creating this instance.- Returns:
trueif an error was flagged,falseotherwise.
-
toString
-