List of usage examples for org.apache.commons.collections.iterators TransformIterator TransformIterator
public TransformIterator(Iterator iterator, Transformer transformer)
TransformIterator
that will use the given iterator and transformer. From source file:edu.umd.cfar.lamp.viper.util.CropIteratorUtility.java
public Iterator getIterator(Iterator iter) { return new TransformIterator(new FilterIterator(iter, pred), trans); }
From source file:com.texeltek.accumulocloudbaseshim.TransformIterable.java
public Iterator<To> iterator() { return new TransformIterator(from.iterator(), transformer); }
From source file:com.texeltek.accumulocloudbaseshim.BatchScannerShim.java
public Iterator<Map.Entry<Key, Value>> iterator() { return new TransformIterator(new CloudbaseBatchScannerCloseableIterator(impl), new Transformer() { @Override/*from www . j a v a 2s . c o m*/ public Object transform(Object input) { Map.Entry<cloudbase.core.data.Key, cloudbase.core.data.Value> entry = (Map.Entry<cloudbase.core.data.Key, cloudbase.core.data.Value>) input; return new EntryShim(new Key(entry.getKey()), new Value(entry.getValue())); } }); }
From source file:com.texeltek.accumulocloudbaseshim.ScannerShim.java
public Iterator<Map.Entry<Key, Value>> iterator() { return new TransformIterator(impl.iterator(), new Transformer() { public Object transform(Object input) { Map.Entry<cloudbase.core.data.Key, cloudbase.core.data.Value> entry = (Map.Entry<cloudbase.core.data.Key, cloudbase.core.data.Value>) input; return new EntryShim(new Key(entry.getKey()), new Value(entry.getValue())); }//from w w w .j a v a 2 s.co m }); }
From source file:com.sworddance.util.NotNullIterator.java
@Override protected void setIterator(Object iterator) { Iterator<?> iter = extractIterator(iterator); TransformIterator transformIterator = new TransformIterator(iter, ReferenceTransformer.INSTANCE); super.setIterator(new FilterIterator(transformIterator, NotNullKeyValuePredicate.INSTANCE)); }
From source file:com.texeltek.accumulocloudbaseshim.BatchDeleterShim.java
public Iterator<Map.Entry<Key, Value>> iterator() { return new TransformIterator(((BatchScanner) impl).iterator(), new Transformer() { public Object transform(Object input) { Map.Entry<cloudbase.core.data.Key, cloudbase.core.data.Value> entry = (Map.Entry<cloudbase.core.data.Key, cloudbase.core.data.Value>) input; return new EntryShim(new Key(entry.getKey()), new Value(entry.getValue())); }/*from www. j a v a2 s . co m*/ }); }
From source file:com.amalto.core.storage.StagingStorage.java
@Override public void update(Iterable<DataRecord> records) { final TransformIterator iterator = new TransformIterator(records.iterator(), new Transformer() { @Override/*w ww. j a v a 2 s. c o m*/ public Object transform(Object input) { DataRecord dataRecord = (DataRecord) input; DataRecordMetadata metadata = dataRecord.getRecordMetadata(); Map<String, String> recordProperties = metadata.getRecordProperties(); // Update on a record in staging reset all its match&merge information. String status = recordProperties.get(METADATA_STAGING_STATUS); StagingUpdateAction updateAction = updateActions.get(status); if (updateAction == null) { // Try to re-read status from database if (status == null) { UserQueryBuilder readStatus = from(dataRecord.getType()); for (FieldMetadata keyField : dataRecord.getType().getKeyFields()) { readStatus.where(eq(keyField, StorageMetadataUtils.toString(dataRecord.get(keyField), keyField))); } StorageResults refreshedRecord = delegate.fetch(readStatus.getSelect()); for (DataRecord record : refreshedRecord) { Map<String, String> refreshedProperties = record.getRecordMetadata() .getRecordProperties(); updateAction = updateActions.get(refreshedProperties.get(METADATA_STAGING_STATUS)); } } // Database doesn't have any satisfying update action if (updateAction == null) { updateAction = defaultUpdateAction; // Covers cases where update action isn't specified. } } recordProperties.put(Storage.METADATA_STAGING_STATUS, updateAction.value()); recordProperties.put(Storage.METADATA_STAGING_ERROR, StringUtils.EMPTY); if (updateAction.resetTaskId()) { metadata.setTaskId(null); } return dataRecord; } }); Iterable<DataRecord> transformedRecords = new Iterable<DataRecord>() { @Override public Iterator<DataRecord> iterator() { return iterator; } }; delegate.update(transformedRecords); }
From source file:hudson.plugins.emailext.plugins.recipients.FailingTestSuspectsRecipientProviderTest.java
private static void addMockChangeSet(final AbstractBuild build, final String... inAuthors) { PowerMockito.when(build.getChangeSet()).thenReturn(new ChangeLogSet(build) { final String[] authors = inAuthors; @Override/*from w w w . j av a2s . c o m*/ public boolean isEmptySet() { return authors.length == 0; } public Iterator iterator() { return new TransformIterator(Arrays.asList(authors).iterator(), new Transformer() { @Override public Object transform(final Object inAuthor) { return new ChangeLogSet.Entry() { @Override public String getMsg() { return "COMMIT MESSAGE"; } @Override public User getAuthor() { return getMockUser((String) inAuthor); } @Override public Collection<String> getAffectedPaths() { return Collections.EMPTY_SET; } @Override public String getMsgAnnotated() { return getMsg(); } @Override public Collection<? extends ChangeLogSet.AffectedFile> getAffectedFiles() { return Collections.EMPTY_SET; } }; } }); } }); }
From source file:io.wcm.config.core.persistence.impl.ToolsConfigPagePersistenceProvider.java
@SuppressWarnings("unchecked") private Iterator<String> findConfigRefs(Resource startResource) { // collect all context path resources without config ref, and expand to config page path Iterator<ContextResource> contextResources = contextPathStrategy.findContextResources(startResource); return new FilterIterator(new TransformIterator(contextResources, new Transformer() { @Override//from w ww . j a v a 2s . c o m public Object transform(Object input) { ContextResource contextResource = (ContextResource) input; if (contextResource.getConfigRef() == null) { String configPath = getConfigPagePath(contextResource.getResource().getPath()); log.trace("+ Found reference for context path {}: {}", contextResource.getResource().getPath(), configPath); return configPath; } return null; } }), PredicateUtils.notNullPredicate()); }
From source file:io.wcm.caconfig.extensions.persistence.impl.ToolsConfigPagePersistenceStrategy.java
/** * Searches the resource hierarchy upwards for all config references and returns them. *///from w w w. j a va 2 s. c o m @SuppressWarnings("unchecked") private Iterator<String> findConfigRefs(@NotNull final Resource startResource, @NotNull final Collection<String> bucketNames) { // collect all context path resources (but filter out those without config reference) final Iterator<ContextResource> contextResources = new FilterIterator( contextPathStrategy.findContextResources(startResource), new Predicate() { @Override public boolean evaluate(Object object) { ContextResource contextResource = (ContextResource) object; return StringUtils.isNotBlank(contextResource.getConfigRef()); } }); // get config resource path for each context resource, filter out items where not reference could be resolved final Iterator<String> configPaths = new TransformIterator(contextResources, new Transformer() { @Override public Object transform(Object input) { final ContextResource contextResource = (ContextResource) input; String val = checkPath(contextResource, contextResource.getConfigRef(), bucketNames); if (val != null) { log.trace("+ Found reference for context path {}: {}", contextResource.getResource().getPath(), val); } return val; } }); return new FilterIterator(configPaths, PredicateUtils.notNullPredicate()); }