Java Code Examples for com.google.common.collect.Collections2

The following examples show how to use com.google.common.collect.Collections2. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: atlas   Source File: ApDependency.java    License: Apache License 2.0 6 votes vote down vote up
private File getBaseApFile(Project project, TBuildType tBuildType) {
    File apBaseFile;
    File buildTypeBaseApFile = tBuildType.getBaseApFile();
    if (null != buildTypeBaseApFile && buildTypeBaseApFile.exists()) {
        apBaseFile = buildTypeBaseApFile;
    } else if (!isNullOrEmpty(tBuildType.getBaseApDependency())) {
        String apDependency = tBuildType.getBaseApDependency();
        // Preconditions.checkNotNull(apDependency,
        //                            "You have to specify the baseApFile property or the baseApDependency
        // dependency");
        Dependency dependency = project.getDependencies().create(apDependency);
        Configuration configuration = project.getConfigurations().detachedConfiguration(dependency);
        configuration.setTransitive(false);
        apBaseFile = Iterables.getOnlyElement(Collections2.filter(configuration.getFiles(), new Predicate<File>() {
            @Override
            public boolean apply(@Nullable File file) {
                return file.getName().endsWith(".ap");
            }
        }));
    } else {
        throw new IllegalStateException("AP is missing");
    }
    return apBaseFile;
}
 
Example 2
Source Project: attic-apex-malhar   Source File: FileEndpointTest.java    License: Apache License 2.0 6 votes vote down vote up
private boolean waitTillStdoutIsPopulated(ByteArrayOutputStream baos, int timeout) throws InterruptedException,
  IOException
{
  long now = System.currentTimeMillis();
  Collection<String> filter = Lists.newArrayList();
  while (System.currentTimeMillis() - now < timeout) {
    baos.flush();
    String[] sout = baos.toString().split(System.lineSeparator());
    filter = Collections2.filter(Arrays.asList(sout), Predicates.containsPattern("Delta Record:"));
    if (filter.size() != 0) {
      break;
    }

    Thread.sleep(500);
  }

  return (filter.size() != 0);
}
 
Example 3
Source Project: PGM   Source File: MapContextImpl.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public MapContextImpl(MapInfo info, MapSource source, Collection<MapModule> modules) {
  super(info);
  this.source = checkNotNull(source);
  this.modules = ImmutableList.copyOf(checkNotNull(modules));

  for (MapModule module : this.modules) {
    this.tags.addAll(module.getTags());

    if (module instanceof TeamModule) {
      this.players.clear();
      this.players.addAll(
          Collections2.transform(((TeamModule) module).getTeams(), TeamFactory::getMaxPlayers));
    }

    if (module instanceof FreeForAllModule) {
      this.players.clear();
      this.players.add(((FreeForAllModule) module).getOptions().maxPlayers);
    }
  }

  if (getWorld().hasTerrain()) {
    this.tags.add(TERRAIN);
  }
}
 
Example 4
Source Project: cerberus-source   Source File: DeleteTest.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Get {@link TestCaseStep} which are using an other {@link TestCaseStep}
 * from the given {@link Test} but which are NOT included into this
 * {@link Test}
 *
 * @param test the {@link Test} from which getting externally used
 * {@link TestCaseStep}s
 * @return a {@link Collection} of {@link TestCaseStep} which are using an
 * other {@link TestCaseStep} from the given {@link Test} but which are NOT
 * included into this {@link Test}
 * @throws CerberusException if an unexpected error occurred
 */
private Collection<TestCaseStep> externallyUsedTestCaseSteps(final Test test) throws CerberusException {
    // Get the associated ApplicationContext to this servlet
    final ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());

    // Get all TestCaseSteps which are using an other TestCaseSteps from given Test
    final ITestCaseStepService testCaseStepService = applicationContext.getBean(ITestCaseStepService.class);
    final List<TestCaseStep> stepsInUse = testCaseStepService.getTestCaseStepsUsingTestInParameter(test.getTest());

    // Filter the retrieved list to only retain those which are not included from the given Test
    return Collections2.filter(stepsInUse, new Predicate<TestCaseStep>() {
        @Override
        public boolean apply(@Nullable final TestCaseStep input) {
            return !input.getTest().equals(test.getTest());
        }

        @Override
        public boolean test(TestCaseStep t) {
            return Predicate.super.test(t); //To change body of generated methods, choose Tools | Templates.
        }
    });
}
 
