CField implements PField, CAnnotatedDescriptor { @Override public Object getDefaultValue() { try { return defaultValue != null ? defaultValue.get() : null; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new IllegalStateException("Unable to parse default value " + getName(), e); } } CField(@Nullable String docs,
                  int id,
                  @Nonnull PRequirement requirement,
                  @Nonnull String name,
                  @Nonnull PDescriptorProvider typeProvider,
                  @Nullable PValueProvider defaultValue,
                  @Nullable Map<String, String> annotations); @Override String getDocumentation(); @Override int getId(); @Nonnull @Override PRequirement getRequirement(); @Nonnull @Override PType getType(); @Nonnull @Override PDescriptor getDescriptor(); @Nonnull @Override String getName(); @Override boolean hasDefaultValue(); @Override Object getDefaultValue(); @Nonnull @Override @SuppressWarnings("unchecked") Set<String> getAnnotations(); @Override boolean hasAnnotation(@Nonnull String name); @Override String getAnnotationValue(@Nonnull String name); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testDefaultValue() { assertThat(fieldDefault.getDefaultValue(), is(6)); assertThat(fieldNoDefault.getDefaultValue(), is(nullValue())); fieldDefault = new CField("comment", 4, PRequirement.DEFAULT, "name", PPrimitive.I32.provider(), () -> {throw new IllegalArgumentException("Unable to parse default value name");}, ImmutableMap.of("annot", "ation")); try { fieldDefault.getDefaultValue(); fail("no exception"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("Unable to parse default value name")); } }