ServiceTools { Object getObjectFromConstantField(Class cls, Field field) { Object instance = null; if (Modifier.isStatic(field.getModifiers()) && field.getType().isAssignableFrom(cls)) { try { instance = getConstantFromField(field); } catch (IllegalArgumentException | IllegalAccessException ex1) { } } return instance; }  String getShortName(String fullformat); String getLiteralType(Type type); IJsonMarshaller getJsonMarshaller(Annotation[] annotations); IJsonMarshaller getJsonMarshallerFromAnnotation(JsonUnmarshaller jua); String getTemplateOfType(Type type, IJsonMarshaller jsonMarshaller); String getInstanceNameFromDataservice(Class cls); boolean isConsiderateMethod(Method method);  }
@Test public void testGetObjectFromConstantField() throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException { System.out.println("getObjectFromConstantField"); Field badField = Result.class.getDeclaredField("integer"); Field goodField = Locale.class.getField("US"); Object result = instance.getObjectFromConstantField(Result.class, badField); assertThat(result).isNull(); result = instance.getObjectFromConstantField(Locale.class, goodField); assertThat(result).isInstanceOf(Locale.class); doThrow(IllegalAccessException.class).doThrow(IllegalArgumentException.class).when(instance).getConstantFromField(any(Field.class)); result = instance.getObjectFromConstantField(Locale.class, goodField); assertThat(result).isNull(); result = instance.getObjectFromConstantField(Locale.class, goodField); assertThat(result).isNull(); }