Class Parameter
- java.lang.Object
-
- com.google.common.flogger.parameter.Parameter
-
- Direct Known Subclasses:
BraceStyleParameter
,DateTimeParameter
,SimpleParameter
public abstract class Parameter extends java.lang.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 protected
Parameter(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 void
accept(ParameterVisitor visitor, java.lang.Object value)
void
accept(ParameterVisitor visitor, java.lang.Object[] args)
abstract java.lang.String
getFormat()
Returns the printf format string specified for this parameter (eg, "%d" or "%tc").protected FormatOptions
getFormatOptions()
Returns the formatting options.int
getIndex()
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, java.lang.Object[] args)
-
accept
protected abstract void accept(ParameterVisitor visitor, java.lang.Object value)
-
getFormat
public abstract java.lang.String getFormat()
Returns the printf format string specified for this parameter (eg, "%d" or "%tc").
-
-