Example 5
Source Project: streamline   Source File: StreamlineEventImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public String getDataSourceId() {
    String res = dataSourceId;
    if (res == null) {
        Object dataSourceIds = header.get("dataSourceIds");
        if (dataSourceIds instanceof List) {
            res = Joiner.on(",").join(Collections2.filter((List) dataSourceIds, new Predicate() {
                @Override
                public boolean apply(Object input) {
                    return input != null;
                }
            }));
        }
    }
    return res;
}
 
Example 6
private Dictionary<String> buildDictionary(TblColRef dim, List<Object> inputValues) throws IOException {
    Stopwatch stopwatch = new Stopwatch();
    stopwatch.start();
    final Collection<String> values = Collections2.transform(Sets.newHashSet(inputValues),
            new Function<Object, String>() {
                @Nullable
                @Override
                public String apply(Object input) {
                    String value = (String) input;
                    return value;
                }
            });
    final Dictionary<String> dict = DictionaryGenerator.buildDictionary(dim.getType(),
            new IterableDictionaryValueEnumerator(values));
    stopwatch.stop();
    if (logger.isDebugEnabled()) {
        logger.debug("BuildDictionary for column : " + dim.getName() + " took : " + stopwatch.elapsedMillis()
                + " ms ");
    }
    return dict;
}
 
Example 7
Source Project: SciGraph   Source File: GraphOwlVisitor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Void visit(OWLEquivalentObjectPropertiesAxiom axiom) {
  Set<OWLObjectPropertyExpression> properties = axiom.getProperties();
  boolean anonymousPropertyExists = false;
  for (OWLObjectPropertyExpression property : properties) {
    anonymousPropertyExists = anonymousPropertyExists || property.isAnonymous();
  }

  // #217 - in case of EquivalentObjectProperties(:p ObjectInverseOf(:q))
  if (!anonymousPropertyExists) {
    Collection<Long> nodes = Collections2.transform(axiom.getObjectPropertiesInSignature(),
        new Function<OWLObjectProperty, Long>() {

          @Override
          public Long apply(OWLObjectProperty objectProperty) {
            return getOrCreateNode(getIri(objectProperty));
          }
        });

    getOrCreateRelationshipPairwise(nodes, OwlRelationships.OWL_EQUIVALENT_OBJECT_PROPERTY);
  }
  return null;
}
 
Example 8
@Override
protected List<MergedAnomalyResultDTO> retrieveAnomaliesFromDatabase(List<MergedAnomalyResultDTO> generated) {
  List<MergedAnomalyResultDTO> retrieved = super.retrieveAnomaliesFromDatabase(generated);

  Collection<MergedAnomalyResultDTO> anomalies =
      Collections2.filter(retrieved,
              mergedAnomaly -> mergedAnomaly != null &&
              !mergedAnomaly.isChild() &&
              mergedAnomaly.getAnomalyResultSource().equals(AnomalyResultSource.DEFAULT_ANOMALY_DETECTION) &&
                  // merge if only the anomaly generated by the same detector
              this.detectorComponentName.equals(mergedAnomaly.getProperties().getOrDefault(PROP_DETECTOR_COMPONENT_NAME, "")) &&
                  // merge if only the anomaly is in the same dimension
              this.metricUrn.equals(mergedAnomaly.getMetricUrn())
      );
  for (MergedAnomalyResultDTO anomaly : anomalies) {
    if(anomaly.getId() != null) this.existingAnomalies.put(anomaly.getId(), copyAnomalyInfo(anomaly, new MergedAnomalyResultDTO()));
  }
  return new ArrayList<>(anomalies);
}
 
Example 9
Source Project: db   Source File: Query.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates a query for inserting a collection of records of the specified type
 * @param ds name of datastore
 * @param collection name of collection
 * @param records a collection of records that are to be inserted
 * @param recordType the @link {@link RecordType} indicating the format engine to use for data
 * @return the generated query in JSON format
 */
