Class LMinMax
- java.lang.Object
-
- org.supercsv.cellprocessor.CellProcessorAdaptor
-
- org.supercsv.cellprocessor.constraint.LMinMax
-
- All Implemented Interfaces:
CellProcessor
,StringCellProcessor
public class LMinMax extends CellProcessorAdaptor implements StringCellProcessor
Converts the input data to a Long and and ensures the value is between the supplied min and max values (inclusive). If the data has no upper or lower bound, you should use either ofMIN
orMAX
constants provided in the class.
-
-
Field Summary
Fields Modifier and Type Field Description private long
max
static int
MAX_8_BIT_SIGNED
Maximum value for 8 bits (signed)static int
MAX_8_BIT_UNSIGNED
Maximum value for 8 bits (unsigned)static int
MAX_CHAR
Maximum value for a Characterstatic int
MAX_INTEGER
Maximum value for an Integerstatic long
MAX_LONG
Maximum value for a Longstatic short
MAX_SHORT
Maximum value for a Shortprivate long
min
static int
MIN_8_BIT_SIGNED
Minimum value for 8 bits (signed)static int
MIN_8_BIT_UNSIGNED
Minimum value for 8 bits (unsigned)static int
MIN_CHAR
Minimum value for a Characterstatic int
MIN_INTEGER
Minimum value for an Integerstatic long
MIN_LONG
Minimum value for a Longstatic short
MIN_SHORT
Minimum value for a Short-
Fields inherited from class org.supercsv.cellprocessor.CellProcessorAdaptor
next
-
-
Constructor Summary
Constructors Constructor Description LMinMax(long min, long max)
Constructs a new LMinMax processor, which converts the input data to a Long and and ensures the value is between the supplied min and max values.LMinMax(long min, long max, LongCellProcessor next)
Constructs a new LMinMax processor, which converts the input data to a Long and and ensures the value is between the supplied min and max values, then calls the next processor in the chain.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
checkPreconditions(long min, long max)
Checks the preconditions for creating a new LMinMax processor.java.lang.Object
execute(java.lang.Object value, CsvContext context)
This method is invoked by the framework when the processor needs to process data or check constraints.-
Methods inherited from class org.supercsv.cellprocessor.CellProcessorAdaptor
toString, validateInputNotNull
-
-
-
-
Field Detail
-
MAX_LONG
public static final long MAX_LONG
Maximum value for a Long- See Also:
- Constant Field Values
-
MIN_LONG
public static final long MIN_LONG
Minimum value for a Long- See Also:
- Constant Field Values
-
MAX_INTEGER
public static final int MAX_INTEGER
Maximum value for an Integer- See Also:
- Constant Field Values
-
MIN_INTEGER
public static final int MIN_INTEGER
Minimum value for an Integer- See Also:
- Constant Field Values
-
MAX_SHORT
public static final short MAX_SHORT
Maximum value for a Short- See Also:
- Constant Field Values
-
MIN_SHORT
public static final short MIN_SHORT
Minimum value for a Short- See Also:
- Constant Field Values
-
MAX_CHAR
public static final int MAX_CHAR
Maximum value for a Character- See Also:
- Constant Field Values
-
MIN_CHAR
public static final int MIN_CHAR
Minimum value for a Character- See Also:
- Constant Field Values
-
MAX_8_BIT_UNSIGNED
public static final int MAX_8_BIT_UNSIGNED
Maximum value for 8 bits (unsigned)- See Also:
- Constant Field Values
-
MIN_8_BIT_UNSIGNED
public static final int MIN_8_BIT_UNSIGNED
Minimum value for 8 bits (unsigned)- See Also:
- Constant Field Values
-
MAX_8_BIT_SIGNED
public static final int MAX_8_BIT_SIGNED
Maximum value for 8 bits (signed)- See Also:
- Constant Field Values
-
MIN_8_BIT_SIGNED
public static final int MIN_8_BIT_SIGNED
Minimum value for 8 bits (signed)- See Also:
- Constant Field Values
-
min
private final long min
-
max
private final long max
-
-
Constructor Detail
-
LMinMax
public LMinMax(long min, long max)
Constructs a new LMinMax processor, which converts the input data to a Long and and ensures the value is between the supplied min and max values.- Parameters:
min
- the minimum value (inclusive)max
- the maximum value (inclusive)- Throws:
java.lang.IllegalArgumentException
- ifmax < min
-
LMinMax
public LMinMax(long min, long max, LongCellProcessor next)
Constructs a new LMinMax processor, which converts the input data to a Long and and ensures the value is between the supplied min and max values, then calls the next processor in the chain.- Parameters:
min
- the minimum value (inclusive)max
- the maximum value (inclusive)next
- the next processor in the chain- Throws:
java.lang.NullPointerException
- if next is nulljava.lang.IllegalArgumentException
- ifmax < min
-
-
Method Detail
-
checkPreconditions
private static void checkPreconditions(long min, long max)
Checks the preconditions for creating a new LMinMax processor.- Parameters:
min
- the minimum value (inclusive)max
- the maximum value (inclusive)- Throws:
java.lang.IllegalArgumentException
- ifmax < min
-
execute
public java.lang.Object execute(java.lang.Object value, CsvContext context)
This method is invoked by the framework when the processor needs to process data or check constraints.- Specified by:
execute
in interfaceCellProcessor
- Parameters:
value
- the value to be processedcontext
- the CSV context- Returns:
- the result of cell processor execution
- Throws:
SuperCsvCellProcessorException
- if value is null or can't be parsed as a LongSuperCsvConstraintViolationException
- if value, or doesn't lie between min and max (inclusive)
-
-