ConstProvider implements PValueProvider<Object> { @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; } ConstProvider(@Nonnull TypeRegistry registry,
                         @Nonnull String typeName,
                         @Nonnull String programContext,
                         @Nonnull String constantString,
                         int startLineNo,
                         int startLinePos); @Override Object get();  }
@Test public void testProvider() { ProgramRegistry registry = new ProgramRegistry(); ConstProvider provider = new ConstProvider(registry.registryForPath("prog.thrift"), "string", "prog", "\"value\"", 0, 0); assertThat(provider.get(), is("value")); }