List of usage examples for org.springframework.util CollectionUtils findCommonElementType
@Nullable public static Class<?> findCommonElementType(Collection<?> collection)
From source file:com.expedia.seiso.web.controller.delegate.BasicItemDelegate.java
private Object getListProperty(ApiVersion apiVersion, List<?> listPropValue, String view) { if (listPropValue == null) { return null; }/*from ww w. ja va 2 s . c o m*/ // Not sure I'm happy with this approach. Would it make more sense to require collection properties to declare // their type param (e.g. List<NodeIpAddress> instead of List) and then use reflection to grab the type? [WLW] if (listPropValue.isEmpty()) { return Collections.EMPTY_LIST; } val elemClass = CollectionUtils.findCommonElementType(listPropValue); val elemMeta = itemMetaLookup.getItemMeta(elemClass); val proj = elemMeta.getProjectionNode(apiVersion, Projection.Cardinality.COLLECTION, view); return resourceAssembler.toResourceList(apiVersion, listPropValue, proj); }
From source file:org.springframework.integration.aggregator.AbstractCorrelatingMessageHandler.java
private void verifyResultCollectionConsistsOfMessages(Collection<?> elements) { Class<?> commonElementType = CollectionUtils.findCommonElementType(elements); Assert.isAssignable(Message.class, commonElementType, "The expected collection of Messages contains non-Message element: " + commonElementType); }