public Query insertQuery(final String ds, final String collection, List<Record> records, final RecordType recordType) {
    queryJson.put(QueryParams.QUERY.getParam(), QueryType.INSERT.getQueryCode());
    queryJson.put(QueryParams.DATASTORE.getParam(), ds);
    queryJson.put(QueryParams.COLLECTION.getParam(), collection);

    JSONObject payloadJson = new JSONObject();
    payloadJson.put(QueryParams.TYPE.getParam(), recordType.getTypeCode());
    payloadJson.put(QueryParams.DATA.getParam(), new JSONArray(Collections2.transform(records, new Function<Record, JSONObject>() {
        public JSONObject apply(Record record) {
            return record.asJson();
        }
    })));

    queryJson.put(QueryParams.PAYLOAD.getParam(), payloadJson);
    return this;
}
 
Example 10
Source Project: rya   Source File: TupleExecutionPlanGenerator.java    License: Apache License 2.0 6 votes vote down vote up
private List<TupleExpr> getPlans(final TupleExpr te) {


        final NodeCollector nc = new NodeCollector();
        te.visit(nc);

        final Set<QueryModelNode> nodeSet = nc.getNodeSet();
        final List<Filter> filterList = nc.getFilterSet();
        final Projection projection = nc.getProjection().clone();

        final List<TupleExpr> queryPlans = Lists.newArrayList();

        final Collection<List<QueryModelNode>> plans = Collections2.permutations(nodeSet);

        for (final List<QueryModelNode> p : plans) {
            if (p.size() == 0) {
                throw new IllegalArgumentException("Tuple must contain at least one node!");
            } else if (p.size() == 1) {
                queryPlans.add(te);
            } else {
                queryPlans.add(buildTuple(p, filterList, projection));
            }
        }

        return queryPlans;
    }
 
Example 11
Source Project: incubator-pinot   Source File: AlertUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Helper to convert a collection of email strings into {@code InternetAddress} instances, filtering
 * out invalid addresses and nulls.
 *
 * @param emailCollection collection of email address strings
 * @return filtered collection of InternetAddress objects
 */
public static Collection<InternetAddress> toAddress(Collection<String> emailCollection) {
  if (CollectionUtils.isEmpty(emailCollection)) {
    return Collections.emptySet();
  }
  return Collections2.filter(Collections2.transform(emailCollection,
      new Function<String, InternetAddress>() {
        @Override
        public InternetAddress apply(String s) {
          try {
            return InternetAddress.parse(s)[0];
          } catch (Exception e) {
            return null;
          }
        }
      }),
      new Predicate<InternetAddress>() {
        @Override
        public boolean apply(InternetAddress internetAddress) {
          return internetAddress != null;
        }
      });
}
 
Example 12
Source Project: streamline   Source File: StreamCatalogService.java    License: Apache License 2.0 6 votes vote down vote up
private Collection<TopologyProcessor> fillProcessorStreams(Collection<TopologyProcessor> processors) {
    if (processors != null) {
        for (TopologyProcessor processor : processors) {
            List<TopologyStream> topologyStreams = getOutputStreams(processor);
            processor.setOutputStreams(topologyStreams);
            processor.setOutputStreamIds(new ArrayList<>(Collections2.transform(topologyStreams, new Function<TopologyStream, Long>() {
                @Nullable
                @Override
                public Long apply(@Nullable TopologyStream input) {
                    return input.getId();
                }
            })));
        }
    }
    return processors;
}
 
Example 13
Source Project: bazel   Source File: ConfigurationsForTargetsTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns the configured deps for a given configured target under the given attribute.
 *
 * <p>Throws an exception if the attribute can't be found.
 */
protected List<ConfiguredTarget> getConfiguredDeps(ConfiguredTarget target, String attrName)
    throws Exception {
  String targetLabel = AliasProvider.getDependencyLabel(target).toString();
  Multimap<DependencyKind, ConfiguredTargetAndData> allDeps = getConfiguredDeps(target);
  for (DependencyKind kind : allDeps.keySet()) {
    Attribute attribute = kind.getAttribute();
    if (attribute.getName().equals(attrName)) {
      return ImmutableList.copyOf(
          Collections2.transform(
              allDeps.get(kind), ConfiguredTargetAndData::getConfiguredTarget));
    }
  }
  throw new AssertionError(
      String.format("Couldn't find attribute %s for label %s", attrName, targetLabel));
}
 
