本文整理了Java中org.apache.commons.collections4.CollectionUtils.size()
方法的一些代码示例,展示了CollectionUtils.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CollectionUtils.size()
方法的具体详情如下:
包路径:org.apache.commons.collections4.CollectionUtils
类名称:CollectionUtils
方法名:size
[英]Gets the size of the collection/iterator specified.
This method can handles objects as follows
代码示例来源:origin: org.apache.commons/commons-collections4
/**
* Gets the total size of the map by counting all the values.
*
* @return the total size of the map counting all values
*/
public int totalSize() {
int total = 0;
for (final Object v : decorated().values()) {
total += CollectionUtils.size(v);
}
return total;
}
代码示例来源:origin: ethereum/ethereumj
public InternalTransaction addInternalTransaction(byte[] parentHash, int deep, byte[] nonce, DataWord gasPrice, DataWord gasLimit,
byte[] senderAddress, byte[] receiveAddress, byte[] value, byte[] data, String note) {
InternalTransaction transaction = new InternalTransaction(parentHash, deep, size(internalTransactions), nonce, gasPrice, gasLimit, senderAddress, receiveAddress, value, data, note);
getInternalTransactions().add(transaction);
return transaction;
}
代码示例来源:origin: ethereum/ethereumj
private static void assertLogInfoEquals(LogInfo expected, LogInfo actual) {
assertNotNull(expected);
assertNotNull(actual);
assertArrayEquals(expected.getAddress(), actual.getAddress());
assertEquals(size(expected.getTopics()), size(actual.getTopics()));
for (int i = 0; i < size(expected.getTopics()); i++) {
assertArrayEquals(expected.getTopics().get(i).getData(), actual.getTopics().get(i).getData());
}
assertArrayEquals(expected.getData(), actual.getData());
}
代码示例来源:origin: ethereum/ethereumj
assertArrayEquals(tx.getHash(), summary.getTransactionHash());
assertEquals(size(deleteAccounts), size(summary.getDeletedAccounts()));
for (DataWord account : summary.getDeletedAccounts()) {
assertTrue(deleteAccounts.contains(account));
assertEquals(size(logs), size(summary.getLogs()));
for (int i = 0; i < logs.size(); i++) {
assertLogInfoEquals(logs.get(i), summary.getLogs().get(i));
assertEquals(gasUsed, summary.getGasUsed());
assertEquals(nestedLevelCount * countByLevel, size(internalTransactions));
代码示例来源:origin: apache/metron
/**
* Flushes all expired profiles.
*
* <p>If a profile has not received a message for an extended period of time then it is
* marked as expired. Periodically we need to flush these expired profiles to ensure
* that their state is not lost.
*/
protected void flushExpired() {
List<ProfileMeasurement> measurements = null;
try {
// flush the expired profiles
synchronized (messageDistributor) {
measurements = messageDistributor.flushExpired();
emitMeasurements(measurements);
}
} catch(Throwable t) {
// need to catch the exception, otherwise subsequent executions would be suppressed.
// see java.util.concurrent.ScheduledExecutorService#scheduleAtFixedRate
LOG.error("Failed to flush expired profiles", t);
}
LOG.debug("Flushed expired profiles and found {} measurement(s).", CollectionUtils.size(measurements));
}
代码示例来源:origin: apache/metron
/**
* Render a view of the {@link RecordMetadata} that resulted from writing
* messages to Kafka.
*
* @param records The record metadata.
* @param properties The properties.
* @return
*/
private Object render(List<RecordMetadata> records, Properties properties) {
Object view;
if(MESSAGE_VIEW_RICH.equals(getMessageView(properties))) {
// build a 'rich' view of the messages that were written
List<Object> responses = new ArrayList<>();
for(RecordMetadata record: records) {
// render the 'rich' view of the record
Map<String, Object> richView = new HashMap<>();
richView.put("topic", record.topic());
richView.put("partition", record.partition());
richView.put("offset", record.offset());
richView.put("timestamp", record.timestamp());
responses.add(richView);
}
// the rich view is a list of maps containing metadata about how each message was written
view = responses;
} else {
// otherwise, the view is simply a count of the number of messages written
view = CollectionUtils.size(records);
}
return view;
}
代码示例来源:origin: esig/dss
@Override
@SuppressWarnings("rawtypes")
public int collectionSize(Collection collection) {
return CollectionUtils.size(collection);
}
代码示例来源:origin: org.jboss.windup.rules.apps/windup-rules-java-api
@Override
public String toString()
{
return "Pom{" + role + " " + coord + ", parent=" + (parent == null ? "" : parent.coord) + ", " + "name=" + name
+ /* ", desc=" + description + */ ", " + "dependencies=" + CollectionUtils.size(dependencies) + ", " + "localDependencies="
+ CollectionUtils.size(localDependencies) + ", " + "submodules=" + CollectionUtils.size(submodules) + '}';
}
代码示例来源:origin: windup/windup
@Override
public String toString()
{
return "Pom{" + role + " " + coord + ", parent=" + (parent == null ? "" : parent.coord) + ", " + "name=" + name
+ /* ", desc=" + description + */ ", " + "dependencies=" + CollectionUtils.size(dependencies) + ", " + "localDependencies="
+ CollectionUtils.size(localDependencies) + ", " + "submodules=" + CollectionUtils.size(submodules) + '}';
}
代码示例来源:origin: org.ligoj.bootstrap/bootstrap-business
@Override
@Transactional
public int deleteAllExpected(final Collection<K> identifiers) {
final int deleted = deleteAll(identifiers);
if (deleted != org.apache.commons.collections4.CollectionUtils.size(identifiers)) {
// At least one row has not been deleted
throw new EntityNotFoundException(identifiers.toString());
}
return deleted;
}
代码示例来源:origin: adorsys/xs2a
public SpiPeriodicPaymentInitiationResponse mapToSpiPeriodicPaymentResponse(@NotNull AspspPeriodicPayment payment) {
SpiPeriodicPaymentInitiationResponse spi = new SpiPeriodicPaymentInitiationResponse();
spi.setAspspAccountId(Optional.ofNullable(payment.getDebtorAccount())
.map(AspspAccountReference::getAccountId)
.orElse(null));
spi.setPaymentId(payment.getPaymentId());
spi.setMultilevelScaRequired(CollectionUtils.size(payment.getPsuDataList()) > 1);
if (payment.getPaymentId() == null) {
spi.setTransactionStatus(SpiTransactionStatus.RJCT);
} else {
spi.setTransactionStatus(SpiTransactionStatus.RCVD);
}
return spi;
}
代码示例来源:origin: adorsys/xs2a
public SpiSinglePaymentInitiationResponse mapToSpiSinglePaymentResponse(@NotNull AspspSinglePayment payment) {
SpiSinglePaymentInitiationResponse spi = new SpiSinglePaymentInitiationResponse();
spi.setAspspAccountId(Optional.ofNullable(payment.getDebtorAccount())
.map(AspspAccountReference::getAccountId)
.orElse(null));
spi.setPaymentId(payment.getPaymentId());
spi.setMultilevelScaRequired(CollectionUtils.size(payment.getPsuDataList()) > 1);
if (payment.getPaymentId() == null) {
spi.setTransactionStatus(SpiTransactionStatus.RJCT);
} else {
spi.setTransactionStatus(SpiTransactionStatus.RCVD);
}
return spi;
}
}
代码示例来源:origin: adorsys/xs2a
public SpiBulkPaymentInitiationResponse mapToSpiBulkPaymentResponse(@NotNull AspspBulkPayment payment, String paymentProduct) {
SpiBulkPaymentInitiationResponse spi = new SpiBulkPaymentInitiationResponse();
spi.setAspspAccountId(Optional.ofNullable(payment.getDebtorAccount())
.map(AspspAccountReference::getAccountId)
.orElse(null));
spi.setPayments(mapToListSpiSinglePayments(payment.getPayments(), paymentProduct));
spi.setPaymentId(payment.getPaymentId());
spi.setMultilevelScaRequired(CollectionUtils.size(payment.getPsuDataList()) > 1);
if (payment.getPaymentId() == null) {
spi.setTransactionStatus(SpiTransactionStatus.RJCT);
} else {
spi.setTransactionStatus(SpiTransactionStatus.RCVD);
}
return spi;
}
代码示例来源:origin: FINRAOS/herd
@Test
public void testAddObjectPropertyToContextOnAbstractNotificationMessageBuilder()
{
// Create an empty context map
Map<String, Object> context = new LinkedHashMap<>();
// Create test property values.
Object propertyValue = new Object();
Object jsonEscapedPropertyValue = new Object();
Object xmlEscapedPropertyValue = new Object();
// Call the method under test.
businessObjectDataStatusChangeMessageBuilder
.addObjectPropertyToContext(context, ATTRIBUTE_NAME + SUFFIX_UNESCAPED, propertyValue, jsonEscapedPropertyValue, xmlEscapedPropertyValue);
// Validate the results.
assertEquals(3, CollectionUtils.size(context));
assertEquals(propertyValue, context.get(ATTRIBUTE_NAME + SUFFIX_UNESCAPED));
assertEquals(jsonEscapedPropertyValue, context.get(ATTRIBUTE_NAME + SUFFIX_UNESCAPED + "WithJson"));
assertEquals(xmlEscapedPropertyValue, context.get(ATTRIBUTE_NAME + SUFFIX_UNESCAPED + "WithXml"));
}
代码示例来源:origin: FINRAOS/herd
@Test
public void testAddStringPropertyToContextOnAbstractNotificationMessageBuilder()
{
// Create an empty context map.
Map<String, Object> context = new LinkedHashMap<>();
// Call the method under test.
businessObjectDataStatusChangeMessageBuilder.addStringPropertyToContext(context, ATTRIBUTE_NAME + SUFFIX_UNESCAPED, ATTRIBUTE_VALUE + SUFFIX_UNESCAPED);
// Validate the results.
assertEquals(3, CollectionUtils.size(context));
assertEquals(ATTRIBUTE_VALUE + SUFFIX_UNESCAPED, context.get(ATTRIBUTE_NAME + SUFFIX_UNESCAPED));
assertEquals(ATTRIBUTE_VALUE + SUFFIX_ESCAPED_JSON, context.get(ATTRIBUTE_NAME + SUFFIX_UNESCAPED + "WithJson"));
assertEquals(ATTRIBUTE_VALUE + SUFFIX_ESCAPED_XML, context.get(ATTRIBUTE_NAME + SUFFIX_UNESCAPED + "WithXml"));
}
代码示例来源:origin: FINRAOS/herd
@Test
public void testGetBaseVelocityContextMap()
{
// Call the method under test.
Map<String, Object> result = businessObjectDataStatusChangeMessageBuilder.getBaseVelocityContextMap();
// Validate the results.
assertEquals(14, CollectionUtils.size(result));
}
代码示例来源:origin: Evolveum/midpoint
@SuppressWarnings("unchecked")
private <F extends FocusType> Collection<EvaluatedAssignmentImpl<F>> assertAssignmentTripleSetSize(LensContext<F> context, int zero, int plus, int minus) {
assertEquals("Wrong size of assignment triple zero set", zero, CollectionUtils.size(context.getEvaluatedAssignmentTriple().getZeroSet()));
assertEquals("Wrong size of assignment triple plus set", plus, CollectionUtils.size(context.getEvaluatedAssignmentTriple().getPlusSet()));
assertEquals("Wrong size of assignment triple minus set", minus, CollectionUtils.size(context.getEvaluatedAssignmentTriple().getMinusSet()));
return (Collection) context.getEvaluatedAssignmentTriple().getAllValues();
}
代码示例来源:origin: FINRAOS/herd
@Test
public void testGetMap()
{
// Create objects required for testing.
final String name = STRING_VALUE;
final String value = STRING_VALUE_2;
final Parameter parameter = new Parameter(name, value);
// Call the method under test.
Map<String, String> result = emrDaoImpl.getMap(Arrays.asList(parameter));
// Verify the external calls.
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(1, CollectionUtils.size(result));
assertTrue(result.containsKey(name));
assertEquals(value, result.get(name));
}
代码示例来源:origin: FINRAOS/herd
@Test
public void testSearchBusinessObjectDataPageNum1() throws Exception
{
retentionExpirationExporterWebClient.getRegServerAccessParamsDto().setUseSsl(false);
BusinessObjectDataSearchResult result = retentionExpirationExporterWebClient.searchBusinessObjectData(new BusinessObjectDataSearchRequest(), 1);
assertNotNull(result);
assertEquals(2, CollectionUtils.size(result.getBusinessObjectDataElements()));
}
代码示例来源:origin: FINRAOS/herd
@Test
public void testSearchBusinessObjectDataPageNum2() throws Exception
{
retentionExpirationExporterWebClient.getRegServerAccessParamsDto().setUseSsl(false);
BusinessObjectDataSearchResult result = retentionExpirationExporterWebClient.searchBusinessObjectData(new BusinessObjectDataSearchRequest(), 2);
assertNotNull(result);
assertEquals(0, CollectionUtils.size(result.getBusinessObjectDataElements()));
}
内容来源于网络,如有侵权,请联系作者删除!