Example usage for com.google.common.collect Iterators removeIf

List of usage examples for com.google.common.collect Iterators removeIf

Introduction

In this page you can find the example usage for com.google.common.collect Iterators removeIf.

Prototype

public static <T> boolean removeIf(Iterator<T> removeFrom, Predicate<? super T> predicate) 

Source Link

Document

Removes every element that satisfies the provided predicate from the iterator.

Usage

From source file:gg.uhc.uhc.modules.recipes.NotchApplesModule.java

@Override
protected void onDisable() {
    Iterators.removeIf(Bukkit.recipeIterator(), IS_NOTCH_APPLE_RECIPE);
}

From source file:gov.va.isaac.gui.dialog.ExportFileSettingsDialogController.java

/**
 * Initialize./* www .  j  a  v a2  s.c o  m*/
 */
@FXML
public void initialize() {
    ExportTypeStringConverter converter = new ExportTypeStringConverter();

    // Populate modelTypeCombo.
    modelTypeCombo.setConverter(converter);
    modelTypeCombo.setItems(ExportType.asObservableList());

    // Populate pathCombo

    ObservableList<ConceptChronicleBI> paths = FXCollections
            .observableArrayList(new ArrayList<ConceptChronicleBI>());
    try {
        List<ConceptChronicleBI> pathConcepts = OTFUtility.getPathConcepts();
        Iterators.removeIf(pathConcepts.iterator(), new Predicate<ConceptChronicleBI>() {

            @Override
            public boolean apply(ConceptChronicleBI arg0) {
                try {
                    return arg0.getVersion(OTFUtility.getViewCoordinate()).get().getPreferredDescription()
                            .getText().startsWith(TermAux.SNOMED_CORE.getDescription() + " ");
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (ContradictionException e) {
                    e.printStackTrace();
                }
                return false;
            }

        });
        paths.addAll(pathConcepts);
    } catch (ValidationException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (ContradictionException e) {
        e.printStackTrace();
    }
    pathCombo.setItems(paths);

    // Properties to speed development.
    String modelTypeName = System.getProperty(MODEL_TYPE_PROPERTY);
    if (modelTypeName != null) {
        LOG.debug(MODEL_TYPE_PROPERTY + "=" + modelTypeName);
        ExportType modelType = converter.fromString(modelTypeName);
        modelTypeCombo.setValue(modelType);
    }
}

From source file:org.grouplens.lenskit.scored.ScoredIdBuilder.java

/**
 * Add a new unboxed side channel to the {@code ScoredId} under construction.
 * @param symbol The symbol for the side channel.
 * @param value The numerical value for the side channel.
 * @return This builder (for chaining)/*from w w w. ja  va  2 s .c o  m*/
 * @see #addChannel(TypedSymbol, Object)
 */
public ScoredIdBuilder addChannel(Symbol symbol, double value) {
    Preconditions.checkNotNull(symbol, "symbol cannot be null");
    DoubleSymbolValue sv = SymbolValue.of(symbol, value);
    Iterators.removeIf(channels.iterator(), SymbolValue.hasSymbol(sv.getSymbol()));
    channels.add(sv);
    return this;
}

From source file:jp.co.ctc_g.jse.core.message.Messages.java

/**
 * ?????//from   w  ww  .jav  a  2s .c  o  m
 * @param key 
 */
public void remove(String key) {
    final String k = key;
    Iterators.removeIf(messageItemList.iterator(), new Predicate<Message>() {
        @Override
        public boolean apply(Message m) {
            return m.getKey().equals(k);
        }
    });
}

From source file:org.grouplens.lenskit.scored.ScoredIdBuilder.java

/**
 * Add a new side channel to the {@code ScoredId} under construction.
 * @param symbol The symbol for the side channel.
 * @param value The value for the side channel.
 * @return This builder (for chaining)//from  w ww. j av a 2  s.c  o  m
 */
public <K> ScoredIdBuilder addChannel(@Nonnull TypedSymbol<K> symbol, @Nonnull K value) {
    Preconditions.checkNotNull(symbol, "symbol cannot be null");
    Preconditions.checkNotNull(value, "value cannot be null");
    Preconditions.checkArgument(symbol.getType().isInstance(value), "value is not of type " + symbol.getType());
    SymbolValue<K> val = SymbolValue.of(symbol, value);
    Iterators.removeIf(channels.iterator(), SymbolValue.hasSymbol(symbol));
    channels.add(val);
    return this;
}

From source file:org.gradle.model.dsl.internal.spike.ScopeVisitor.java

private void addCreator(String path, ClosureExpression creator) {
    final ImmutableMap<String, String> referenceAliasesMap = ImmutableMap.copyOf(referenceAliases);
    ReferenceExtractor extractor = new ReferenceExtractor(sourceUnit, referenceAliasesMap);
    Iterators.removeIf(creator.getVariableScope().getReferencedLocalVariablesIterator(),
            new Predicate<Variable>() {
                public boolean apply(Variable variable) {
                    return referenceAliasesMap.keySet().contains(variable.getName());
                }/*  w w w.ja va 2  s .c o  m*/
            });
    creator.getCode().visit(extractor);
    statementGenerator.addCreator(path, creator, extractor.getReferencedPaths());
}

From source file:zotmc.collect.delegate.IterativeMap.java

@Override
public Set<K> keySet() {
    final Set<Entry<K, V>> backing = entrySet();

    return keySet != null ? keySet : (keySet = new TransformedSet<Entry<K, V>, K>() {
        @Override// w ww  .j  a v a2 s  .com
        protected Set<Entry<K, V>> backing() {
            return backing;
        }

        @Override
        protected Function<Entry<K, V>, K> transformation() {
            return entryToKey();
        }

        @Override
        public boolean add(K e) {
            throw new UnsupportedOperationException();
        }

        @Override
        public boolean contains(Object o) {
            return Iterators.any(IterativeMap.this.backing().iterator(), keyEqualTo(cast(o)));
        }

        @Override
        public boolean remove(Object o) {
            return Iterators.removeIf(IterativeMap.this.backing().iterator(), keyEqualTo(cast(o)));
        }
    });
}