Source:
<code>protected static Object getContentFromCxf(Message message, DataFormat dataFormat, String encoding) { Set<Class<?>> contentFormats = message.getContentFormats(); Object answer = null; if (contentFormats != null) { if (LOG.isTraceEnabled()) { for (Class<?> contentFormat : contentFormats) { LOG.trace("Content format={} value={}", contentFormat, message.getContent(contentFormat)); } } if (dataFormat == DataFormat.POJO) { List<?> pojoMessageList = message.getContent(List.class); <START> if (pojoMessageList != null && pojoMessageList.size() != 0) { <END> answer = pojoMessageList; } if (answer == null) { answer = message.getContent(Object.class); if (answer != null) { answer = new MessageContentsList(answer); } } } else if (dataFormat == DataFormat.PAYLOAD) { List<SoapHeader> headers = CastUtils.cast((List<?>)message.get(Header.HEADER_LIST)); Map<String, String> nsMap = new HashMap<String, String>(); answer = new CxfPayload<SoapHeader>(headers, getPayloadBodyElements(message, nsMap), nsMap); } else if (dataFormat.dealias() == DataFormat.RAW) { answer = message.getContent(InputStream.class); if (answer == null) { answer = message.getContent(Reader.class); if (answer != null) { if (encoding == null) { encoding = "UTF-8"; } LOG.trace("file encoding is = {}", encoding); answer = new ReaderInputStream((Reader)answer, Charset.forName(encoding)); } } } else if (dataFormat.dealias() == DataFormat.CXF_MESSAGE && message.getContent(List.class) != null) { answer = message.getContent(List.class).get(0); } LOG.trace("Extracted body from CXF message = {}", answer); } return answer; }</code><technical_language>I favour isEmpty() impl optimized for that, instead of exact number of elements</technical_language>

Target:
protected static Object getContentFromCxf(Message message, DataFormat dataFormat, String encoding) { Set<Class<?>> contentFormats = message.getContentFormats(); Object answer = null; if (contentFormats != null) { if (LOG.isTraceEnabled()) { for (Class<?> contentFormat : contentFormats) { LOG.trace("Content format={} value={}", contentFormat, message.getContent(contentFormat)); } } if (dataFormat == DataFormat.POJO) { List<?> pojoMessageList = message.getContent(List.class); if (pojoMessageList != null && !pojoMessageList.isEmpty()) { answer = pojoMessageList; } if (answer == null) { answer = message.getContent(Object.class); if (answer != null) { answer = new MessageContentsList(answer); } } } else if (dataFormat == DataFormat.PAYLOAD) { List<SoapHeader> headers = CastUtils.cast((List<?>)message.get(Header.HEADER_LIST)); Map<String, String> nsMap = new HashMap<String, String>(); answer = new CxfPayload<SoapHeader>(headers, getPayloadBodyElements(message, nsMap), nsMap); } else if (dataFormat.dealias() == DataFormat.RAW) { answer = message.getContent(InputStream.class); if (answer == null) { answer = message.getContent(Reader.class); if (answer != null) { if (encoding == null) { encoding = "UTF-8"; } LOG.trace("file encoding is = {}", encoding); answer = new ReaderInputStream((Reader)answer, Charset.forName(encoding)); } } } else if (dataFormat.dealias() == DataFormat.CXF_MESSAGE && message.getContent(List.class) != null) { answer = message.getContent(List.class).get(0); } LOG.trace("Extracted body from CXF message = {}", answer); } return answer; }