Search in sources :

Example 1 with AlwaysFailingParser

use of org.springframework.ide.vscode.commons.util.AlwaysFailingParser in project sts4 by spring-projects.

the class TypeUtil method getValueParser.

public ValueParser getValueParser(Type type) {
    ValueParser simpleParser = VALUE_PARSERS.get(type.getErasure());
    if (simpleParser != null) {
        return simpleParser;
    }
    Collection<StsValueHint> enumValues = getAllowedValues(type, EnumCaseMode.ALIASED);
    if (enumValues != null) {
        // assigning anything to it is an error.
        return new EnumValueParser(niceTypeName(type), getBareValues(enumValues));
    }
    if (isMap(type)) {
        // provide a parser that allows throws
        return new AlwaysFailingParser(niceTypeName(type));
    }
    if (isSequencable(type)) {
        // Trying to parse list from scalars is possible if the domain type is parseable. Spring boot
        // will try to interpret the string as a comma-separated list
        Type elType = getDomainType(type);
        if (elType != null) {
            ValueParser elParser = getValueParser(elType);
            if (elParser != null) {
                return new DelimitedStringParser(elParser);
            }
        }
    }
    return null;
}
Also used : IType(org.springframework.ide.vscode.commons.java.IType) EnumValueParser(org.springframework.ide.vscode.commons.util.EnumValueParser) ValueParser(org.springframework.ide.vscode.commons.util.ValueParser) EnumValueParser(org.springframework.ide.vscode.commons.util.EnumValueParser) AlwaysFailingParser(org.springframework.ide.vscode.commons.util.AlwaysFailingParser) StsValueHint(org.springframework.ide.vscode.boot.metadata.hints.StsValueHint)

Aggregations

StsValueHint (org.springframework.ide.vscode.boot.metadata.hints.StsValueHint)1 IType (org.springframework.ide.vscode.commons.java.IType)1 AlwaysFailingParser (org.springframework.ide.vscode.commons.util.AlwaysFailingParser)1 EnumValueParser (org.springframework.ide.vscode.commons.util.EnumValueParser)1 ValueParser (org.springframework.ide.vscode.commons.util.ValueParser)1