private <T> T createTarget(Class<T> targetClass, ArtificerTarget artificerTarget) throws Exception { T t = targetClass.newInstance(); Target target = (Target) t; if (artificerTarget != null) { String targetedUuid = artificerTarget.getTarget().getUuid(); target.setValue(targetedUuid); String href = String.format("%1$s/%2$s/%3$s", artificerTarget.getTarget().getModel(), artificerTarget.getTarget().getType(), targetedUuid); target.setHref(href); setOtherAttributes(artificerTarget.getOtherAttributes(), target.getOtherAttributes()); } return t; } }