Example 14
private CalendarOption createCalendarOption(final GPCalendar calendar) {
  AlwaysWorkingTimeCalendarImpl emptyCalendar = new AlwaysWorkingTimeCalendarImpl();
  emptyCalendar.setName(GanttLanguage.getInstance().getText("none"));
  List<GPCalendar> allCalendars = append(GPCalendarProvider.getInstance().getCalendars(), emptyCalendar, myCustomCalendar);
  CalendarOption result = new CalendarOption(calendar, allCalendars);
  if (calendar.getBaseCalendarID() != null) {
    Collection<GPCalendar> filtered = Collections2.filter(allCalendars, new Predicate<GPCalendar>() {
      public boolean apply(GPCalendar cal) {
        return cal.getID().equals(calendar.getBaseCalendarID());
      }
    });
    if (!filtered.isEmpty()) {
      GPCalendar baseCalendar = filtered.iterator().next();
      if (Sets.newHashSet(baseCalendar.getPublicHolidays()).equals(Sets.newHashSet(calendar.getPublicHolidays()))) {
        result.setSelectedValue(baseCalendar);
      } else {
        fillCustomCalendar(Lists.newArrayList(calendar.getPublicHolidays()), baseCalendar);
        result.setSelectedValue(myCustomCalendar);
        updateBasedOnLabel(baseCalendar);
      }
    }
  }
  return result;
}
 
Example 15
Source Project: arbiter   Source File: ConfigurationMerger.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Merge a collection of maps where the values are themselves collections
 * Every value in the values of the resulting map is unique
 *
 * @param actionTypes The collection of ActionTypes
 * @param transformFunction The function that produces a map from an ActionType
 * @param <T> The type of values in the collection that is the value of the map
 * @return A Map representing the merger of all input maps
 */
public static <T, U extends Collection<T>> Map<String, U> mergeCollectionMaps(Collection<ActionType> actionTypes, Function<ActionType, Map<String, U>> transformFunction) {
    Collection<Map<String, U>> values = Collections2.transform(actionTypes, transformFunction);
    Map<String, U> result = new HashMap<>();

    for (Map<String, U> map : values) {
        for (Map.Entry<String, U> entry : map.entrySet()) {
            if (!result.containsKey(entry.getKey())) {
                result.put(entry.getKey(), entry.getValue());
            } else {
                result.get(entry.getKey()).addAll(entry.getValue());
            }
        }
    }

    return result;
}
 
Example 16
Source Project: onos   Source File: MetersListCommand.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void doExecute() {

    if (!isNullOrEmpty(meterstr)) {
        meterId = MeterId.meterId(Long.parseLong(meterstr));
    }

    MeterService service = get(MeterService.class);

    if (meterId != null && uri != null) {
        Meter m = service.getMeter(DeviceId.deviceId(uri), meterId);
        if (m != null) {
            print("%s", m);
        } else {
            error("Meter %s not found for device %s", meterId, uri);
        }
    } else {
        Collection<Meter> meters = service.getAllMeters();
        if (uri == null) {
            printMeters(meters);
        } else {
            printMeters(Collections2.filter(meters,
                    m -> m.deviceId().equals(DeviceId.deviceId(uri))));
        }
    }
}
 
Example 17
Source Project: xtext-core   Source File: GrammarUtil.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.9
 */
public static Collection<? extends AbstractElement> getAllPredicatedElements(Grammar g) {
	Collection<AbstractElement> unfiltered = getAllElementsByType(g, AbstractElement.class);
	Collection<AbstractElement> result = Collections2.filter(unfiltered, new Predicate<AbstractElement>() {
		@Override
		public boolean apply(AbstractElement input) {
			return input.isPredicated() || input.isFirstSetPredicated();
		}
	});
	return result;
}
 
Example 18
Source Project: bazel   Source File: BuildViewForTesting.java    License: Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
public Collection<ConfiguredTarget> getDirectPrerequisitesForTesting(
    ExtendedEventHandler eventHandler,
    ConfiguredTarget ct,
    BuildConfigurationCollection configurations)
    throws EvalException, InvalidConfigurationException, InterruptedException,
        InconsistentAspectOrderException, StarlarkTransition.TransitionException {
  return Collections2.transform(
      getConfiguredTargetAndDataDirectPrerequisitesForTesting(eventHandler, ct, configurations),
      ConfiguredTargetAndData::getConfiguredTarget);
}
 
