当前位置: 首页>>代码示例>>Java>>正文


Java Closure类代码示例

本文整理汇总了Java中org.apache.commons.collections.Closure的典型用法代码示例。如果您正苦于以下问题:Java Closure类的具体用法?Java Closure怎么用?Java Closure使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Closure类属于org.apache.commons.collections包,在下文中一共展示了Closure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getVolumeProductsFromVhds

import org.apache.commons.collections.Closure; //导入依赖的package包/类
private ArrayList<VolumeProduct> getVolumeProductsFromVhds() throws CloudException {
    WAPVhdsModel wapVhdsModel =
            new AzurePackRequester(this.getProvider(), new AzurePackVolumeRequests(this.getProvider()).listVirtualDisks().build()).withJsonProcessor(WAPVhdsModel.class).execute();

    final ArrayList<VolumeProduct> volumes = new ArrayList<>();
    CollectionUtils.forAllDo(wapVhdsModel.getVhds(), new Closure() {
        @Override
        public void execute(Object input) {
            WAPVhdModel wapVhdModel = (WAPVhdModel)input;
            if(wapVhdModel.getOperatingSystem().equalsIgnoreCase("none")) {
                volumes.add(VolumeProduct.getInstance(wapVhdModel.getId(), wapVhdModel.getName(),
                        wapVhdModel.getName(),
                        VolumeType.HDD,
                        new Storage<Megabyte>(Integer.parseInt(wapVhdModel.getSize()), Storage.MEGABYTE)));
            }
        }
    });
    return volumes;
}
 
开发者ID:dasein-cloud,项目名称:dasein-cloud-azurepack,代码行数:20,代码来源:AzurePackVolumeSupport.java

示例2: getVolumesFromVMs

import org.apache.commons.collections.Closure; //导入依赖的package包/类
private ArrayList<Volume> getVolumesFromVMs() throws CloudException {
    WAPVirtualMachinesModel virtualMachinesModel =
            new AzurePackRequester(this.getProvider(), new AzurePackVolumeRequests(this.getProvider()).listVMsWithVDD().build())
                    .withJsonProcessor(WAPVirtualMachinesModel.class).execute();
    final ArrayList<Volume> volumes = new ArrayList<>();
    CollectionUtils.forAllDo(virtualMachinesModel.getVirtualMachines(), new Closure() {
        @Override
        public void execute(Object input) {
            WAPVirtualMachineModel virtualMachineModel = (WAPVirtualMachineModel)input;
            for (WAPDiskDriveModel wapDiskDriveModel : virtualMachineModel.getVirtualDiskDrives()) {
                volumes.add(volumeFrom(wapDiskDriveModel, virtualMachineModel.getId()));
            }
        }
    });
    return volumes;
}
 
开发者ID:dasein-cloud,项目名称:dasein-cloud-azurepack,代码行数:17,代码来源:AzurePackVolumeSupport.java

示例3: listVlans

import org.apache.commons.collections.Closure; //导入依赖的package包/类
@Override
public @Nonnull Iterable<VLAN> listVlans() throws CloudException, InternalException {
    HttpUriRequest listNetworksRequest = new AzurePackNetworkRequests(provider).listVMNetworks().build();

    return new AzurePackRequester(provider, listNetworksRequest).withJsonProcessor(new DriverToCoreMapper<WAPVMNetworksModel, List<VLAN>>() {
        @Override
        public List<VLAN> mapFrom(WAPVMNetworksModel entity) {
            final ArrayList<VLAN> vlans = new ArrayList<VLAN>();
            CollectionUtils.forAllDo(entity.getVirtualMachineNetworks(), new Closure() {
                @Override
                public void execute(Object input) {
                    vlans.add(vlanFrom((WAPVMNetworkModel) input));
                }
            });

            return vlans;
        }
    }, WAPVMNetworksModel.class).execute();
}
 
开发者ID:dasein-cloud,项目名称:dasein-cloud-azurepack,代码行数:20,代码来源:AzurePackNetworkSupport.java

示例4: listRegions

import org.apache.commons.collections.Closure; //导入依赖的package包/类
@Override
public Collection<Region> listRegions() throws InternalException, CloudException {
    HttpUriRequest httpUriRequest = new AzurePackDataCenterRequests(provider).listClouds().build();

    WAPCloudsModel result = new AzurePackRequester(provider, httpUriRequest).withJsonProcessor(WAPCloudsModel.class).execute();

    final List<Region> regions = new ArrayList<Region>();

    CollectionUtils.forAllDo(result.getClouds(), new Closure() {
        @Override
        public void execute(Object input) {
            WAPCloudModel cloudModel = (WAPCloudModel) input;
            Region region = new Region();
            region.setName(cloudModel.getName());
            region.setProviderRegionId(cloudModel.getId());
            region.setActive(true);
            region.setAvailable(true);
            region.setJurisdiction("US");

            regions.add(region);
        }
    });

    return regions;
}
 
开发者ID:dasein-cloud,项目名称:dasein-cloud-azurepack,代码行数:26,代码来源:AzurePackDataCenterService.java

