本文整理汇总了Java中org.apache.commons.collections4.IterableUtils.find方法的典型用法代码示例。如果您正苦于以下问题:Java IterableUtils.find方法的具体用法?Java IterableUtils.find怎么用?Java IterableUtils.find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.collections4.IterableUtils
的用法示例。
在下文中一共展示了IterableUtils.find方法的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: 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();
}
}
示例4: updateOutputFile
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
* @param url Url to retrieve the file. If null the download is managed by
* the task service so the url will be under the the task resource url.
*/
public final void updateOutputFile(
final String name, final TaskFile.FILESTATUS aStatus,
final String url) {
TaskFileOutput tfo = IterableUtils.find(outputFiles,
new Predicate<TaskFileOutput>() {
@Override
public boolean evaluate(final TaskFileOutput t) {
return t.getName().equals(name);
}
});
if (tfo != null) {
tfo.setStatus(aStatus);
tfo.setUrl(url);
lastChange = new Date();
setChanged();
notifyObservers();
}
}
示例5: findField
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
public Value findField(final String fieldName){
Value value;
value = IterableUtils.find(this, new Predicate<Value>() {
@Override
public boolean evaluate(Value object) {
return object.getMetadata().getName().equals(fieldName);
}
});
return value;
}
示例6: getPermissionVariant
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
public AttributePermissionVariant getPermissionVariant(final String attribute) {
AttributeTarget attrTarget = IterableUtils.find(getPermissions(),
object -> object != null && attribute.equals(object.getId()));
if (attrTarget != null)
return attrTarget.getPermissionVariant();
else
return null;
}
示例7: assignPermissionVariant
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
public void assignPermissionVariant(final String attribute, AttributePermissionVariant permissionVariant) {
AttributeTarget attrTarget = IterableUtils.find(getPermissions(),
object -> object != null && attribute.equals(object.getId()));
if (attrTarget != null) {
attrTarget.setPermissionVariant(permissionVariant);
}
}
示例8: addDynamicAttributes
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
protected void addDynamicAttributes(Table component, Datasource ds, List<Table.Column> availableColumns) {
if (metadataTools.isPersistent(ds.getMetaClass())) {
Set<CategoryAttribute> attributesToShow =
dynamicAttributesGuiTools.getAttributesToShowOnTheScreen(ds.getMetaClass(), context.getFullFrameId(), component.getId());
if (CollectionUtils.isNotEmpty(attributesToShow)) {
ds.setLoadDynamicAttributes(true);
for (CategoryAttribute attribute : attributesToShow) {
final MetaPropertyPath metaPropertyPath = DynamicAttributesUtils.getMetaPropertyPath(ds.getMetaClass(), attribute);
Object columnWithSameId = IterableUtils.find(availableColumns,
o -> o.getId().equals(metaPropertyPath));
if (columnWithSameId != null) {
continue;
}
final Table.Column column = new Table.Column(metaPropertyPath);
column.setCaption(LocaleHelper.isLocalizedValueDefined(attribute.getLocaleNames()) ?
attribute.getLocaleName() :
StringUtils.capitalize(attribute.getName()));
if (attribute.getDataType().equals(PropertyType.STRING)) {
column.setMaxTextLength(clientConfig.getDynamicAttributesTableColumnMaxTextLength());
}
if (attribute.getDataType().equals(PropertyType.ENUMERATION)) {
column.setFormatter(value ->
LocaleHelper.getEnumLocalizedValue((String) value, attribute.getEnumerationLocales())
);
}
component.addColumn(column);
}
}
dynamicAttributesGuiTools.listenDynamicAttributesChanges(ds);
}
}
示例9: getAssociatedInfrastructure
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
/**
* Retrieves the associated infrastructure Id.
* This is the infrastructure selected to execute the task among
* the many the application can run on.
*
* @return The infrastructure
*/
@Transient
public Infrastructure getAssociatedInfrastructure() {
if (applicationDetail == null) {
return null;
}
return IterableUtils.find(
applicationDetail.getInfrastructures(),
new Predicate<Infrastructure>() {
@Override
public boolean evaluate(final Infrastructure t) {
return t.getId().equals(getAssociatedInfrastructureId());
}
});
}
示例10: getParameterValue
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
/**
* Retrieves the parameter value from a list.
* If the parameter has multiple definition, and so multiple values, the
* first occurrence is returned.
*
* @param params The parameter list
* @param name Parameter name
* @param defaultValue Default value if the parameter is not defined
* @return Parameter value or null is not present
*/
public static String getParameterValue(final List<Params> params,
final String name, final String defaultValue) {
Params tmpParam = IterableUtils.find(
params, new Predicate<Params>() {
@Override
public boolean evaluate(final Params t) {
return t.getName().equals(name);
}
});
if (tmpParam != null) {
return tmpParam.getValue();
}
return defaultValue;
}
示例11: getWiFiChannelPairFirst
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
@Override
public Pair<WiFiChannel, WiFiChannel> getWiFiChannelPairFirst(String countryCode) {
Pair<WiFiChannel, WiFiChannel> found = null;
if (StringUtils.isNotBlank(countryCode)) {
found = IterableUtils.find(getWiFiChannelPairs(), new WiFiChannelPredicate(countryCode));
}
return found == null ? SET1 : found;
}
示例12: getWiFiChannelByFrequency
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
public WiFiChannel getWiFiChannelByFrequency(int frequency) {
Pair<WiFiChannel, WiFiChannel> found = null;
if (isInRange(frequency)) {
found = IterableUtils.find(wiFiChannelPairs, new FrequencyPredicate(frequency));
}
return found == null ? WiFiChannel.UNKNOWN : getWiFiChannel(frequency, found);
}
示例13: syncDatabase
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
public void syncDatabase(final DatabaseReader reader, DatabaseCounter counter, long lastSyncTimestamp, long currentSyncTimestamp) throws IOException {
Database dbCurrentDatabase;
Table dbCurrentTable;
Record dbCurrentRecord;
TableToSync currentTableToSync = null;
Map<String, ValueMetadata> columns = null;
String joinColumnName;
ValueMetadata joinColumnMetadata;
int elementType;
Log.i(TAG, "start syncDatabase");
// TODO check database name
try {
// Open the TX
mDB.beginTransaction();
while ((elementType = reader.nextElement()) != JSonDatabaseReader.END) {
switch (elementType) {
case JSonDatabaseReader.START_DB:
dbCurrentDatabase = reader.readDatabase();
// Check schema version
if (dbCurrentDatabase.getSchemaVersion() > mSchemaVersion) {
throw new SyncException(SyncStatus.Code.ERROR_NEW_SCHEMA_VERSION, "Find new schema version, need to update (found:" + dbCurrentDatabase.getSchemaVersion() + ", expected:" + mSchemaVersion + ")");
}
break;
case JSonDatabaseReader.START_TABLE:
// Read the table and column metadata
dbCurrentTable = reader.readTable();
// Find the table to sync definition and rules
final String tableName = dbCurrentTable.getName();
currentTableToSync = IterableUtils.find(mTableToSync, new Predicate<TableToSync>() {
@Override
public boolean evaluate(TableToSync object) {
return object.getName().equals(tableName);
}
});
if (currentTableToSync == null) {
throw new SyncException(SyncStatus.Code.ERROR_SYNC_COULD_DB, "Unable to find table " + tableName + " into table definition");
}
columns = SqlLiteUtility.readTableMetadataAsMap(mDB, dbCurrentTable.getName());
// Add the records columns for join tables
for (JoinTable joinTable : currentTableToSync.getJoinTable()) {
joinColumnName = JOIN_COLUMN_PREFIX + joinTable.getJoinColumn();
joinColumnMetadata = new ValueMetadata(joinColumnName.toUpperCase(), ValueMetadata.TYPE_STRING);
columns.put(joinColumnName, joinColumnMetadata);
}
break;
case JSonDatabaseReader.RECORD:
dbCurrentRecord = reader.readRecord(columns);
// Found record sync single record
if (!dbCurrentRecord.isEmpty()) {
syncRecord(currentTableToSync, dbCurrentRecord, counter, lastSyncTimestamp, currentSyncTimestamp);
}
break;
}
}
// Commit the TX
mDB.setTransactionSuccessful();
} catch (Exception e) {
throw e;
} finally {
mDB.endTransaction();
}
Log.i(TAG, "end syncDatabase tables: " + counter.getTableSyncedCount() + " recUpdated:" + counter.getRecordUpdated() + " recInserted:" + counter.getRecordInserted());
}
示例14: find
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
WiFiDetail find(@NonNull Series series) {
return IterableUtils.find(cache.keySet(), new FindPredicate(series));
}
示例15: findColor
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
private GraphColor findColor(long primaryColor) {
return IterableUtils.find(getAvailableGraphColors(), new ColorPredicate(primaryColor));
}