public static int getClustersStat(String clusters) { Predicate predicate = new Predicate() { public boolean evaluate(Object object) { String clustersId = ((ClustersState) object).getClusters(); return clustersId.compareTo(clusters) == 0; } }; Iterator iterator = new FilterIterator(stateArray.iterator(), predicate); ClustersState state = null; while (iterator.hasNext()) { state = (ClustersState) iterator.next(); break; } return (state != null) ? state.getState() : 0; }
public static ConsumerClusters selectByClusters(String clusters) { Predicate predicate = new Predicate() { public boolean evaluate(Object object) { String id = ((ClustersRelation) object).getId(); return id.compareTo(clusters) == 0; } }; Iterator iterator = new FilterIterator(relationArray.iterator(), predicate); ClustersRelation relation = null; while (iterator.hasNext()) { relation = (ClustersRelation) iterator.next(); break; } return (relation != null) ? relation.getClusters() : null; }
/** * return an iterator over visual children that haven't been marked described. */ // TODO visual children are marked described by the descriptor // generator, so there is some order-of-codegen sensitivity // here. It's the only such dependency, but at some point // descriptor codegen and marking-of-isDescribed should be // split apart. public final Iterator getProceduralVisualChildInitializerIterator() { if (root instanceof MovieClip) { return new FilterIterator(((MovieClip)root).getChildInitializerIterator(), new Predicate() { public boolean evaluate(Object object) { ValueInitializer init = (ValueInitializer)object; Object value = init.getValue(); return !(value instanceof Model) || (!((Model)value).isDescribed() && !((Model)value).isStateSpecific()); } }); } else { return Collections.EMPTY_LIST.iterator(); } }
/** * Note that we do *not* filter out bindings for element initializers. */ @SuppressWarnings("unchecked") public final Iterator<ArrayElementInitializer> getElementInitializerIterator() { return new FilterIterator(list.iterator(), new Predicate() { public boolean evaluate(Object object) { return (! (((ArrayElementInitializer) object).getValue() instanceof Reparent)); } }); }
/** * NOTE: suppress declaration of inherited properties */ public final Iterator<PropertyDeclaration> getDeclarationIterator() { final Type superType = getSuperClass(); return new FilterIterator(declarations.values().iterator(), new Predicate() { public boolean evaluate(Object object) { return superType.getProperty(((PropertyDeclaration)object).getName()) == null; } }); }
/** * */ private final Iterator<PropertyDeclaration> getTopLevelDeclarationIterator() { return new FilterIterator(declarations.values().iterator(), new Predicate() { public boolean evaluate(Object object) { return ((PropertyDeclaration)object).getTopLevel(); } }); }
/** * */ public final Iterator<Initializer> getNonStagePropertyInitializerIterator() { return new FilterIterator(new IteratorChain(root.getPropertyInitializerIterator(false), getTopLevelInitializerIterator()), new Predicate() { public boolean evaluate(Object object) { if (object instanceof NamedInitializer) return (!StandardDefs.isStageProperty(((NamedInitializer)object).getName())) && (!((NamedInitializer)object).isDesignLayer()); return true; } }); }
/** * */ public final Iterator<Initializer> getDesignLayerPropertyInitializerIterator() { return new FilterIterator(layerDeclarations.iterator(), new Predicate() { public boolean evaluate(Object object) { return object instanceof InitializedPropertyDeclaration; } }); }
/** * */ public final Iterator<Initializer> getStagePropertyInitializerIterator() { return new FilterIterator(new IteratorChain(root.getPropertyInitializerIterator(false), getTopLevelInitializerIterator()), new Predicate() { public boolean evaluate(Object object) { if (object instanceof NamedInitializer) return StandardDefs.isStageProperty(((NamedInitializer)object).getName()); return false; } }); }
/** * */ public final Iterator<Initializer> getTopLevelInitializerIterator() { return new FilterIterator(getTopLevelDeclarationIterator(), new Predicate() { public boolean evaluate(Object object) { return object instanceof InitializedPropertyDeclaration; } }); }
/** * */ @SuppressWarnings("unchecked") protected Iterator<Initializer> bindingFilter(Iterator<? extends Initializer> iter, final boolean include) { return new FilterIterator(iter, new Predicate() { public boolean evaluate(Object object) { return (((Initializer) object).isBinding()) == include; } }); }
/** * Creates the FilterIterator that underlies this Iterator */ protected void initialize() { if (!initialized) { filteredBalances = new FilterIterator(balancesSource, new Predicate() { public boolean evaluate(Object obj) { return balancePredicate.select((Balance) obj); } }); initialized = true; } }
/** * Returns an iterator with elements from an original <code>iterator</code> where the * given <code>predicate</code> matches removed. * * @param <T> * @param iterator * @param predicate * @return */ @SuppressWarnings("unchecked") public static <T> Iterator<T> filterIterator(Iterator<? extends T> iterator, final Predicate<? super T> predicate) { return new FilterIterator(iterator, new org.apache.commons.collections.Predicate() { public boolean evaluate(Object object) { return predicate.evaluate((T) object); } }); }