private static void populate(Object data, String template, Object dest, Object[] params) {
		log.debug("populating {} for template {}", dest.getClass().getName(), template);
		String[] fields = null;
		TemplateEntity closures = dest.getClass().getAnnotation(TemplateEntity.class);
		if (closures != null) {
			Template[] templates = closures.value();
			for (Template templateFields : templates) {
				if (templateFields.name().equalsIgnoreCase(template)) {
					fields = templateFields.fields();
					break;
				}
			}
		}

		if (fields != null) {
			for (String field : fields) {
				try {
					addField(dest.getClass().getDeclaredField(field), data, template, dest, params);
				} catch (NoSuchFieldException e) {
					log.error("The field " + field + " was not declared in the class of type " + data.getClass());
				}
			}
		} else if (template == null) {
			for (Field field : dest.getClass().getDeclaredFields()) {
				addField(field, data, null, dest, params);
			}
		}
	}