Class Parameter
- java.lang.Object
-
- com.google.common.flogger.parameter.Parameter
-
- Direct Known Subclasses:
BraceStyleParameter,DateTimeParameter,SimpleParameter
public abstract class Parameter extends Object
An abstract representation of a parameter for a message template.Note that this is implemented as a class (rather than via an interface) because it is very helpful to have explicit checks for the index values and count to ensure we can calculate reliable low bounds for the number of arguments a template can accept.
Note that all subclasses of Parameter must be immutable and thread safe.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedParameter(FormatOptions options, int index)Constructs a parameter to format an argument using specified formatting options.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidaccept(ParameterVisitor visitor, Object value)voidaccept(ParameterVisitor visitor, Object[] args)abstract StringgetFormat()Returns the printf format string specified for this parameter (eg, "%d" or "%tc").protected FormatOptionsgetFormatOptions()Returns the formatting options.intgetIndex()Returns the index of the argument to be processed by this parameter.
-
-
-
Constructor Detail
-
Parameter
protected Parameter(FormatOptions options, int index)
Constructs a parameter to format an argument using specified formatting options.- Parameters:
options- the format options for this parameter.index- the index of the argument processed by this parameter.
-
-
Method Detail
-
getIndex
public final int getIndex()
Returns the index of the argument to be processed by this parameter.
-
getFormatOptions
protected final FormatOptions getFormatOptions()
Returns the formatting options.
-
accept
public final void accept(ParameterVisitor visitor, Object[] args)
-
accept
protected abstract void accept(ParameterVisitor visitor, Object value)
-
getFormat
public abstract String getFormat()
Returns the printf format string specified for this parameter (eg, "%d" or "%tc").
-
-