List of usage examples for org.apache.commons.collections CollectionUtils collect
public static Collection collect(Iterator inputIterator, Transformer transformer)
From source file:org.mule.module.http.functional.listener.HttpListenerGlobalResponseBuilderTestCase.java
private void testResponseHeaders(String url, Collection<String> userAgentHeaderValues) throws IOException { final Response response = Request.Get(url).connectTimeout(1000).execute(); final HttpResponse httpResponse = response.returnResponse(); assertThat(isDateValid(httpResponse.getFirstHeader(HttpHeaders.Names.DATE).getValue()), Is.is(true)); final Header[] userAgentHeaders = httpResponse.getHeaders(HttpHeaders.Names.USER_AGENT); final Collection<String> headerValues = CollectionUtils.collect(Arrays.asList(userAgentHeaders), new Transformer() { @Override// ww w.jav a 2 s .co m public Object transform(Object input) { Header header = (Header) input; return header.getValue(); } }); assertThat(userAgentHeaders.length, is(userAgentHeaderValues.size())); assertThat(headerValues, Matchers .containsInAnyOrder(userAgentHeaderValues.toArray(new String[userAgentHeaderValues.size()]))); }
From source file:org.mule.module.http.functional.listener.HttpListenerResponseBuilderTestCase.java
private void headersWithDuplicatesResponseBuilderTest(String url) throws IOException { final Response response = Request.Get(url).connectTimeout(1000).execute(); final HttpResponse httpResponse = response.returnResponse(); final Header[] userAgentHeaders = httpResponse.getHeaders(HttpHeaders.Names.USER_AGENT); final Collection<String> headerValues = CollectionUtils.collect(Arrays.asList(userAgentHeaders), new Transformer() { @Override/*from w w w . ja v a 2 s. co m*/ public Object transform(Object input) { Header header = (Header) input; return header.getValue(); } }); assertThat(userAgentHeaders.length, is(5)); assertThat(headerValues, Matchers.containsInAnyOrder( Arrays.asList("Mule 3.5.0", "Mule 3.6.0", "Mule 3.7.0", "Mule 3.8.0", "Mule 3.9.0") .toArray(new String[4]))); }
From source file:org.mule.module.http.internal.listener.matcher.MethodRequestMatcher.java
/** * The list of methods accepted by this matcher * * @param methods http request method allowed. *///from w w w . j av a 2 s . c o m public MethodRequestMatcher(final String... methods) { Preconditions.checkArgument(methods != null, "methods attribute should not be null"); this.methods = (List<String>) CollectionUtils.collect(Arrays.asList(methods), new Transformer() { @Override public Object transform(Object input) { return ((String) input).toLowerCase(); } }); }
From source file:org.mule.module.magento.api.order.AxisMagentoOrderClient.java
@SuppressWarnings("unchecked") @NotNull// w w w . j av a 2 s .c o m public List<Carrier> getOrderShipmentCarriers(@NotNull String orderId) throws RemoteException { Validate.notNull(orderId); return (List<Carrier>) CollectionUtils.collect( Arrays.asList(getPort().salesOrderShipmentGetCarriers(getSessionId(), orderId)), new Transformer() { public Object transform(Object input) { AssociativeEntity entity = (AssociativeEntity) input; return new Carrier(entity.getKey(), entity.getValue()); } }); }
From source file:org.mule.module.magento.api.util.MagentoMap.java
@SuppressWarnings("unchecked") public static List<Map<String, Object>> toMap(Object[] magentoObjects) { return (List<Map<String, Object>>) CollectionUtils.collect(Arrays.asList(magentoObjects), TO_MAP); }
From source file:org.mule.modules.zuora.zuora.api.ZObjectMapper.java
@SuppressWarnings("unchecked") public static List<ZObject> toZObject(final ZObjectType type, List<Map<String, Object>> maps) { return (List<ZObject>) CollectionUtils.collect(maps, new Transformer() { @Override// www.j a va2s . c om public Object transform(Object input) { return toZObject(type, (Map<String, Object>) input); } }); }
From source file:org.netbeans.jmiimpl.omg.uml.foundation.core.ClassifierImpl.java
public Collection getAbstractions() { // todo there's gotta be a better way to do this than iterating the list three times... Collection clientDependencies = getCore().getAClientClientDependency().getClientDependency(this); Collection collection = CollectionUtils.select(clientDependencies, new InstanceofPredicate(Abstraction.class)); return CollectionUtils.collect(collection, new Transformer() { public Object transform(Object object) { return ((Abstraction) object).getSupplier().iterator().next(); }/*w w w .j a v a2 s . co m*/ }); }
From source file:org.objectstyle.cayenne.map.DbRelationship.java
/** * Returns a Collection of target attributes. * /*w w w .ja v a 2 s . c o m*/ * @since 1.1 */ public Collection getTargetAttributes() { if (joins.size() == 0) { return Collections.EMPTY_LIST; } return CollectionUtils.collect(joins, JoinTransformers.targetExtractor); }
From source file:org.objectstyle.cayenne.map.DbRelationship.java
/** * Returns a Collection of target attributes. * //from w w w .jav a 2 s . c o m * @since 1.1 */ public Collection getSourceAttributes() { if (joins.size() == 0) { return Collections.EMPTY_LIST; } return CollectionUtils.collect(joins, JoinTransformers.sourceExtractor); }
From source file:org.objectstyle.cayenne.modeler.Application.java
/** * Reinitializes ModelerClassLoader from preferences. *///ww w . j a va2s. co m public void initClassLoader() { FileClassLoadingService classLoader = new FileClassLoadingService(); // init from preferences... Domain classLoaderDomain = getPreferenceDomain().getSubdomain(FileClassLoadingService.class); Collection details = classLoaderDomain.getPreferences(); if (details.size() > 0) { // transform preference to file... Transformer transformer = new Transformer() { public Object transform(Object object) { DomainPreference pref = (DomainPreference) object; return new File(pref.getKey()); } }; classLoader.setPathFiles(CollectionUtils.collect(details, transformer)); } this.modelerClassLoader = classLoader; }