Example usage for com.google.common.collect Iterables concat

List of usage examples for com.google.common.collect Iterables concat

Introduction

In this page you can find the example usage for com.google.common.collect Iterables concat.

Prototype

public static <T> Iterable<T> concat(Iterable<? extends T> a, Iterable<? extends T> b) 

Source Link

Document

Combines two iterables into a single iterable.

Usage

From source file:com.synflow.cx.internal.services.BoolCxSwitch.java

@Override
public Boolean caseExpressionVariable(ExpressionVariable expr) {
    return check(this, Iterables.concat(expr.getIndexes(), expr.getParameters()));
}

From source file:com.cloudera.oryx.kmeans.common.Centers.java

/**
 * Construct a new {@code Centers} object made up of the given {@code Vector}
 * and the points contained in this instance.
 * /*from  w w w.  j a  va  2s. co  m*/
 * @param point The new point
 * @return A new {@code Centers} instance
 */
public Centers extendWith(RealVector point) {
    return new Centers(Iterables.concat(centers, ImmutableList.of(point)));
}

From source file:com.b2international.snowowl.snomed.datastore.index.change.DescriptionAcceptabilityChangeProcessor.java

public Map<String, Multimap<Acceptability, RefSetMemberChange>> process(ICDOCommitChangeSet commitChangeSet,
        RevisionSearcher searcher) throws IOException {
    final Multimap<String, RefSetMemberChange> preferredMemberChanges = HashMultimap.create();
    final Multimap<String, RefSetMemberChange> acceptableMemberChanges = HashMultimap.create();

    // add active new and active dirty members
    final Iterable<SnomedLanguageRefSetMember> newAndDirtyMembers = Iterables.concat(
            commitChangeSet.getNewComponents(SnomedLanguageRefSetMember.class),
            commitChangeSet.getDirtyComponents(SnomedLanguageRefSetMember.class));

    for (SnomedLanguageRefSetMember member : newAndDirtyMembers) {
        if (member.isActive()) {
            final String uuid = member.getUuid();
            final String refSetId = member.getRefSetIdentifierId();
            final RefSetMemberChange change = new RefSetMemberChange(uuid, refSetId, MemberChangeKind.ADDED,
                    member.isActive());// w ww . j  ava2  s.c  om
            registerChange(preferredMemberChanges, acceptableMemberChanges, member.getAcceptabilityId(),
                    member.getReferencedComponentId(), change);
        }
    }

    // remove dirty inactive (and/or changed in acceptability) members
    final Iterable<SnomedLanguageRefSetMember> dirtyMembers = commitChangeSet
            .getDirtyComponents(SnomedLanguageRefSetMember.class);

    final Iterable<Long> dirtyMemberStorageKeys = CDOIDUtils.createCdoIdToLong(CDOIDUtils.getIds(dirtyMembers));
    final Iterable<Long> detachedMemberStorageKeys = CDOIDUtils.createCdoIdToLong(
            commitChangeSet.getDetachedComponents(SnomedRefSetPackage.Literals.SNOMED_LANGUAGE_REF_SET_MEMBER));
    final Map<Long, SnomedRefSetMemberIndexEntry> currentRevisionsByStorageKey = Maps.uniqueIndex(
            searcher.get(SnomedRefSetMemberIndexEntry.class,
                    Iterables.concat(dirtyMemberStorageKeys, detachedMemberStorageKeys)),
            new Function<SnomedRefSetMemberIndexEntry, Long>() {
                @Override
                public Long apply(SnomedRefSetMemberIndexEntry input) {
                    return input.getStorageKey();
                }
            });

    for (SnomedLanguageRefSetMember member : dirtyMembers) {
        final String uuid = member.getUuid();
        final String refSetId = member.getRefSetIdentifierId();
        final RefSetMemberChange change = new RefSetMemberChange(uuid, refSetId, MemberChangeKind.REMOVED,
                member.isActive());
        final SnomedRefSetMemberIndexEntry before = currentRevisionsByStorageKey
                .get(CDOIDUtil.getLong(member.cdoID()));
        if (before != null) {
            final String beforeAcceptabilityId = before.getAcceptabilityId();
            final boolean beforeActive = before.isActive();
            final boolean acceptabilityChanged = !member.getAcceptabilityId().equals(beforeAcceptabilityId);

            if (beforeActive && acceptabilityChanged) {
                registerChange(preferredMemberChanges, acceptableMemberChanges, beforeAcceptabilityId,
                        member.getReferencedComponentId(), change);
            }
        }

        if (!member.isActive()) {
            registerChange(preferredMemberChanges, acceptableMemberChanges, member.getAcceptabilityId(),
                    member.getReferencedComponentId(), change);
        }
    }

    // remove earlier active detached members

    for (CDOID cdoid : commitChangeSet
            .getDetachedComponents(SnomedRefSetPackage.Literals.SNOMED_LANGUAGE_REF_SET_MEMBER)) {
        final SnomedRefSetMemberIndexEntry before = currentRevisionsByStorageKey.get(CDOIDUtil.getLong(cdoid));
        if (before.isActive()) {
            final String uuid = before.getId();
            final String refSetId = before.getReferenceSetId();
            final String referencedComponentId = before.getReferencedComponentId();
            final String beforeAcceptabilityId = before.getAcceptabilityId();
            final RefSetMemberChange change = new RefSetMemberChange(uuid, refSetId, MemberChangeKind.REMOVED,
                    before.isActive());

            registerChange(preferredMemberChanges, acceptableMemberChanges, beforeAcceptabilityId,
                    referencedComponentId, change);
        }
    }

    final Map<String, Multimap<Acceptability, RefSetMemberChange>> changes = newHashMap();

    for (String descriptionId : Iterables.concat(preferredMemberChanges.keySet(),
            acceptableMemberChanges.keySet())) {
        if (!changes.containsKey(descriptionId)) {
            changes.put(descriptionId, HashMultimap.<Acceptability, RefSetMemberChange>create());
        }
        final Multimap<Acceptability, RefSetMemberChange> memberChanges = changes.get(descriptionId);

        memberChanges.putAll(Acceptability.PREFERRED, preferredMemberChanges.get(descriptionId));
        memberChanges.putAll(Acceptability.ACCEPTABLE, acceptableMemberChanges.get(descriptionId));
    }
    return changes;
}

