@Test public void linksAreInjectedInLinksField() { DummyEntity entity = new DummyEntity(); Object returnedEntity = tested.injectLinks(entity, linkProducer, HateoasVerbosity.MINIMUM); assertSame(entity, returnedEntity); assertSame(EXPECTED_MAP, Iterables.getOnlyElement(entity.getLinks())); }
@SuppressWarnings({ "unchecked" }) @Override public Object injectLinks(Object entity, LinkProducer<Object> linkProducer, final HateoasVerbosity verbosity) { try { Field field = ReflectionUtils.getFieldHierarchical(entity.getClass(), linksFieldName); if (Collection.class.isAssignableFrom(field.getType())) { field.set(entity, Collections2.transform(linkProducer.getLinks(entity), new Function<HateoasLink, Map<String, Object>>() { @Override public Map<String, Object> apply(HateoasLink from) { return from.toMap(verbosity); } })); } else { throw new IllegalArgumentException("Field '" + linksFieldName + "' is not a Collection object"); } return entity; } catch (Exception e) { throw new HateoasInjectException(e); } }
ReflectionBasedHateoasLinkInjector implements HateoasLinkInjector<Object> { @SuppressWarnings({ "unchecked" }) @Override public Object injectLinks(Object entity, LinkProducer<Object> linkProducer, final HateoasVerbosity verbosity) { try { Field field = ReflectionUtils.getFieldHierarchical(entity.getClass(), linksFieldName); if (Collection.class.isAssignableFrom(field.getType())) { field.set(entity, Collections2.transform(linkProducer.getLinks(entity), new Function<HateoasLink, Map<String, Object>>() { @Override public Map<String, Object> apply(HateoasLink from) { return from.toMap(verbosity); } })); } else { throw new IllegalArgumentException("Field '" + linksFieldName + "' is not a Collection object"); } return entity; } catch (Exception e) { throw new HateoasInjectException(e); } } }
ReflectionBasedHateoasLinkInjector implements HateoasLinkInjector<Object> { @SuppressWarnings({ "unchecked" }) @Override public Object injectLinks(Object entity, LinkProducer<Object> linkProducer, final HateoasVerbosity verbosity) { try { Field field = ReflectionUtils.getFieldHierarchical(entity.getClass(), linksFieldName); if (Collection.class.isAssignableFrom(field.getType())) { field.set(entity, Collections2.transform(linkProducer.getLinks(entity), new Function<HateoasLink, Map<String, Object>>() { @Override public Map<String, Object> apply(HateoasLink from) { return from.toMap(verbosity); } })); } else { throw new IllegalArgumentException("Field '" + linksFieldName + "' is not a Collection object"); } return entity; } catch (Exception e) { throw new HateoasInjectException(e); } } ReflectionBasedHateoasLinkInjector();  ReflectionBasedHateoasLinkInjector(String linksFieldName); }
ReflectionBasedHateoasLinkInjector implements HateoasLinkInjector<Object> { @SuppressWarnings({ "unchecked" }) @Override public Object injectLinks(Object entity, LinkProducer<Object> linkProducer, final HateoasVerbosity verbosity) { try { Field field = ReflectionUtils.getFieldHierarchical(entity.getClass(), linksFieldName); if (Collection.class.isAssignableFrom(field.getType())) { field.set(entity, Collections2.transform(linkProducer.getLinks(entity), new Function<HateoasLink, Map<String, Object>>() { @Override public Map<String, Object> apply(HateoasLink from) { return from.toMap(verbosity); } })); } else { throw new IllegalArgumentException("Field '" + linksFieldName + "' is not a Collection object"); } return entity; } catch (Exception e) { throw new HateoasInjectException(e); } } ReflectionBasedHateoasLinkInjector();  ReflectionBasedHateoasLinkInjector(String linksFieldName); @Override boolean canInject(Object entity); @SuppressWarnings({ "unchecked" }) @Override Object injectLinks(Object entity, LinkProducer<Object> linkProducer,
			final HateoasVerbosity verbosity); }
ReflectionBasedHateoasLinkInjector implements HateoasLinkInjector<Object> { @SuppressWarnings({ "unchecked" }) @Override public Object injectLinks(Object entity, LinkProducer<Object> linkProducer, final HateoasVerbosity verbosity) { try { Field field = ReflectionUtils.getFieldHierarchical(entity.getClass(), linksFieldName); if (Collection.class.isAssignableFrom(field.getType())) { field.set(entity, Collections2.transform(linkProducer.getLinks(entity), new Function<HateoasLink, Map<String, Object>>() { @Override public Map<String, Object> apply(HateoasLink from) { return from.toMap(verbosity); } })); } else { throw new IllegalArgumentException("Field '" + linksFieldName + "' is not a Collection object"); } return entity; } catch (Exception e) { throw new HateoasInjectException(e); } } ReflectionBasedHateoasLinkInjector();  ReflectionBasedHateoasLinkInjector(String linksFieldName); @Override boolean canInject(Object entity); @SuppressWarnings({ "unchecked" }) @Override Object injectLinks(Object entity, LinkProducer<Object> linkProducer,
			final HateoasVerbosity verbosity);  }