Example 19
Source Project: PlotMe-Core   Source File: Database.java    License: GNU General Public License v3.0 5 votes vote down vote up
public List<Plot> getExpiredPlots(final IWorld world) {
    Collection<Plot> filter = Collections2.filter(plots.get(world).values(), new Predicate<Plot>() {
        @Override public boolean apply(Plot plot) {
            return plot.getExpiredDate() != null && Calendar.getInstance().getTime().after(plot.getExpiredDate()) && plot.getWorld().equals
                    (world);
        }
    });
    return ImmutableList.copyOf(filter);
}
 
Example 20
Source Project: turbine   Source File: Dependencies.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Filters a transitive classpath to contain only the entries for direct dependencies, and the
 * types needed to compile those direct deps as reported by jdeps.
 *
 * <p>If no direct dependency information is available the full transitive classpath is returned.
 */
public static Collection<String> reduceClasspath(
    ImmutableList<String> transitiveClasspath,
    ImmutableSet<String> directJars,
    ImmutableList<String> depsArtifacts) {
  if (directJars.isEmpty()) {
    // the compilation doesn't support strict deps (e.g. proto libraries)
    // TODO(cushon): make this a usage error
    return transitiveClasspath;
  }
  Set<String> reduced = new HashSet<>(directJars);
  for (String path : depsArtifacts) {
    DepsProto.Dependencies.Builder deps = DepsProto.Dependencies.newBuilder();
    try (InputStream is = new BufferedInputStream(Files.newInputStream(Paths.get(path)))) {
      deps.mergeFrom(is);
    } catch (IOException e) {
      throw new IOError(e);
    }
    for (DepsProto.Dependency dep : deps.build().getDependencyList()) {
      switch (dep.getKind()) {
        case EXPLICIT:
        case IMPLICIT:
          reduced.add(dep.getPath());
          break;
        case INCOMPLETE:
        case UNUSED:
          break;
      }
    }
  }
  // preserve the order of entries in the transitive classpath
  return Collections2.filter(transitiveClasspath, Predicates.in(reduced));
}
 