示例5: assertHttpMethod

import org.apache.commons.collections.Closure; //导入依赖的package包/类
private static void assertHttpMethod(final HttpUriRequest actualHttpRequest, String expectedHttpMethod, String expectedUrl, Header[] expectedHeaders)
{
    assertHttpMethod(actualHttpRequest, expectedHttpMethod, expectedUrl);
    assertNotNull(actualHttpRequest.getAllHeaders());
    CollectionUtils.forAllDo(Arrays.asList(expectedHeaders), new Closure() {
        @Override
        public void execute(Object input) {
            final Header expectedHeader = (Header) input;
            boolean headerExists = CollectionUtils.exists(Arrays.asList(actualHttpRequest.getAllHeaders()), new Predicate() {
                @Override
                public boolean evaluate(Object object) {
                    Header actualHeader = (Header) object;
                    return expectedHeader.getName().equals(actualHeader.getName()) && expectedHeader.getValue().equals(actualHeader.getValue());
                }
            });
            assertTrue(String.format("Expected %s header not found in the request or found with the wrong value in the request", expectedHeader.getName()), headerExists);
        }
    });
}
 
开发者ID:dasein-cloud,项目名称:dasein-cloud-azurepack,代码行数:20,代码来源:HttpMethodAsserts.java

示例6: findProvider_shouldReturnTheListOfProvidersMatchingTheSearchName

import org.apache.commons.collections.Closure; //导入依赖的package包/类
/**
 * @see DWRProviderService#findProvider(String,boolean,Integer,Integer)
 * @verifies return the list of providers matching the search name
 */
@Test
public void findProvider_shouldReturnTheListOfProvidersMatchingTheSearchName() throws Exception {
	
	Vector<Object> providers = service.findProvider("provider", false, 0, 10);
	Assert.assertEquals(2, providers.size());
	
	final ArrayList<String> providerNames = new ArrayList<String>();
	
	CollectionUtils.forAllDo(providers, new Closure() {
		
		@Override
		public void execute(Object input) {
			providerNames.add(((ProviderListItem) input).getDisplayName());
		}
	});
	
	Assert.assertTrue(providerNames.containsAll(Arrays.asList("Bruno Otterbourg", "Hippocrates of Cos")));
}
 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:23,代码来源:DWRProviderServiceTest.java

示例7: testGetNames

import org.apache.commons.collections.Closure; //导入依赖的package包/类
@Test
public void testGetNames() throws Exception {
    final InputStream is = getClass().getResourceAsStream(personalXsd);
    assertNotNull(is);

    final StreamSource source = new StreamSource(is);
    final XmlSchema schema = new XmlSchemaCollection().read(source);
    assertNotNull(schema);

    final Collection<QName> elements = SchemaUtil.getElements(schema);
    assertNotNull(elements);
    assertFalse(elements.isEmpty());

    System.out.println("Got the following elements from schema:");
    CollectionUtils.forAllDo(elements, new Closure() {
        @Override
        public void execute(Object input) {
            System.out.println(input);
        }
    });

}
 
开发者ID:mkris,项目名称:xsd2xml,代码行数:23,代码来源:SchemaUtilTest.java

示例8: onConfigChange

