List of usage examples for java.util Set stream
default Stream<E> stream()
From source file:de.metas.ui.web.window.datatypes.json.JSONDocumentLayoutElementField.java
public static Set<JSONDocumentLayoutElementField> ofSet( final Set<DocumentLayoutElementFieldDescriptor> fieldDescriptors, final JSONOptions jsonOpts) { return fieldDescriptors.stream().map(fieldDescriptor -> of(fieldDescriptor, jsonOpts)) .collect(GuavaCollectors.toImmutableSet()); }
From source file:com.netflix.genie.web.data.repositories.jpa.specifications.JpaSpecificationUtils.java
/** * Convert a set of TagEntities to the '|' delimited tag search string. * * @param tags The tags to convert/*w ww . ja v a 2s .co m*/ * @return The tag search string in case insensitive order. e.g. |tag1||tag2||tag3| */ public static String createTagSearchString(final Set<TagEntity> tags) { // Tag search string length max is currently 1024 which will be caught by hibernate validator if this // exceeds that length return TAG_DELIMITER + tags.stream().map(TagEntity::getTag).sorted(String.CASE_INSENSITIVE_ORDER) .reduce((one, two) -> one + TAG_DELIMITER + TAG_DELIMITER + two).orElse("") + TAG_DELIMITER; }
From source file:com.liferay.apio.architect.internal.body.MultipartToBodyConverter.java
private static <T> Map<String, List<T>> _flattenMap(Map<String, Map<Integer, T>> indexedValueLists) { Set<Entry<String, Map<Integer, T>>> entries = indexedValueLists.entrySet(); Stream<Entry<String, Map<Integer, T>>> stream = entries.stream(); return stream.collect(Collectors.toMap(Entry::getKey, v -> { Map<Integer, T> map = v.getValue(); return new ArrayList<>(map.values()); }));// w w w. j a va 2 s . c om }
From source file:edu.wpi.checksims.util.PairGeneratorTest.java
public static void checkPairsAreInSet(Set<Pair<Submission, Submission>> toCheck, Set<Pair<Submission, Submission>> expected) { assertNotNull(toCheck);/* w w w. j a v a 2 s. c o m*/ assertNotNull(expected); assertEquals(expected.size(), toCheck.size()); expected.stream().forEach((pair) -> assertTrue( toCheck.contains(pair) || toCheck.contains(Pair.of(pair.getRight(), pair.getLeft())))); }
From source file:co.runrightfast.vertx.core.protobuf.MessageConversions.java
static VerticleDeployment toVerticleDeployment(@NonNull final RunRightFastVerticleDeployment deployment, @NonNull final Set<String> deploymentIds) { final VerticleDeployment.Builder builder = VerticleDeployment.newBuilder() .setVerticleClass(deployment.getVerticleClass().getName()) .setVerticleId(toVerticleId(deployment.getRunRightFastVerticleId())) .setDeploymentOptions(toDeploymentOptions(deployment.getDeploymentOptions())); final Set<RunRightFastHealthCheck> healthChecks = deployment.getHealthChecks(); if (CollectionUtils.isNotEmpty(healthChecks)) { healthChecks.stream().map(healthCheck -> toHealthCheck(healthCheck, builder.getVerticleId())) .forEach(builder::addHealthChecks); }// w w w.java2s. c o m if (CollectionUtils.isNotEmpty(deploymentIds)) { builder.addAllDeploymentIds(deploymentIds); } return builder.build(); }
From source file:io.github.moosbusch.lumpi.util.FormUtil.java
public static boolean isExcludedProperty(Class<?> type, String propertyName, Map<String, Set<Class<?>>> excludedProperties) { Map<String, Set<Class<?>>> excludedProps = excludedProperties; if (excludedProps != null) { if (excludedProps.containsKey(propertyName)) { Set<Class<?>> ignoredPropertyTypes = excludedProps.get(propertyName); Set<Class<?>> superTypes = LumpiUtil.getSuperTypes(type, true, true, true); if (!ignoredPropertyTypes.contains(type)) { if (superTypes.stream().anyMatch((superType) -> (!ignoredPropertyTypes.contains(superType)))) { return true; }/*from www.ja v a 2 s.c o m*/ } } } return false; }
From source file:fi.hsl.parkandride.back.RequestLogDao.java
private static Set<String> difference(Set<String> toPersist, BiMap<Long, String> alreadyPersisted) { return toPersist.stream().filter(val -> !alreadyPersisted.containsValue(val)).collect(toSet()); }
From source file:se.uu.it.cs.recsys.service.preference.ConstraintSolverPreferenceBuilder.java
private static short getFirstPlanYear(Set<CourseSchedule> scheduleInfo) { return scheduleInfo.stream().sorted((s1, s2) -> Short.compare(s1.getTaughtYear(), s2.getTaughtYear())) .findFirst().get().getTaughtYear(); }
From source file:cop.raml.utils.Utils.java
/** * Converts enum constants as array {@code arr} to enum string without any duplication. * * @param arr array of enum items// ww w.j a v a 2s . c om * @return {@code null} or not empty enum string (e.g. [one,two]) */ public static String toEnumStr(String... arr) { Set<String> res = asSet(arr); return res.isEmpty() ? null : res.stream().collect(Collectors.joining(",", "[", "]")); }
From source file:co.runrightfast.core.utils.JmxUtils.java
static void unregisterMBeans(final String domain, final Set<MBeanRegistration<?>> mBeanRegistrations) { if (CollectionUtils.isEmpty(mBeanRegistrations)) { return;//ww w .j a v a 2 s .co m } checkArgument(StringUtils.isNotBlank(domain)); mBeanRegistrations.stream().forEach(reg -> unregisterApplicationMBean(domain, reg.getMbeanType())); }