Example usage for com.google.common.collect ImmutableSet iterator

List of usage examples for com.google.common.collect ImmutableSet iterator

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSet iterator.

Prototype

Iterator<E> iterator();

Source Link

Document

Returns an iterator over the elements in this set.

Usage

From source file:org.locationtech.geogig.api.plumbing.ResolveBranchId.java

@Override
protected Optional<Ref> _call() {
    Preconditions.checkState(id != null, "id has not been set.");
    Predicate<Ref> filter = new Predicate<Ref>() {
        @Override//  w  w w  .j  a  va  2  s  .  com
        public boolean apply(@Nullable Ref ref) {
            return ref.getObjectId().equals(id);
        }
    };
    ImmutableSet<Ref> refs = command(ForEachRef.class).setFilter(filter).call();
    if (refs.isEmpty()) {
        return Optional.absent();
    } else {
        return Optional.of(refs.iterator().next());
    }
}

From source file:org.springframework.ide.eclipse.boot.dash.views.properties.ExposedPropertyControl.java

@Override
public void refreshControl() {
    AbstractLaunchConfigurationsDashElement<?> bde = getLocalBootDashElement();

    if (bde != null) {
        StringBuilder labelText = new StringBuilder();

        ImmutableSet<ILaunchConfiguration> configs = bde.getLaunchConfigs();
        if (configs.size() == 1) {
            String tunnelName = configs.iterator().next().getName();
            NGROKClient ngrokClient = NGROKLaunchTracker.get(tunnelName);
            if (ngrokClient != null) {
                labelText.append(ngrokClient.getTunnel().getPublic_url()
                        + "   --- (local ngrok instance at: <a href=\"\">" + ngrokClient.getURL() + "</a>)");
            }/*from   w w w  .j a v a2s. c  o  m*/
        }

        exposedURL.setText(labelText.toString());
    }
}

From source file:org.locationtech.geogig.plumbing.ResolveBranchId.java

@Override
protected Optional<Ref> _call() {
    Preconditions.checkState(id != null, "id has not been set.");
    Predicate<Ref> filter = new Predicate<Ref>() {

        private ObjectId id = ResolveBranchId.this.id;

        @Override//from www .j a va 2s  .com
        public boolean apply(@Nullable Ref ref) {
            String refName = ref.getName();
            ObjectId refId = ref.getObjectId();
            return refName.startsWith(Ref.HEADS_PREFIX) && refId.equals(this.id);
        }
    };
    ImmutableSet<Ref> refs = command(ForEachRef.class).setFilter(filter).call();
    if (refs.isEmpty()) {
        return Optional.absent();
    } else {
        return Optional.of(refs.iterator().next());
    }
}

From source file:shadowmage.ancient_warfare.common.machine.TEChunkLoader.java

public void setTicket(Ticket tk) {
    this.releaseTicket();
    this.tk = tk;
    if (this.tk != null) {
        NBTTagCompound tag = new NBTTagCompound();
        tag.setCompoundTag("pos", new BlockPosition(xCoord, yCoord, zCoord).writeToNBT(new NBTTagCompound()));
        tk.getModData().setCompoundTag("chunkTE", tag);

        ForgeChunkManager.forceChunk(tk, new ChunkCoordIntPair(xCoord >> 4, zCoord >> 4));
        ImmutableSet tkCk = tk.getChunkList();
        Iterator<ChunkCoordIntPair> it = tkCk.iterator();
        while (it.hasNext()) {
            ChunkCoordIntPair ccip = it.next();
            this.forceChunk(ccip);
        }/*  w  w  w . jav  a 2s  .co  m*/
        for (ChunkCoordIntPair ccip : this.forcedChunks) {
            this.forceChunk(ccip);
        }
    }
}

From source file:org.springframework.ide.eclipse.boot.dash.views.properties.ExposedPropertyControl.java

@Override
public void createControl(Composite composite, TabbedPropertySheetPage page) {
    super.createControl(composite, page);
    page.getWidgetFactory().createLabel(composite, "Exposed via:") //$NON-NLS-1$
            .setLayoutData(GridDataFactory.fillDefaults().create());

    exposedURL = new Link(composite, SWT.NONE);
    exposedURL.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    exposedURL.setBackground(composite.getBackground());

    exposedURL.addListener(SWT.Selection, new Listener() {
        @Override//from  ww w  .ja v a2 s .  c o  m
        public void handleEvent(Event event) {
            AbstractLaunchConfigurationsDashElement<?> bde = getLocalBootDashElement();
            if (bde != null) {
                ImmutableSet<ILaunchConfiguration> launchConfigs = bde.getLaunchConfigs();
                if (launchConfigs.size() == 1) {
                    String tunnelName = launchConfigs.iterator().next().getName();
                    NGROKClient ngrokClient = NGROKLaunchTracker.get(tunnelName);
                    if (ngrokClient != null) {
                        String addr = ngrokClient.getURL();
                        UiUtil.openUrl(addr);
                    }
                }
            }
        }
    });
}

