List of usage examples for com.google.common.collect Collections2 transform
public static <F, T> Collection<T> transform(Collection<F> fromCollection, Function<? super F, T> function)
From source file:brooklyn.rest.transform.ApplicationTransformer.java
public static ApplicationSpec specFromApplication(Application application) { Collection<String> locations = Collections2.transform(application.getLocations(), new Function<Location, String>() { @Override//from w w w. j av a 2s . co m @Nullable public String apply(@Nullable Location input) { return input.getId(); } }); // okay to have entities and config as null, as this comes from a real instance return new ApplicationSpec(application.getDisplayName(), application.getEntityType().getName(), null, locations, null); }
From source file:org.sonar.server.computation.issue.ScmAccountCacheLoader.java
@Override public String load(String scmAccount) { List<UserDoc> users = index.getAtMostThreeActiveUsersForScmAccount(scmAccount); if (users.size() == 1) { return users.get(0).login(); }//from w w w.j a v a2s . c o m if (!users.isEmpty()) { // multiple users are associated to the same SCM account, for example // the same email Collection<String> logins = Collections2.transform(users, new Function<UserDoc, String>() { @Override public String apply(UserDoc input) { return input.login(); } }); log.warn(String.format("Multiple users share the SCM account '%s': %s", scmAccount, Joiner.on(", ").join(logins))); } return null; }
From source file:br.com.caelum.vraptor.mydvds.model.User.java
public Set<Dvd> getDvds() { return new HashSet<Dvd>(Collections2.transform(getRents(), new Function<DvdRental, Dvd>() { public Dvd apply(DvdRental copy) { return copy.getDvd(); }//from w w w . ja v a2 s.c o m })); }
From source file:xml.entity.mutableelement.InternalElement.java
@Override @Nonnull//from ww w. j a v a 2s . co m public Element copy() { final InternalElement copy = new InternalElement(name(), this.factory); copy.children().addAll(Collections2.transform(children(), Elements.copy)); return copy; }
From source file:org.sonar.server.permission.ws.SearchProjectPermissionsDataLoader.java
public SearchProjectPermissionsDataLoader(DbClient dbClient, PermissionWsSupport wsSupport, ResourceTypes resourceTypes) {/*from w w w.ja va 2 s . c o m*/ this.dbClient = dbClient; this.wsSupport = wsSupport; this.rootQualifiers = Collections2.transform(resourceTypes.getRoots(), ResourceType::getQualifier) .toArray(new String[resourceTypes.getRoots().size()]); }
From source file:hmi.animation.VJointUtils.java
/** * Create a set of sid strings from a collection of VJoints. * If the sid of a joint in joints is null, its id or name are used respectively. *//* ww w . ja v a 2s. com*/ public static Set<String> transformToSidSet(Collection<VJoint> joints) { Collection<String> j = Collections2.transform(joints, new ApplySidFuntion()); return ImmutableSet.copyOf(j); }
From source file:com.qcadoo.mes.deviationCausesReporting.dataProvider.DeviationWithOccurrencesDataProvider.java
private static String prepareTotalOccurrencesForProblemProjection() { Collection<String> subQueries = Collections2.transform(Arrays.asList(DeviationType.values()), new Function<DeviationType, String>() { @Override/*from w w w . j a va 2s .c o m*/ public String apply(final DeviationType deviationType) { DeviationModelDescriber modelDescriber = deviationType.getModelDescriber(); HashMap<String, String> placeholderValues = Maps.newHashMap(); placeholderValues.put("MODEL_PLUGIN", modelDescriber.getModelPlugin()); placeholderValues.put("MODEL_NAME", modelDescriber.getModelName()); placeholderValues.put("REASON_TYPE_FIELD_NAME", modelDescriber.getReasonTypeFieldName()); placeholderValues.put("ORDER_PATH", deviationType.getPathToOrder()); placeholderValues.put("ORDER_STATE", OrderFields.STATE); StrSubstitutor substitutor = new StrSubstitutor(placeholderValues, "${", "}"); return substitutor.replace(PARTIAL_COUNT_SUB_QUERY_TPL).toString(); } }); return StringUtils.join(subQueries, " + "); }
From source file:com.offbytwo.jenkins.model.Job.java
/** * Trigger a parameterized build// ww w . j ava 2s . c o m * * @param params * the job parameters * @throws IOException */ public void build(Map<String, String> params) throws IOException { String qs = join(Collections2.transform(params.entrySet(), new MapEntryToQueryStringPair()), "&"); client.post(url + "buildWithParameters?" + qs); }
From source file:br.com.caelum.vraptor.musicjungle.model.User.java
public Set<Music> getMusics() { return new HashSet<Music>(Collections2.transform(getMusicOwners(), new Function<MusicOwner, Music>() { @Override/* w w w .ja v a2 s . co m*/ public Music apply(MusicOwner copy) { return copy.getMusic(); } })); }
From source file:com.qcadoo.model.api.utils.EntityUtils.java
public static <T> Collection<T> getFieldsView(final Collection<Entity> entities, final String fieldName) { return Collections2.transform(entities, (Function<Entity, T>) getFieldExtractor(fieldName)); }