本文整理汇总了Java中org.apache.commons.collections4.IterableUtils类的典型用法代码示例。如果您正苦于以下问题:Java IterableUtils类的具体用法?Java IterableUtils怎么用?Java IterableUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IterableUtils类属于org.apache.commons.collections4包,在下文中一共展示了IterableUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeAll
import org.apache.commons.collections4.IterableUtils; //导入依赖的package包/类
@Override
public void removeAll(Collection<byte[]> removing) {
awaitInit();
Set<Long> removed = new HashSet<>();
for(final Map.Entry<Long, byte[]> e : hashes.entrySet()) {
byte[] hash = IterableUtils.find(removing, hash1 -> FastByteComparisons.compareTo(hash1, 0, 32, e.getValue(), 0, 32) == 0);
if(hash != null) {
removed.add(e.getKey());
}
}
index.removeAll(removed);
for(Long idx : removed) {
hashes.remove(idx);
}
dbCommit();
}
示例2: getObjectName
import org.apache.commons.collections4.IterableUtils; //导入依赖的package包/类
protected static ObjectName getObjectName(final MBeanServerConnection connection, final String remoteContext,
final Class objectClass) throws IOException {
Set<ObjectName> names = connection.queryNames(null, null);
return IterableUtils.find(names, o -> {
if (!Objects.equals(remoteContext, o.getDomain())) {
return false;
}
MBeanInfo info;
try {
info = connection.getMBeanInfo(o);
} catch (Exception e) {
throw new JmxControlException(e);
}
return Objects.equals(objectClass.getName(), info.getClassName());
});
}
示例3: findLastByFacilityStatesUpdatedSince
import org.apache.commons.collections4.IterableUtils; //导入依赖的package包/类
@Override
public Iterable<FacilityStateSnapshot> findLastByFacilityStatesUpdatedSince(Iterable<FacilityState> facilityStates,
long timestamp) {
final Set<FacilityState> states = new TreeSet<>(IterableUtils.toList(facilityStates));
final List<FacilityStateSnapshot> snapshots = new LinkedList<>();
synchronized (facilityStateSnapshots) {
for (Entry<Long, Collection<FacilityStateSnapshot>> entry : facilityStateSnapshots.asMap().entrySet()) {
final Iterator<FacilityStateSnapshot> iterator = entry.getValue().iterator();
if (iterator.hasNext()) {
final FacilityStateSnapshot snapshot = iterator.next();
if (states.contains(snapshot.getState()) && snapshot.getTimestamp() > timestamp) {
snapshots.add(snapshot);
}
}
}
}
return snapshots;
}
示例4: createBusinessObjectDefinitionColumnFromEntity
import org.apache.commons.collections4.IterableUtils; //导入依赖的package包/类
/**
* Creates a business object definition column from the persisted entity.
*
* @param businessObjectDefinitionColumnEntity the business object definition column entity
* @param includeId boolean value indicating whether or not to include the id
* @param fields set of field parameters to include on the business object definition column
*
* @return the business object definition column
*/
private BusinessObjectDefinitionColumn createBusinessObjectDefinitionColumnFromEntity(
BusinessObjectDefinitionColumnEntity businessObjectDefinitionColumnEntity, boolean includeId, Set<String> fields)
{
BusinessObjectDefinitionColumn businessObjectDefinitionColumn = new BusinessObjectDefinitionColumn();
if (includeId)
{
businessObjectDefinitionColumn.setId(businessObjectDefinitionColumnEntity.getId());
}
businessObjectDefinitionColumn.setBusinessObjectDefinitionColumnKey(getBusinessObjectDefinitionColumnKey(businessObjectDefinitionColumnEntity));
if (fields.contains(DESCRIPTION_FIELD))
{
businessObjectDefinitionColumn.setDescription(businessObjectDefinitionColumnEntity.getDescription());
}
if (fields.contains(SCHEMA_COLUMN_NAME_FIELD) && CollectionUtils.isNotEmpty(businessObjectDefinitionColumnEntity.getSchemaColumns()))
{
businessObjectDefinitionColumn.setSchemaColumnName(IterableUtils.get(businessObjectDefinitionColumnEntity.getSchemaColumns(), 0).getName());
}
return businessObjectDefinitionColumn;
}
示例5: testUpdateBusinessObjectDataAttributesAttributeAdded
import org.apache.commons.collections4.IterableUtils; //导入依赖的package包/类
@Test
public void testUpdateBusinessObjectDataAttributesAttributeAdded()
{
// Create a list of attributes.
List<Attribute> attributes = Arrays.asList(new Attribute(ATTRIBUTE_NAME, ATTRIBUTE_VALUE));
// Create a business object data entity without attributes.
BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity();
businessObjectDataEntity.setAttributes(new ArrayList<>());
// Call the method under test.
attributeDaoHelper.updateBusinessObjectDataAttributes(businessObjectDataEntity, attributes);
// Verify the external calls.
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(1, CollectionUtils.size(businessObjectDataEntity.getAttributes()));
BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = IterableUtils.get(businessObjectDataEntity.getAttributes(), 0);
assertEquals(businessObjectDataEntity, businessObjectDataAttributeEntity.getBusinessObjectData());
assertEquals(ATTRIBUTE_NAME, businessObjectDataAttributeEntity.getName());
assertEquals(ATTRIBUTE_VALUE, businessObjectDataAttributeEntity.getValue());
}
示例6: testUpdateBusinessObjectDataAttributesAttributeValueNotUpdated
import org.apache.commons.collections4.IterableUtils; //导入依赖的package包/类
@Test
public void testUpdateBusinessObjectDataAttributesAttributeValueNotUpdated()
{
// Create a business object data attribute entity.
BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = new BusinessObjectDataAttributeEntity();
businessObjectDataAttributeEntity.setName(ATTRIBUTE_NAME);
businessObjectDataAttributeEntity.setValue(ATTRIBUTE_VALUE);
// Create a business object data entity that contains one attribute entity.
BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity();
List<BusinessObjectDataAttributeEntity> businessObjectDataAttributeEntities = new ArrayList<>();
businessObjectDataEntity.setAttributes(businessObjectDataAttributeEntities);
businessObjectDataAttributeEntities.add(businessObjectDataAttributeEntity);
// Call the method under test.
attributeDaoHelper.updateBusinessObjectDataAttributes(businessObjectDataEntity, Arrays.asList(new Attribute(ATTRIBUTE_NAME, ATTRIBUTE_VALUE)));
// Verify the external calls.
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(1, CollectionUtils.size(businessObjectDataEntity.getAttributes()));
BusinessObjectDataAttributeEntity result = IterableUtils.get(businessObjectDataEntity.getAttributes(), 0);
assertEquals(ATTRIBUTE_NAME, result.getName());
assertEquals(ATTRIBUTE_VALUE, result.getValue());
}
示例7: testUpdateBusinessObjectDataAttributesAttributeValueUpdated
import org.apache.commons.collections4.IterableUtils; //导入依赖的package包/类
@Test
public void testUpdateBusinessObjectDataAttributesAttributeValueUpdated()
{
// Create a business object data attribute entity.
BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = new BusinessObjectDataAttributeEntity();
businessObjectDataAttributeEntity.setName(ATTRIBUTE_NAME);
businessObjectDataAttributeEntity.setValue(ATTRIBUTE_VALUE);
// Create a business object data entity that contains one attribute entity.
BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity();
List<BusinessObjectDataAttributeEntity> businessObjectDataAttributeEntities = new ArrayList<>();
businessObjectDataEntity.setAttributes(businessObjectDataAttributeEntities);
businessObjectDataAttributeEntities.add(businessObjectDataAttributeEntity);
// Call the method under test.
attributeDaoHelper.updateBusinessObjectDataAttributes(businessObjectDataEntity, Arrays.asList(new Attribute(ATTRIBUTE_NAME, ATTRIBUTE_VALUE_2)));
// Verify the external calls.
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(1, CollectionUtils.size(businessObjectDataEntity.getAttributes()));
BusinessObjectDataAttributeEntity result = IterableUtils.get(businessObjectDataEntity.getAttributes(), 0);
assertEquals(ATTRIBUTE_NAME, result.getName());
assertEquals(ATTRIBUTE_VALUE_2, result.getValue());
}
示例8: updateInputFileStatus
import org.apache.commons.collections4.IterableUtils; //导入依赖的package包/类
/**
* Update the state of input files.
* Change the state value for the input file specified. If the name is not
associated with any input file nothing happen.
<p>
There is not check on the file existence and real state which
is delegated to the caller object.
*
* @param name File name
* @param aStatus New state
*/
public final void updateInputFileStatus(
final String name, final TaskFile.FILESTATUS aStatus) {
TaskFileInput tfi = IterableUtils.find(inputFiles,
new Predicate<TaskFileInput>() {
@Override
public boolean evaluate(final TaskFileInput t) {
return t.getName().equals(name);
}
});
if (tfi != null) {
tfi.setStatus(aStatus);
lastChange = new Date();
setChanged();
notifyObservers();
}
}
示例9: add_infra_should_create_a_new_infra
import org.apache.commons.collections4.IterableUtils; //导入依赖的package包/类
@Before
public void add_infra_should_create_a_new_infra() {
Infrastructure infra = new Infrastructure();
infra.setDescription("Test description");
infra.setGroup("group");
HttpEntity<InfrastructureResource> resp = this.infrastructureController.addInfrastructure(infra);
Assert.assertNotNull(resp);
Assert.assertNotNull(resp.getBody());
InfrastructureResource infraReturned = resp.getBody();
Assert.assertNotNull(infraReturned);
Assert.assertNotNull(infraReturned.getId());
Assert.assertEquals(infra.getDescription(), infraReturned.getDescription());
Assert.assertEquals(infra.getCrm(), infraReturned.getCrm());
Assert.assertEquals(infra.getGroup(), infraReturned.getGroup());
infraId = infraReturned.getInfraId();
List<InfrastructureResource> infras = IterableUtils.toList(this.infrastructureController.getInfrastructures(null, null, new PagedResourcesAssembler<Infrastructure>(resolver, null)));
Assert.assertNotNull(infras);
Assert.assertEquals(1, infras.size());
}
示例10: add_zone_should_create_a_new_zone
import org.apache.commons.collections4.IterableUtils; //导入依赖的package包/类
@Test
public void add_zone_should_create_a_new_zone() {
Zone zone = new Zone();
zone.setDescription("Test description");
zone.setInfraId(infraId);
zone.setIp(0xC0A80001L);
HttpEntity<ZoneResource> resp = this.controller.addZone(infraId, zone);
Assert.assertNotNull(resp);
Assert.assertNotNull(resp.getBody());
ZoneResource zoneReturned = resp.getBody();
Assert.assertNotNull(zoneReturned);
Assert.assertNotNull(zoneReturned.getId());
Assert.assertEquals(zone.getDescription(), zoneReturned.getDescription());
Assert.assertEquals(zone.getInfraId(), zoneReturned.getInfraId());
Assert.assertEquals(zone.getIp(), zoneReturned.getIp());
Assert.assertEquals(3, zoneReturned.getLinks().size());
id = zoneReturned.getZoneId();
List<ZoneResource> zones = IterableUtils.toList(this.controller.getZones(infraId, null, new PagedResourcesAssembler<Zone>(resolver, null)));
Assert.assertNotNull(zones);
Assert.assertEquals(1, zones.size());
}
示例11: testUpdateWithGHZ5AndUS
import org.apache.commons.collections4.IterableUtils; //导入依赖的package包/类
@Test
public void testUpdateWithGHZ5AndUS() throws Exception {
// setup
int colorSelected = ContextCompat.getColor(mainActivity, R.color.connected);
int colorNotSelected = ContextCompat.getColor(mainActivity, R.color.connected_background);
Pair<WiFiChannel, WiFiChannel> selectedKey = WiFiBand.GHZ5.getWiFiChannels().getWiFiChannelPairs().get(0);
when(configuration.getWiFiChannelPair()).thenReturn(selectedKey);
when(settings.getCountryCode()).thenReturn(Locale.US.getCountry());
when(settings.getWiFiBand()).thenReturn(WiFiBand.GHZ5);
when(settings.getSortBy()).thenReturn(SortBy.CHANNEL);
// execute
fixture.update(WiFiData.EMPTY);
// validate
verify(layout).setVisibility(View.VISIBLE);
IterableUtils.forEach(views.keySet(), new PairUpdateClosure(selectedKey, colorSelected, colorNotSelected));
IterableUtils.forEach(ChannelGraphNavigation.ids.values(), new IntegerUpdateClosure());
verify(settings).getCountryCode();
verify(settings, times(2)).getWiFiBand();
verify(settings).getSortBy();
verify(configuration).getWiFiChannelPair();
}
示例12: add_range_should_create_a_new_range
import org.apache.commons.collections4.IterableUtils; //导入依赖的package包/类
@Test
public void add_range_should_create_a_new_range() {
Range range = new Range();
range.setDescription("Test description");
range.setInfraId(infraId);
range.setZoneId(zoneId);
range.setSize(65536L);
range.setIp(0xC0A80000L);
HttpEntity<RangeResource> resp = this.controller.addRange(infraId, zoneId, range);
Assert.assertNotNull(resp);
Assert.assertNotNull(resp.getBody());
RangeResource rangeReturned = resp.getBody();
Assert.assertNotNull(rangeReturned);
Assert.assertNotNull(rangeReturned.getId());
Assert.assertEquals(range.getDescription(), rangeReturned.getDescription());
Assert.assertEquals(range.getInfraId(), rangeReturned.getInfraId());
Assert.assertEquals(range.getZoneId(), rangeReturned.getZoneId());
Assert.assertEquals(range.getIp(), rangeReturned.getIp());
Assert.assertEquals(range.getSize(), rangeReturned.getSize());
Assert.assertEquals(4, rangeReturned.getLinks().size());
id = rangeReturned.getRangeId();
List<RangeResource> ranges = IterableUtils.toList(this.controller.getRanges(infraId, zoneId, null, new PagedResourcesAssembler<Range>(resolver, null)));
Assert.assertNotNull(ranges);
Assert.assertEquals(1, ranges.size());
}
示例13: z3_delete_zone_should_work
import org.apache.commons.collections4.IterableUtils; //导入依赖的package包/类
@After
public void z3_delete_zone_should_work() {
this.repository.deleteAll();
this.subnetController.deleteSubnet(infraId, subnetId, null);
this.zoneController.deleteZone(infraId, zoneId);
List<ZoneResource> zones = IterableUtils.toList(this.zoneController.getZones(infraId, null, new PagedResourcesAssembler<Zone>(resolver, null)));
Assert.assertNotNull(zones);
Assert.assertEquals(0, zones.size());
this.infrastructureController.deleteInfrastructure(infraId);
List<InfrastructureResource> infras = IterableUtils.toList(this.infrastructureController.getInfrastructures(null, null, new PagedResourcesAssembler<Infrastructure>(resolver, null)));
Assert.assertNotNull(infras);
Assert.assertEquals(0, infras.size());
}
示例14: add_infra_should_create_a_new_infra
import org.apache.commons.collections4.IterableUtils; //导入依赖的package包/类
@Test
public void add_infra_should_create_a_new_infra() {
Infrastructure infra = new Infrastructure();
infra.setDescription("Test description");
infra.setGroup("group");
HttpEntity<InfrastructureResource> resp = this.controller.addInfrastructure(infra);
Assert.assertNotNull(resp);
Assert.assertNotNull(resp.getBody());
InfrastructureResource infraReturned = resp.getBody();
Assert.assertNotNull(infraReturned);
Assert.assertNotNull(infraReturned.getId());
Assert.assertEquals(infra.getDescription(), infraReturned.getDescription());
Assert.assertEquals(infra.getCrm(), infraReturned.getCrm());
Assert.assertEquals(infra.getGroup(), infraReturned.getGroup());
Assert.assertEquals(3, infraReturned.getLinks().size());
id = infraReturned.getInfraId();
List<InfrastructureResource> infras = IterableUtils.toList(this.controller.getInfrastructures(null, null, new PagedResourcesAssembler<Infrastructure>(resolver, null)));
Assert.assertNotNull(infras);
Assert.assertEquals(1, infras.size());
}
示例15: add_infra_twice_should_create_a_new_infra
import org.apache.commons.collections4.IterableUtils; //导入依赖的package包/类
@Test
public void add_infra_twice_should_create_a_new_infra() {
add_infra_should_create_a_new_infra();
Infrastructure infra = new Infrastructure();
infra.setDescription("Test description 3");
infra.setGroup("group2");
HttpEntity<InfrastructureResource> response = this.controller.addInfrastructure(infra);
Assert.assertNotNull(response);
Assert.assertNotNull(response.getBody());
InfrastructureResource infraReturned = response.getBody();
Assert.assertNotNull(infraReturned);
Assert.assertNotNull(infraReturned.getId());
Assert.assertEquals(infra.getDescription(), infraReturned.getDescription());
Assert.assertEquals(infra.getCrm(), infraReturned.getCrm());
Assert.assertEquals(infra.getGroup(), infraReturned.getGroup());
Assert.assertEquals(3, infraReturned.getLinks().size());
id2 = infraReturned.getInfraId();
List<InfrastructureResource> infras = IterableUtils.toList(this.controller.getInfrastructures(null, null, new PagedResourcesAssembler<Infrastructure>(resolver, null)));
Assert.assertNotNull(infras);
Assert.assertEquals(2, infras.size());
}