From source file:info.gehrels.voting.singleTransferableVote.STVElectionCalculationStep.java

private CANDIDATE_TYPE chooseOneOutOfManyCandidates(ImmutableSet<CANDIDATE_TYPE> candidates) {
    if (candidates.size() == 1) {
        return candidates.iterator().next();
    }//from  w ww . j  a  v  a2 s .  c o  m

    CANDIDATE_TYPE chosenCandidate = null;
    if (candidates.size() > 1) {
        electionCalculationListener.delegatingToExternalAmbiguityResolution(candidates);
        AmbiguityResolverResult<CANDIDATE_TYPE> ambiguityResolverResult = ambiguityResolver
                .chooseOneOfMany(candidates);
        electionCalculationListener.externallyResolvedAmbiguity(ambiguityResolverResult);
        chosenCandidate = ambiguityResolverResult.chosenCandidate;
    }

    return chosenCandidate;
}

From source file:com.facebook.buck.features.project.intellij.model.AbstractIjModuleAndroidFacet.java

public Optional<Path> getFirstManifestPath() {
    ImmutableSet<Path> androidManifestPaths = getManifestPaths();
    if (androidManifestPaths.isEmpty()) {
        return Optional.empty();
    } else {//w ww.j  a  v a  2 s  .co  m
        return Optional.of(androidManifestPaths.iterator().next());
    }
}

From source file:dagger.internal.codegen.DependencyRequestFormatter.java

/**
 * Returns a string of the form "{@code @BindsOptionalOf SomeKey is declared at Module.method()}",
 * where {@code Module.method()} is the declaration. If there is more than one such declaration,
 * one is chosen arbitrarily, and ", among others" is appended.
 */// w  w  w  . ja v  a2 s .  c o m
private String formatSyntheticOptionalBindingDependency(
        ImmutableSet<OptionalBindingDeclaration> optionalBindingDeclarations) {
    OptionalBindingDeclaration optionalBindingDeclaration = optionalBindingDeclarations.iterator().next();
    StringBuilder builder = new StringBuilder();
    builder.append(INDENT).append("@BindsOptionalOf ").append(formatKey(optionalBindingDeclaration.key()))
            .append(" is declared at\n").append(DOUBLE_INDENT);

    appendEnclosingTypeAndMemberName(optionalBindingDeclaration.bindingElement().get(), builder);
    builder.append("()");
    if (optionalBindingDeclarations.size() > 1) {
        builder.append(", among others");
    }

    return builder.toString();
}

From source file:org.androidtransfuse.analysis.module.ProvidesProcessor.java

public ModuleConfiguration process(ASTType moduleType, ASTType moduleScanTarget, ASTMethod astMethod,
        ASTAnnotation astAnnotation) {//from ww  w .  ja v a2  s  . co m

    ImmutableSet<ASTAnnotation> qualifierAnnotations = FluentIterable.from(astMethod.getAnnotations())
            .filter(qualifierPredicate).toSet();

    ImmutableSet<ASTAnnotation> scopeAnnotations = FluentIterable.from(astMethod.getAnnotations())
            .filter(scopePredicate).toSet();

    ASTAnnotation scope = null;
    if (scopeAnnotations.size() > 0) {
        scope = scopeAnnotations.iterator().next();
    }

    validate(astMethod, astMethod.getAnnotations());

    return new ProvidesModuleConfiguration(moduleType, qualifierAnnotations, astMethod, scope);
}

From source file:org.cyclop.service.exporter.intern.CsvQueryResultExporterImpl.java

private void appendMap(PrintWriter out, Row row, CqlExtendedColumnName column) {
    ImmutableSet<Map.Entry<CqlColumnValue, CqlColumnValue>> displayMap = extractor.extractMap(row, column)
            .entrySet();/* w w  w .j  av a 2 s  .co  m*/
    Iterator<Map.Entry<CqlColumnValue, CqlColumnValue>> it = displayMap.iterator();

    LOG.trace("Appending: {}", displayMap);

    StringBuilder mapBuf = new StringBuilder();
    while (it.hasNext()) {
        Map.Entry<CqlColumnValue, CqlColumnValue> entry = it.next();

        CqlColumnValue key = entry.getKey();
        String keyText = esc(converter.convert(key.value));
        mapBuf.append(keyText);

        mapBuf.append(conf.separatorMap);

        CqlColumnValue val = entry.getValue();
        String valText = esc(converter.convert(val.value));
        mapBuf.append(valText);

        if (it.hasNext()) {
            mapBuf.append(conf.separatorList);
        }
    }

    String mapVal = esc(mapBuf.toString());
    LOG.trace("Appended map: {}", mapVal);
    out.append(mapVal);
}