Search in sources :

Example 1 with ConstParser

use of net.morimekta.providence.reflect.parser.internal.ConstParser in project providence by morimekta.

the class ConstProvider method get.

@Override
public Object get() {
    if (parsedValue == null) {
        ConstParser parser = new ConstParser(registry, programContext, startLineNo, startLinePos);
        @SuppressWarnings("unchecked") PDescriptor type = registry.getProvider(typeName, programContext, Collections.EMPTY_MAP).descriptor();
        try (ByteArrayInputStream in = new ByteArrayInputStream(constantString.getBytes(StandardCharsets.UTF_8))) {
            parsedValue = parser.parse(in, type);
        } catch (IOException e) {
            throw new UncheckedIOException(e.getMessage(), e);
        }
    }
    return parsedValue;
}
Also used : PDescriptor(net.morimekta.providence.descriptor.PDescriptor) ByteArrayInputStream(java.io.ByteArrayInputStream) ConstParser(net.morimekta.providence.reflect.parser.internal.ConstParser) UncheckedIOException(java.io.UncheckedIOException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 PDescriptor (net.morimekta.providence.descriptor.PDescriptor)1 ConstParser (net.morimekta.providence.reflect.parser.internal.ConstParser)1