From source file:com.google.jenkins.plugins.dsl.tag.ArgumentYamlTransform.java

/** Merge the two transforms, producing a new combined transformation. */
public ArgumentYamlTransform merge(ArgumentYamlTransform other) {
    checkState(getTag().equals(other.getTag()));
    return new ArgumentYamlTransform(getTag(),
            Lists.newArrayList(Iterables.concat(getArguments(), other.getArguments())),
            Lists.newArrayList(Iterables.concat(getClasses(), other.getClasses())));
}

From source file:org.eclipse.sirius.ui.tools.internal.views.common.item.ProjectDependenciesItemImpl.java

/**
 * Get the children of this item.//from   w  w  w. j  av  a  2s  .  c  o  m
 *
 * @return the children, never <code>null</code>
 */
@Override
public Collection<?> getChildren() {
    Collection<Object> children = Sets.newLinkedHashSet();

    Session session = project.getSession();
    if (session != null) {
        /*
         * Retrieve all resources of the session not located directly in the
         * project
         */
        Iterable<Resource> semanticDeps = session.getSemanticResources();
        if (session instanceof DAnalysisSessionEObject) {
            semanticDeps = Iterables.concat(semanticDeps,
                    ((DAnalysisSessionEObject) session).getControlledResources());
        }
        children.addAll(extractProjectDependencies(semanticDeps));

        Iterable<Resource> analysesDeps = extractProjectDependencies(session.getAllSessionResources());
        for (Resource analysisRes : analysesDeps) {
            children.add(new AnalysisResourceItemImpl(session, analysisRes, this));
        }
    }
    return children;
}

From source file:org.apache.cassandra.db.migration.AddColumnFamily.java

