List of usage examples for com.google.common.collect Sets union
public static <E> SetView<E> union(final Set<? extends E> set1, final Set<? extends E> set2)
From source file:org.sosy_lab.cpachecker.cfa.ast.c.FileLocationCollectingVisitor.java
@Override public Set<FileLocation> visit(CFieldReference pE) throws RuntimeException { return Sets.union(Collections.singleton(pE.getFileLocation()), pE.getFieldOwner().accept(this)); }
From source file:org.apache.james.jmap.utils.KeywordsCombiner.java
public Set<Keyword> union(Set<Keyword> set1, Set<Keyword> set2, List<Keyword> exceptKeywords) { return Sets.union(set1, set2).stream().filter(keyword -> !exceptKeywords.contains(keyword)) .collect(Guavate.toImmutableSet()); }
From source file:org.n52.iceland.i18n.metadata.I18NProcedureMetadata.java
@Override public Set<Locale> getLocales() { return Sets.union(getShortName().getLocales(), Sets.union(getLongName().getLocales(), super.getLocales())); }
From source file:edu.jhuapl.tinkerpop.mapreduce.MapReduceElement.java
@Override public Set<String> getPropertyKeys() { return Sets.union(new HashSet<String>(properties.keySet()), new HashSet<String>(newProperties.keySet())); }
From source file:com.playonlinux.core.utils.Files.java
public static Set<PosixFilePermission> intToPosixFilePermission(int mode) { if (mode >= 1000 || mode < 0) { throw new IllegalArgumentException("Invalid mode " + mode); }/*www . j a v a 2s . co m*/ final int owner = mode / 100; final int group = (mode - owner * 100) / 10; final int others = mode - owner * 100 - group * 10; if (owner > 7 || group > 7 || others > 7) { throw new IllegalArgumentException("Invalid mode " + mode); } return Sets.union( Sets.union(singleIntToFilePermission(owner, "OWNER"), singleIntToFilePermission(group, "GROUP")), singleIntToFilePermission(others, "OTHERS")); }
From source file:com.nesscomputing.jms.ActiveMQConnectionFactoryProvider.java
@Inject public void injectInjector(Injector injector) { final TypeLiteral<Set<JmsUriInterceptor>> type = new TypeLiteral<Set<JmsUriInterceptor>>() { };/*from w ww . jav a2 s . com*/ Binding<Set<JmsUriInterceptor>> binding = injector.getExistingBinding(Key.get(type, annotation)); if (binding != null) { interceptors = Sets.union(interceptors, binding.getProvider().get()); } binding = injector.getExistingBinding(Key.get(type)); if (binding != null) { interceptors = Sets.union(interceptors, binding.getProvider().get()); } }
From source file:io.druid.firehose.kafka.KafkaSevenFirehoseFactory.java
@Override public Firehose connect(final ByteBufferInputRowParser firehoseParser) throws IOException { Set<String> newDimExclus = Sets.union( firehoseParser.getParseSpec().getDimensionsSpec().getDimensionExclusions(), Sets.newHashSet("feed")); final ByteBufferInputRowParser theParser = firehoseParser .withParseSpec(firehoseParser.getParseSpec().withDimensionsSpec( firehoseParser.getParseSpec().getDimensionsSpec().withDimensionExclusions(newDimExclus))); final ConsumerConnector connector = Consumer.createJavaConsumerConnector(new ConsumerConfig(consumerProps)); final Map<String, List<KafkaStream<Message>>> streams = connector .createMessageStreams(ImmutableMap.of(feed, 1)); final List<KafkaStream<Message>> streamList = streams.get(feed); if (streamList == null || streamList.size() != 1) { return null; }/*w w w . j av a 2s . c o m*/ final KafkaStream<Message> stream = streamList.get(0); final Iterator<MessageAndMetadata<Message>> iter = stream.iterator(); return new Firehose() { @Override public boolean hasMore() { return iter.hasNext(); } @Override public InputRow nextRow() { final Message message = iter.next().message(); if (message == null) { return null; } return parseMessage(message); } public InputRow parseMessage(Message message) { return theParser.parse(message.payload()); } @Override public Runnable commit() { return new Runnable() { @Override public void run() { /* * This is actually not going to do exactly what we want, cause it * will be called asynchronously after the persist is complete. So, * it's going to commit that it's processed more than was actually * persisted. This is unfortunate, but good enough for now. Should * revisit along with an upgrade of our Kafka version. */ log.info("committing offsets"); connector.commitOffsets(); } }; } @Override public void close() throws IOException { connector.shutdown(); } }; }
From source file:com.google.devtools.build.android.ParsedAndroidDataSubject.java
private <T extends DataValue> void compareDataValues(Iterable<Entry<DataKey, T>> actual, Iterable<Entry<DataKey, T>> expected, List<String> out, String valueType) { List<String> errors = new ArrayList<>(); ImmutableMap<DataKey, T> actualMap = ImmutableMap.copyOf(actual); ImmutableMap<DataKey, T> expectedMap = ImmutableMap.copyOf(expected); for (DataKey key : Sets.union(actualMap.keySet(), expectedMap.keySet())) { if (!(actualMap.containsKey(key) && expectedMap.containsKey(key))) { if (!actualMap.containsKey(key)) { errors.add(error("\tExpected %s.", key.toPrettyString())); }/*from w w w . j a v a 2 s. c o m*/ if (!expectedMap.containsKey(key)) { errors.add(error("\tHad unexpected %s.", key.toPrettyString())); } } else { T actualValue = actualMap.get(key); T expectedValue = expectedMap.get(key); if (!actualValue.equals(expectedValue)) { errors.add(error("\t%s is not equal", key.toPrettyString())); if (!actualValue.source().equals(expectedValue.source())) { if (!actualValue.source().getPath().equals(expectedValue.source().getPath())) { errors.add(error("\t\t%-10s: %s", "Expected path", expectedValue.source().getPath())); errors.add(error("\t\t%-10s: %s", "Actual path", actualValue.source().getPath())); } if (!actualValue.source().overrides().equals(expectedValue.source().overrides())) { errors.add(error("\t\t%-10s: %s", "Expected overrides", expectedValue.source())); errors.add(error("\t\t%-10s: %s", "Actual overrides", actualValue.source())); } } if (!actualValue.getClass().equals(expectedValue.getClass())) { errors.add(error("\t\t%-10s: %s", "Expected class", expectedValue.getClass())); errors.add(error("\t\t%-10s: %s", "Actual class", actualValue.getClass())); } else if (actualValue instanceof DataResourceXml) { errors.add(error("\t\t%-10s: %s", "Expected xml", expectedValue)); errors.add(error("\t\t%-10s: %s", "Actual xml", actualValue)); } } } } if (errors.isEmpty()) { return; } out.add(valueType); out.add(Joiner.on("\n").join(errors)); }
From source file:com.codebullets.sagalib.startup.ReflectionsTypeScanner.java
/** * {@inheritDoc}/*from w w w . j ava 2 s . c o m*/ */ @Override public Collection<Class<? extends Saga>> scanForSagas() { Set<Class<? extends Saga>> sagaTypes = reflections.getSubTypesOf(Saga.class); // separate searches in case saga-lib is in embedded jar when performing directory scanning Set<Class<? extends AbstractSaga>> abstractSagaTypes = reflections.getSubTypesOf(AbstractSaga.class); Set<Class<? extends AbstractSingleEventSaga>> singleEventSagaTypes = reflections .getSubTypesOf(AbstractSingleEventSaga.class); Set<Class<? extends Saga>> foundTypes = Sets.union(sagaTypes, abstractSagaTypes); Set<Class<? extends Saga>> mergedSet = Sets.union(foundTypes, copy(singleEventSagaTypes)); return removeAbstractTypes(mergedSet); }
From source file:edu.washington.cs.cupid.mapview.internal.GraphNodeContentProvider.java
/** * Returns union of map keys and values; if all values are {@link Set}s, the individual set elements are included. * @return Union of map keys and values//from ww w . j a v a 2s . com */ public final Set<Object> getNodes() { if (mappedToSets) { Set<Object> result = Sets.newHashSet(map.keySet()); for (Object value : map.values()) { result = Sets.union(result, (Set<?>) value); } return result; } else { return Sets.union(map.keySet(), Sets.newHashSet(map.values())); } }