Class DefaultRSQLArgumentParser
- java.lang.Object
-
- com.broadleafcommerce.data.tracking.core.filtering.fetch.rsql.DefaultRSQLArgumentParser
-
- All Implemented Interfaces:
RSQLArgumentParser
public class DefaultRSQLArgumentParser extends Object implements RSQLArgumentParser
- Author:
- Jeff Fischer, Samarth Dhruva (samarthd)
-
-
Constructor Summary
Constructors Constructor Description DefaultRSQLArgumentParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TemporalAccessor
convertFromInstant(Instant from, Class<?> to)
List<Object>
parseArguments(String selector, cz.jirutka.rsql.parser.ast.ComparisonOperator operator, List<String> arguments, Class<?> rootType)
Returns string-based arguments into their real typed equivalents.List<Object>
parseArguments(String selector, cz.jirutka.rsql.parser.ast.ComparisonOperator operator, List<String> arguments, Class<?> rootType, FilterHelper.LinkField linkField)
Returns string-based arguments into their real typed equivalents.protected Boolean
parseBoolean(String argument)
Parse a String into a Boolean object.protected Date
parseDate(String argument)
Parse an ISO8601 String into aDate
.protected Number
parseNumeric(Class<?> selectorType, String argument)
Parse a String into a number object.protected String
parseString(String argument)
protected TemporalAccessor
parseTemporal(Class<?> selectorType, String argument)
Parse an ISO8601 string into aTemporalAccessor
object.
-
-
-
Method Detail
-
parseArguments
public List<Object> parseArguments(String selector, cz.jirutka.rsql.parser.ast.ComparisonOperator operator, List<String> arguments, Class<?> rootType)
Description copied from interface:RSQLArgumentParser
Returns string-based arguments into their real typed equivalents.- Specified by:
parseArguments
in interfaceRSQLArgumentParser
- Parameters:
selector
- an RSQL selector, usually a fieldoperator
- operator from the selector to the argumentsarguments
- what will be parsed outrootType
- the type that this is being parsed for. This is generally used at the repository layer so this is usually a repository class- Returns:
- typed equivalents of arguments after parsing
-
parseArguments
public List<Object> parseArguments(String selector, cz.jirutka.rsql.parser.ast.ComparisonOperator operator, List<String> arguments, Class<?> rootType, FilterHelper.LinkField linkField)
Description copied from interface:RSQLArgumentParser
Returns string-based arguments into their real typed equivalents.- Specified by:
parseArguments
in interfaceRSQLArgumentParser
- Parameters:
selector
- an RSQL selector, usually a fieldoperator
- operator from the selector to the argumentsarguments
- what will be parsed outrootType
- the type that this is being parsed for. This is generally used at the repository layer so this is usually a repository classlinkField
- Specifies additional information for this selector denoting aLink
annotated field. May be null if the selector does not reference a link field.- Returns:
- typed equivalents of arguments after parsing
-
parseTemporal
protected TemporalAccessor parseTemporal(Class<?> selectorType, String argument)
Parse an ISO8601 string into aTemporalAccessor
object. The supported types areZonedDateTime
,LocalDateTime
,LocalDate
andOffsetDateTime
For
ZonedDateTime
, the String must follow the rules ofDateTimeFormatter.ISO_ZONED_DATE_TIME
. For all other types, the String must follow the rules ofDateTimeFormatter.ISO_INSTANT
.- Parameters:
selectorType
- the specific type that the argument should be parsed intoargument
- the argument to convert- Returns:
- a
TemporalAccessor
with the value specified in the given string - Throws:
UnsupportedOperationException
- in the event that there is a parsing error or the selector type is not supported- See Also:
ZonedDateTime
,LocalDateTime
,LocalDate
-
convertFromInstant
protected TemporalAccessor convertFromInstant(@NonNull Instant from, Class<?> to)
-
parseDate
protected Date parseDate(String argument)
Parse an ISO8601 String into aDate
. This will attempt to parse with both theDateTimeFormatter.ISO_INSTANT
andDateTimeFormatter.ISO_ZONED_DATE_TIME
.- Parameters:
argument
- the argument to convert- Returns:
- a
Date
with the value specified in the given string - Throws:
UnsupportedOperationException
- in the event that there is a parsing error
-
parseNumeric
protected Number parseNumeric(Class<?> selectorType, String argument)
Parse a String into a number object. Strings containing integers are converted to Longs, while decimal strings are converted to BigDecimal.- Parameters:
selectorType
- The type of the selectorargument
- the argument to convert
-
-