private KSMetaData makeNewKeyspaceDefinition(KSMetaData ksm) {
    return KSMetaData.cloneWith(ksm, Iterables.concat(ksm.cfMetaData().values(), Collections.singleton(cfm)));
}

From source file:org.lanternpowered.server.block.type.VariantBlock.java

public VariantBlock(String pluginId, String identifier, @Nullable Function<BlockType, ItemType> itemTypeBuilder,
        BlockTrait<E> variantTrait, Iterable<BlockTrait<?>> blockTraits) {
    super(pluginId, identifier, itemTypeBuilder,
            Iterables.concat(Collections.singleton(variantTrait), blockTraits));

    this.variantTrait = variantTrait;
    String pluginPath = "";
    if (!this.getPluginId().equalsIgnoreCase("minecraft")) {
        pluginPath = this.getPluginId() + '.';
    }/*  w ww  . j a  v a 2s  .  c om*/
    for (E element : variantTrait.getPossibleValues()) {
        this.translations.put(element, Lantern.getRegistry().getTranslationManager()
                .get(pluginPath + this.getTranslationKey(element)));
    }
}

From source file:org.apache.cassandra.index.sasi.conf.view.View.java

public View(ColumnIndex index, Collection<SSTableIndex> currentView, Collection<SSTableReader> oldSSTables,
        Set<SSTableIndex> newIndexes) {
    Map<Descriptor, SSTableIndex> newView = new HashMap<>();

    AbstractType<?> validator = index.getValidator();
    TermTree.Builder termTreeBuilder = (validator instanceof AsciiType || validator instanceof UTF8Type)
            ? new PrefixTermTree.Builder(index.getMode().mode, validator)
            : new RangeTermTree.Builder(index.getMode().mode, validator);

    List<Interval<Key, SSTableIndex>> keyIntervals = new ArrayList<>();
    for (SSTableIndex sstableIndex : Iterables.concat(currentView, newIndexes)) {
        SSTableReader sstable = sstableIndex.getSSTable();
        if (oldSSTables.contains(sstable) || sstable.isMarkedCompacted()
                || newView.containsKey(sstable.descriptor)) {
            sstableIndex.release();//from w w  w  . j a va2 s .c  om
            continue;
        }

        newView.put(sstable.descriptor, sstableIndex);

        termTreeBuilder.add(sstableIndex);
        keyIntervals.add(Interval.create(new Key(sstableIndex.minKey(), index.keyValidator()),
                new Key(sstableIndex.maxKey(), index.keyValidator()), sstableIndex));
    }

    this.view = newView;
    this.termTree = termTreeBuilder.build();
    this.keyValidator = index.keyValidator();
    this.keyIntervalTree = IntervalTree.build(keyIntervals);

    if (keyIntervalTree.intervalCount() != termTree.intervalCount())
        throw new IllegalStateException(
                String.format("mismatched sizes for intervals tree for keys vs terms: %d != %d",
                        keyIntervalTree.intervalCount(), termTree.intervalCount()));
}

From source file:org.gradle.plugins.ide.eclipse.model.WtpComponent.java

public void configure(String deployName, String contextPath, List<WbModuleEntry> newEntries) {
    Iterable<WbModuleEntry> toKeep = Iterables.filter(wbModuleEntries,
            not(instanceOf(WbDependentModule.class)));
    this.wbModuleEntries = Lists.newArrayList(Sets.newLinkedHashSet(Iterables.concat(toKeep, newEntries)));
    if (!isNullOrEmpty(deployName)) {
        this.deployName = deployName;
    }/*  w  ww .  jav a  2  s  .c  om*/
    if (!isNullOrEmpty(contextPath)) {
        this.contextPath = contextPath;
    }
}

From source file:org.sonar.server.permission.ws.SearchProjectPermissionsData.java

Set<String> permissions(long rootComponentId) {
    return FluentIterable
            .from(Iterables.concat(userCountByProjectIdAndPermission.row(rootComponentId).keySet(),
                    groupCountByProjectIdAndPermission.row(rootComponentId).keySet()))
            .toSortedSet(Ordering.natural());
}