@Test public void simpleClassShouldDefineSimpleFields() { final String targetClassName = "me.snowdrop.istio.api.test.Simple"; checkFieldFor(targetClassName, "aInt", "aInt", "integer"); checkFieldFor(targetClassName, "aNumber", "aNumber", "number"); checkFieldFor(targetClassName, "aString", "aString", "string"); checkFieldFor(targetClassName, "aBoolean", "aBoolean", "boolean"); Throwable thrown = catchThrowable(() -> ClassWithInterfaceFieldsRegistry.getFieldInfo(targetClassName, "foo")); assertThat(thrown).isInstanceOf(IllegalArgumentException.class) .hasNoCause().hasMessageContaining("foo"); }
static FieldInfo getFieldInfo(String targetClassName, String fieldName) { final FieldInfo info = classNameToFieldInfos.getOrDefault(targetClassName, Collections.emptyMap()).get(fieldName); if (info == null) { throw new IllegalArgumentException("Unknown field '" + fieldName + "'"); } return info; }
ClassWithInterfaceFieldsRegistry { static FieldInfo getFieldInfo(String targetClassName, String fieldName) { final FieldInfo info = classNameToFieldInfos.getOrDefault(targetClassName, Collections.emptyMap()).get(fieldName); if (info == null) { throw new IllegalArgumentException("Unknown field '" + fieldName + "'"); } return info; } }
ClassWithInterfaceFieldsRegistry { static FieldInfo getFieldInfo(String targetClassName, String fieldName) { final FieldInfo info = classNameToFieldInfos.getOrDefault(targetClassName, Collections.emptyMap()).get(fieldName); if (info == null) { throw new IllegalArgumentException("Unknown field '" + fieldName + "'"); } return info; }  }
ClassWithInterfaceFieldsRegistry { static FieldInfo getFieldInfo(String targetClassName, String fieldName) { final FieldInfo info = classNameToFieldInfos.getOrDefault(targetClassName, Collections.emptyMap()).get(fieldName); if (info == null) { throw new IllegalArgumentException("Unknown field '" + fieldName + "'"); } return info; }   }
ClassWithInterfaceFieldsRegistry { static FieldInfo getFieldInfo(String targetClassName, String fieldName) { final FieldInfo info = classNameToFieldInfos.getOrDefault(targetClassName, Collections.emptyMap()).get(fieldName); if (info == null) { throw new IllegalArgumentException("Unknown field '" + fieldName + "'"); } return info; }    }