import org.apache.commons.collections.Closure; //导入依赖的package包/类
public void onConfigChange(CruiseConfig newCruiseConfig) {
    LOGGER.info("[Configuration Changed] Removing jobs for pipelines that no longer exist in configuration.");
    synchronized (this) {
        List<JobPlan> jobsToRemove = new ArrayList<>();
        for (JobPlan jobPlan : jobPlans) {
            if (!newCruiseConfig.hasBuildPlan(new CaseInsensitiveString(jobPlan.getPipelineName()), new CaseInsensitiveString(jobPlan.getStageName()), jobPlan.getName(), true)) {
                jobsToRemove.add(jobPlan);
            }
        }
        forAllDo(jobsToRemove, new Closure() {
            @Override
            public void execute(Object o) {
                removeJob((JobPlan) o);
            }
        });
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:18,代码来源:BuildAssignmentService.java

示例9: indexCollection

import org.apache.commons.collections.Closure; //导入依赖的package包/类
/**
 * Indexes a collection by creating a map that allows each element of the
 * specified collection to be looked up by its key. The key of each element is
 * determined by calling the <code>makeKey</code> Transformer on that
 * element. I sure miss Lisp.
 *
 * @return a Map
 */
public static <K, E> Map<K,E> indexCollection(Collection c,
                                              final Transformer getKey,
                                              Class<K> keyClass,
                                              Class<E> elementClass)
{
  final Map<K,E> map = new HashMap<K,E>(c.size());
  org.apache.commons.collections.CollectionUtils.forAllDo(c, new Closure() {
    @SuppressWarnings("unchecked")
    public void execute(Object e)
    {
      map.put((K) getKey.transform(e), (E) e);
    }
  });
  return map;
}
 
开发者ID:hmsiccbl,项目名称:screensaver,代码行数:24,代码来源:CollectionUtils.java

示例10: applyForSelectedChanges

import org.apache.commons.collections.Closure; //导入依赖的package包/类
/**
 * Calls the given closure for all changes that are of one of the given types, and
 * then removes them from the changes collection.
 * 
 * @param changes     The changes
 * @param changeTypes The types to search for
 * @param closure     The closure to invoke
 */
protected void applyForSelectedChanges(Collection changes, Class[] changeTypes, final Closure closure)
{
    final Predicate predicate = new MultiInstanceofPredicate(changeTypes);

    // basically we filter the changes for all objects where the above predicate
    // returns true, and for these filtered objects we invoke the given closure
    CollectionUtils.filter(changes,
                           new Predicate()
                           {
                               public boolean evaluate(Object obj)
                               {
                                   if (predicate.evaluate(obj))
                                   {
                                       closure.execute(obj);
                                       return false;
                                   }
                                   else
                                   {
                                       return true;
                                   }
                               }
                           });
}
 
开发者ID:flex-rental-solutions,项目名称:apache-ddlutils,代码行数:32,代码来源:SqlBuilder.java

示例11: setSelectAll

import org.apache.commons.collections.Closure; //导入依赖的package包/类
public void setSelectAll(boolean selectAll) {
    this.selectAll = selectAll;
    if (this.triggerProcessList != null) {
        final boolean isSelectAll = this.isSelectAll();
        CollectionUtils.forAllDo(this.triggerProcessList, new Closure() {
            @Override
            public void execute(Object tp) {
                ((TriggerProcess) tp).setSelected(isSelectAll);
            }
        });
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:13,代码来源:TriggerProcessBean.java

示例12: RepositoryScannerInstance

import org.apache.commons.collections.Closure; //导入依赖的package包/类
public RepositoryScannerInstance( ManagedRepository repository,
                                  List<KnownRepositoryContentConsumer> knownConsumerList,
                                  List<InvalidRepositoryContentConsumer> invalidConsumerList )
{
    this.repository = repository;
    this.knownConsumers = knownConsumerList;
    this.invalidConsumers = invalidConsumerList;

    consumerTimings = new HashMap<>();
    consumerCounts = new HashMap<>();

    this.consumerProcessFile = new ConsumerProcessFileClosure();
    consumerProcessFile.setExecuteOnEntireRepo( true );
    consumerProcessFile.setConsumerTimings( consumerTimings );
    consumerProcessFile.setConsumerCounts( consumerCounts );

    this.consumerWantsFile = new ConsumerWantsFilePredicate( repository );

    stats = new RepositoryScanStatistics();
    stats.setRepositoryId( repository.getId() );

    Closure triggerBeginScan =
        new TriggerBeginScanClosure( repository, new Date( System.currentTimeMillis() ), true );

    CollectionUtils.forAllDo( knownConsumerList, triggerBeginScan );
    CollectionUtils.forAllDo( invalidConsumerList, triggerBeginScan );

    if ( SystemUtils.IS_OS_WINDOWS )
    {
        consumerWantsFile.setCaseSensitive( false );
    }
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:33,代码来源:RepositoryScannerInstance.java

示例13: directoryWalkStep

import org.apache.commons.collections.Closure; //导入依赖的package包/类
@Override
public void directoryWalkStep( int percentage, File file )
{
    log.debug( "Walk Step: {}, {}", percentage, file );

    stats.increaseFileCount();

    // consume files regardless - the predicate will check the timestamp
    BaseFile basefile = new BaseFile( repository.getLocation(), file );

    // Timestamp finished points to the last successful scan, not this current one.
    if ( file.lastModified() >= changesSince )
    {
        stats.increaseNewFileCount();
    }

    consumerProcessFile.setBasefile( basefile );
    consumerWantsFile.setBasefile( basefile );

    Closure processIfWanted = IfClosure.getInstance( consumerWantsFile, consumerProcessFile );
    CollectionUtils.forAllDo( this.knownConsumers, processIfWanted );

    if ( consumerWantsFile.getWantedFileCount() <= 0 )
    {
        // Nothing known processed this file.  It is invalid!
        CollectionUtils.forAllDo( this.invalidConsumers, consumerProcessFile );
    }
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:29,代码来源:RepositoryScannerInstance.java

示例14: up

import org.apache.commons.collections.Closure; //导入依赖的package包/类
private IntakeNode up(IntakeNode node, Closure closure) {
	//if(node == null)
	
	IntakeNode root = node;
	
	while (root.getParent() != null) {
		closure.execute(root);
		root = root.getParent();
	}

	return root;
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:13,代码来源:IntakeNodeWalker.java

示例15: down

import org.apache.commons.collections.Closure; //导入依赖的package包/类
private void down(List<IntakeNode> children, Closure closure) {
	for (IntakeNode child : children) {
		if (child != null) {
			closure.execute(child);
			down(child.getChildren(), closure);
		}
	}
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:9,代码来源:IntakeNodeWalker.java


注:本文中的org.apache.commons.collections.Closure类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。