List of usage examples for com.google.common.collect Iterables toArray
static <T> T[] toArray(Iterable<? extends T> iterable, T[] array)
From source file:org.eclipse.rcptt.core.internal.builder.MigrateProjectsJob.java
private void migrateNatures(IProject iProject) throws CoreException { IProjectDescription description = iProject.getDescription(); List<String> natures = Lists.newArrayList(description.getNatureIds()); if (!natures.contains(NATURE_ID)) natures.add(NATURE_ID);/*from w w w . jav a 2 s . c o m*/ description.setNatureIds(Iterables.toArray(natures, String.class)); iProject.setDescription(description, null); }
From source file:edu.umn.msi.tropix.persistence.service.impl.UserServiceImpl.java
public Group[] getGroups(final String gridIdentity) { final User user = userDao.loadUser(gridIdentity); return Iterables.toArray(user.getGroups(), Group.class); }
From source file:org.datahack.parkingdb.api.BayFacadeREST.java
@GET @Produces({ "application/json" }) public List<Bay> find(@QueryParam("parkingZoneId") Integer pId, @QueryParam("totalSpaces") Integer totalSpaces, @QueryParam("minLat") Double minLat, @QueryParam("minLon") Double minLon, @QueryParam("maxLat") Double maxLat, @QueryParam("maxLon") Double maxLon) { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Bay> q = cb.createQuery(Bay.class); Root<Bay> bay = q.from(Bay.class); List<Predicate> predicates = new ArrayList(); if (pId != null) { predicates.add(cb.equal((bay.get(Bay_.parkingZone)).get(ParkingZone_.id), pId)); }/*from w w w . j av a2 s . co m*/ if (totalSpaces != null) { predicates.add(cb.equal((bay.get(Bay_.totalSpaces)), totalSpaces)); } if (minLat != null) { predicates.add(cb.ge(bay.get(Bay_.latitude), minLat)); } if (minLon != null) { predicates.add(cb.ge(bay.get(Bay_.longitude), minLon)); } if (maxLat != null) { predicates.add(cb.le(bay.get(Bay_.latitude), maxLat)); } if (maxLon != null) { predicates.add(cb.le(bay.get(Bay_.longitude), maxLon)); } Predicate[] arr = Iterables.toArray(predicates, Predicate.class); q = q.where(arr); TypedQuery<Bay> bayQuery = em.createQuery(q); List<Bay> resultList = bayQuery.getResultList(); return resultList; }
From source file:net.lacolaco.smileessence.view.adapter.CustomListAdapter.java
@Override public void notifyDataSetChanged() { sort(); array = Iterables.toArray(list, clss); count = array.length; super.notifyDataSetChanged(); }
From source file:webapp.scheduler.AbstractIsisQuartzJob.java
AuthenticationSession newAuthSession(JobExecutionContext context) { String user = getKey(context, SchedulerConstants.USER_KEY); String rolesStr = getKey(context, SchedulerConstants.ROLES_KEY); String[] roles = Iterables.toArray(Splitter.on(",").split(rolesStr), String.class); return new SimpleSession(user, roles); }
From source file:org.eclipse.viatra.emf.runtime.transformation.batch.BatchTransformation.java
public void initializeIndexes() throws IncQueryException { GenericPatternGroup.of(Iterables.toArray( Iterables.transform(rules, new Function<BatchTransformationRule<?, ?>, IQuerySpecification<?>>() { @Override/*from w w w .j a va 2 s . c o m*/ public IQuerySpecification<?> apply(BatchTransformationRule<?, ?> rule) { return rule.getPrecondition(); } }), IQuerySpecification.class)).prepare(iqEngine); }
From source file:org.openengsb.core.edb.jpa.internal.util.QueryRequestCriteriaBuilder.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public CriteriaQuery<JPAObject> buildQuery() { CriteriaQuery<JPAObject> criteriaQuery = builder.createQuery(JPAObject.class); criteriaQuery.distinct(!request.isAndJoined()); Root from = criteriaQuery.from(JPAObject.class); Subquery<Long> subquery = criteriaQuery.subquery(Long.class); Root subFrom = subquery.from(JPAObject.class); Expression<Long> maxExpression = builder.max(subFrom.get("timestamp")); subquery.select(maxExpression);// ww w . ja v a2s . c o m Predicate p1 = builder.equal(subFrom.get("oid"), from.get("oid")); Predicate p2 = builder.le(subFrom.get("timestamp"), request.getTimestamp()); subquery.where(builder.and(p1, p2)); List<Predicate> predicates = new ArrayList<>(); if (request.getContextId() != null) { predicates.add(builder.like(from.get("oid"), request.getContextId() + "/%")); } predicates.add(builder.notEqual(from.get("isDeleted"), !request.isDeleted())); predicates.add(builder.equal(from.get("timestamp"), subquery)); if (request.getModelClassName() != null) { Subquery<JPAEntry> subquery2 = buildJPAEntrySubquery(EDBConstants.MODEL_TYPE, request.getModelClassName(), from, criteriaQuery); predicates.add(builder.exists(subquery2)); } predicates.add(convertParametersToPredicate(from, criteriaQuery)); criteriaQuery.where(Iterables.toArray(predicates, Predicate.class)); return criteriaQuery; }
From source file:com.google.devtools.cyclefinder.Whitelist.java
public void addEntry(String entry) { String[] tokens = Iterables.toArray(ENTRY_SPLITTER.split(entry), String.class); if (tokens.length < 2) { badEntry(entry);/*ww w.j a v a 2 s. co m*/ } String entryType = tokens[0].toLowerCase(); if (entryType.equals("field")) { if (tokens.length == 2) { fields.add(tokens[1]); } else if (tokens.length == 3) { fieldsWithTypes.put(tokens[1], tokens[2]); } else { badEntry(entry); } } else if (entryType.equals("type") && tokens.length == 2) { types.add(tokens[1]); } else if (entryType.equals("namespace") && tokens.length == 2) { namespaces.add(tokens[1]); } else if (entryType.equals("outer") && tokens.length == 2) { outers.add(tokens[1]); } else { badEntry(entry); } }
From source file:com.squareup.javapoet.Types.java
/** * Returns a new parameterized type, applying {@code typeArguments} to {@code rawType} and * with no enclosing owner type./*ww w . j a v a2 s. c o m*/ */ public static ParameterizedType parameterizedType(Type rawType, Iterable<Type> typeArguments) { return parameterizedType(rawType, Iterables.toArray(typeArguments, Type.class)); }
From source file:com.google.copybara.git.Mirror.java
@Override public void run(Path workdir, @Nullable String sourceRef) throws RepoException, IOException, ValidationException { GitRepository repo = GitRepository.bareRepoInCache(origin, generalOptions.getEnvironment(), generalOptions.isVerbose(), gitOptions.repoStorage); repo.initGitDir();// w w w. j a v a 2 s. co m List<String> fetchRefspecs = refspec.stream().map(r -> r.getOrigin() + ":" + r.getOrigin()) .collect(Collectors.toList()); generalOptions.console().progress("Fetching from " + origin); repo.fetch(origin, /*prune=*/true, /*force=*/true, fetchRefspecs); List<String> pushRefspecs = refspec.stream().map(r -> // Add '+' if we can force the push + origin/local repo refspec location + ':' // + remote refspec location. // For example in 'refs/foo:refs/bar' refspec with force push we would use // '+refs/foo:refs/bar' (r.isAllowNoFastForward() || forcePush ? "+" : "") + r.getOrigin() + ":" + r.getDestination()) .collect(Collectors.toList()); generalOptions.console().progress("Pushing to " + destination); List<String> cmd = Lists.newArrayList("push", destination); if (prune) { cmd.add("--prune"); } cmd.addAll(pushRefspecs); repo.simpleCommand(Iterables.toArray(cmd, String.class)); }