Example 21
Source Project: brooklyn-server   Source File: ApplicationTransformer.java    License: Apache License 2.0 5 votes vote down vote up
public static ApplicationSpec specFromApplication(Application application) {
    Collection<String> locations = Collections2.transform(application.getLocations(), new Function<Location, String>() {
        @Override
        @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);
}
 
Example 22
Source Project: CameraV   Source File: IMediaManifest.java    License: GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
public List getAllByType(final String mimeType) {
	Collection<IMedia> media_ = Collections2.filter(listMedia, new Predicate<IMedia>() {
		@Override
		public boolean apply(IMedia m) {
			return m.dcimEntry.mediaType.equals(mimeType);
		}
	});
	
	return new ArrayList(media_);
}
 
Example 23
Source Project: lttrs-android   Source File: MainRepository.java    License: Apache License 2.0 5 votes vote down vote up
public ListenableFuture<Void> insertAccountsRefreshMailboxes(final String username,
                                                             final String password,
                                                             final HttpUrl sessionResource,
                                                             final String primaryAccountId,
                                                             final Map<String, Account> accounts) {
    final SettableFuture<Void> settableFuture = SettableFuture.create();
    IO_EXECUTOR.execute(() -> {
        try {
            List<AccountWithCredentials> credentials = appDatabase.accountDao().insert(
                    username,
                    password,
                    sessionResource,
                    primaryAccountId,
                    accounts
            );
            SetupCache.invalidate();
            final Collection<ListenableFuture<Status>> mailboxRefreshes = Collections2.transform(
                    credentials,
                    new Function<AccountWithCredentials, ListenableFuture<Status>>() {
                        @NullableDecl
                        @Override
                        public ListenableFuture<Status> apply(@NullableDecl AccountWithCredentials account) {
                            return retrieveMailboxes(account);
                        }
                    });
            settableFuture.setFuture(Futures.whenAllComplete(mailboxRefreshes).call(() -> null, MoreExecutors.directExecutor()));
        } catch (Exception e) {
            settableFuture.setException(e);
        }
    });
    return settableFuture;
}
 
Example 24
Source Project: streamline   Source File: ProxyUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static Collection<String> canonicalNames(Collection<Class<?>> classes) {
    return Collections2.transform(classes, new Function<Class<?>, String>() {
        @Nullable
        @Override
        public String apply(@Nullable Class<?> input) {
            return input.getCanonicalName();
        }
    });
}
 
Example 25
@Override
public List<KeyValue> getKeyValues() {
    Collection<KeyValue> kvs = Collections2.transform(map.entrySet(), new Function<Map.Entry<String, String>, KeyValue>() {
        @Override
        public KeyValue apply(Map.Entry<String, String> input) {
            return new ConcreteKeyValue(input);
        }
    });
    return ImmutableList.copyOf(kvs);
}
 
Example 26
Source Project: kylin-on-parquet-v2   Source File: Coordinator.java    License: Apache License 2.0 5 votes vote down vote up
private void promoteNewSegment(CubingJob cubingJob, CubeInstance cubeInstance, CubeSegment cubeSegment)
        throws IOException {
    long sourceCount = cubingJob.findSourceRecordCount();
    long sourceSizeBytes = cubingJob.findSourceSizeBytes();
    long cubeSizeBytes = cubingJob.findCubeSizeBytes();
    Map<Integer, String> sourceCheckpoint = streamMetadataStore.getSourceCheckpoint(cubeInstance.getName(),
            cubeSegment.getName());

    ISourcePositionHandler positionOperator = StreamingSourceFactory.getStreamingSource(cubeInstance)
            .getSourcePositionHandler();
    Collection<ISourcePosition> sourcePositions = Collections2.transform(sourceCheckpoint.values(),
            new Function<String, ISourcePosition>() {
                @Nullable
                @Override
                public ISourcePosition apply(@Nullable String input) {
                    return positionOperator.parsePosition(input);
                }
            });
    ISourcePosition sourcePosition = positionOperator.mergePositions(sourcePositions, MergeStrategy.KEEP_SMALL);
    cubeSegment.setLastBuildJobID(cubingJob.getId());
    cubeSegment.setLastBuildTime(System.currentTimeMillis());
    cubeSegment.setSizeKB(cubeSizeBytes / 1024);
    cubeSegment.setInputRecords(sourceCount);
    cubeSegment.setInputRecordsSize(sourceSizeBytes);
    cubeSegment.setStreamSourceCheckpoint(positionOperator.serializePosition(sourcePosition));
    getCubeManager().promoteNewlyBuiltSegments(cubeInstance, cubeSegment);
}
 
Example 27
public List<String> getCustom() {
	Collection<String> keys = getOriginalCustomKeys();
	if(keys==null || keys.isEmpty()) return Collections.EMPTY_LIST;
	if(hideSystem) {
		keys = Collections2.filter(keys, IS_NOT_SYSTEM);
	}
	List<String> ret = new ArrayList<String>(keys);
	Collections.sort(ret);
	return ret;
}
 
Example 28
Source Project: docker-elastic-agents-plugin   Source File: Util.java    License: Apache License 2.0 5 votes vote down vote up
public static Collection<String> splitIntoLinesAndTrimSpaces(String lines) {
    if (isBlank(lines)) {
        return Collections.emptyList();
    }

    return Collections2.transform(Arrays.asList(lines.split("[\r\n]+")), new Function<String, String>() {
        @Override
        public String apply(String input) {
            return input.trim();
        }
    });
}
 
Example 29
Source Project: website   Source File: ImportJobDto.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public int getTotalProcessedItemCount() {
    return Collections2.filter(getImportItems(), new Predicate<ImportItem>() {

        @Override
        public boolean apply(ImportItem input) {
            return input.getStatus() == Status.PROCESSED || input.getStatus() == Status.CANCELLED;
        }
        
    }).size();
}
 
Example 30
Source Project: kylin-on-parquet-v2   Source File: ForestSpanningTree.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Collection<LayoutEntity> getChildrenByIndexPlan(LayoutEntity parent) {
    // only meaningful when parent has been called in decideTheNextLayer
    TreeNode parentNode = nodesMap.get(parent.getId());
    Preconditions.checkState(parentNode.hasBeenDecided, "Node must have been decided before get its children.");
    return Collections2.transform(parentNode.children, TRANSFORM_FUNC::apply);
}