private void removeEmptyContentElements(ElementType elementType) { List<Serializable> contentToDelete = newArrayList(); for (Serializable content : elementType.getContent()) { if (content instanceof String && ((String) content).matches("[\\n ].*")) { contentToDelete.add(content); } } elementType.getContent().removeAll(contentToDelete); }
private Object getElementValue(ElementType elementType, Class<?> returnType) { removeEmptyContentElements(elementType); boolean isArray = returnType.isArray(); if (!isArray) { if (elementType.getContent().size() != 1) { throw log.getAttemptToSpecifyAnArrayWhereSingleValueIsExpectedException(); } return getSingleValue(elementType.getContent().get(0), returnType); } else { List<Object> values = newArrayList(); for (Serializable s : elementType.getContent()) { values.add(getSingleValue(s, returnType.getComponentType())); } return values.toArray( (Object[]) Array.newInstance(returnType.getComponentType(), values.size())); } }