
com.github.rutledgepaulv.rqe.conversions.parsers.StringToObjectBestEffortConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rest-query-engine Show documentation
Show all versions of rest-query-engine Show documentation
A library for parsing rsql queries into database queries for a REST API.
The newest version!
/*
* com.github.rutledgepaulv.rqe.conversions.parsers.StringToObjectBestEffortConverter
* *
* * Copyright (C) 2016 Paul Rutledge
* *
* * This software may be modified and distributed under the terms
* * of the MIT license. See the LICENSE file for details.
*
*/
package com.github.rutledgepaulv.rqe.conversions.parsers;
import org.springframework.core.convert.converter.Converter;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.Objects;
import java.util.Optional;
public class StringToObjectBestEffortConverter implements Converter {
private static final DateTimeFormatter PARSER = DateTimeFormatter.ISO_DATE_TIME;
@Override
public Object convert(String source) {
return tryParseBoolean(source)
.orElseGet(() -> tryParseDate(source)
.orElseGet(() -> tryParseNumber(source)
.orElse(source)));
}
private static Optional
© 2015 - 2025 Weber Informatics LLC | Privacy Policy