本文整理匯總了Java中org.apache.commons.collections.ListUtils.union方法的典型用法代碼示例。如果您正苦於以下問題:Java ListUtils.union方法的具體用法?Java ListUtils.union怎麽用?Java ListUtils.union使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.collections.ListUtils
的用法示例。
在下文中一共展示了ListUtils.union方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isValidSchema
import org.apache.commons.collections.ListUtils; //導入方法依賴的package包/類
/**
* check if the schema provided is a valid schema:
* <li>schema is not indicated (only one element in the names list)<li/>
*
* @param names list of schema and table names, table name is always the last element
* @return throws a userexception if the schema is not valid.
*/
private void isValidSchema(final List<String> names) throws UserException {
SchemaPlus defaultSchema = session.getDefaultSchema(this.rootSchema);
String defaultSchemaCombinedPath = SchemaUtilites.getSchemaPath(defaultSchema);
List<String> schemaPath = Util.skipLast(names);
String schemaPathCombined = SchemaUtilites.getSchemaPath(schemaPath);
String commonPrefix = SchemaUtilites.getPrefixSchemaPath(defaultSchemaCombinedPath,
schemaPathCombined,
parserConfig.caseSensitive());
boolean isPrefixDefaultPath = commonPrefix.length() == defaultSchemaCombinedPath.length();
List<String> fullSchemaPath = Strings.isNullOrEmpty(defaultSchemaCombinedPath) ? schemaPath :
isPrefixDefaultPath ? schemaPath : ListUtils.union(SchemaUtilites.getSchemaPathAsList(defaultSchema), schemaPath);
if (names.size() > 1 && (SchemaUtilites.findSchema(this.rootSchema, fullSchemaPath) == null &&
SchemaUtilites.findSchema(this.rootSchema, schemaPath) == null)) {
SchemaUtilites.throwSchemaNotFoundException(defaultSchema, schemaPath);
}
}
示例2: testUpdateScript
import org.apache.commons.collections.ListUtils; //導入方法依賴的package包/類
@Test
public void testUpdateScript() throws Exception {
populateWithTestDocs();
final UpdateScript script = new UpdateScript().setScript("ctx._source.tags += newtag");
script.putToParameters("newtag", "fun");
final UpdateOptions options = new UpdateOptions();
final DocumentIdentifier docId = new DocumentIdentifier(oneaaColumbiaDoc.get_id()).setType(TEST_TYPE);
final IndexResponse result = client.update(docId, script, options, USER_TOKEN);
assertEquals(oneaaColumbiaDoc.get_id(), result.get_id());
final Document updated = client.get(oneaaColumbiaDoc.get_id(), oneaaColumbiaDoc.get_type(), null, USER_TOKEN);
final PlaceOfInterest updatedModel = gson.fromJson(updated.get_jsonObject(), PlaceOfInterest.class);
final List<String> expectedTags =
ListUtils.union(Arrays.asList(oneaaColumbia.getTags()), Collections.singletonList("fun"));
assertArrayEquals(expectedTags.toArray(), updatedModel.getTags());
}
示例3: DefaultTrafficTreatment
import org.apache.commons.collections.ListUtils; //導入方法依賴的package包/類
/**
* Creates a new traffic treatment from the specified list of instructions.
*
* @param deferred deferred instructions
* @param immediate immediate instructions
* @param table table transition instruction
* @param clear instruction to clear the deferred actions list
*/
private DefaultTrafficTreatment(List<Instruction> deferred,
List<Instruction> immediate,
Instructions.TableTypeTransition table,
boolean clear) {
this.immediate = ImmutableList.copyOf(checkNotNull(immediate));
this.deferred = ImmutableList.copyOf(checkNotNull(deferred));
this.all = ListUtils.union(this.immediate, this.deferred);
this.table = table;
this.hasClear = clear;
}
示例4: checkForHiddenSingleRow
import org.apache.commons.collections.ListUtils; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void checkForHiddenSingleRow(int rowNum, int columnNum,
List<Integer> permuteList) {
List<Integer> result = new LinkedList<Integer>();
for (int j = 0; j < Constants.BOARDSIZE; j++) {
if (j == columnNum)
continue;
List<Integer> temp = new LinkedList<Integer>();
if (board[rowNum][j].getCellType() == CellType.VALUE) {
fillList(temp);
checkInRow(rowNum, temp);
checkInColumn(j, temp);
checkInSubGrid(rowNum, j, temp);
result = ListUtils.union(result, temp);
}
}
List<Integer> solution = new LinkedList<Integer>();
solution = ListUtils.subtract(permuteList, result);
if (solution.size() == 1) {
fillValueXY(rowNum, columnNum, solution.get(0),
CellType.PREDETERMINED);
}
}
示例5: checkForHiddenSingleColumn
import org.apache.commons.collections.ListUtils; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void checkForHiddenSingleColumn(int rowNum, int columnNum,
List<Integer> permuteList) {
List<Integer> result = new LinkedList<Integer>();
for (int i = 0; i < Constants.BOARDSIZE; i++) {
if (i == rowNum)
continue;
List<Integer> temp = new LinkedList<Integer>();
if (board[i][columnNum].getCellType() == CellType.VALUE) {
fillList(temp);
checkInRow(i, temp);
checkInColumn(columnNum, temp);
checkInSubGrid(i, columnNum, temp);
result = ListUtils.union(result, temp);
}
}
List<Integer> solution = new LinkedList<Integer>();
solution = ListUtils.subtract(permuteList, result);
if (solution.size() == 1) {
fillValueXY(rowNum, columnNum, solution.get(0),
CellType.PREDETERMINED);
}
}
示例6: discover
import org.apache.commons.collections.ListUtils; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public List<FileMatchMetaData> discover(final Properties dataDiscoveryProperties)
throws AnonymizerException, IOException, SAXException, TikaException {
log.info("Data discovery in process");
// Get the probability threshold from property file
final double probabilityThreshold = parseDouble(dataDiscoveryProperties.getProperty("probability_threshold"));
log.info("Probability threshold [" + probabilityThreshold + "]");
// Get list of models used in data discovery
final String models = dataDiscoveryProperties.getProperty("models");
modelList = models.split(",");
log.info("Model list [" + Arrays.toString(modelList) + "]");
List<FileMatchMetaData> finalList = new ArrayList<>();
for (String model: modelList) {
log.info("********************************");
log.info("Processing model " + model);
log.info("********************************");
final Model modelPerson = createModel(dataDiscoveryProperties, model);
fileMatches = discoverAgainstSingleModel(dataDiscoveryProperties, modelPerson, probabilityThreshold);
finalList = ListUtils.union(finalList, fileMatches);
}
final DecimalFormat decimalFormat = new DecimalFormat("#.##");
log.info("List of suspects:");
log.info(String.format("%20s %20s %20s %20s", "Table*", "Column*", "Probability*", "Model*"));
for(final FileMatchMetaData data: finalList) {
final String probability = decimalFormat.format(data.getAverageProbability());
final String result = String.format("%20s %20s %20s %20s", data.getDirectory(), data.getFileName(), probability, data.getModel());
log.info(result);
}
return Collections.unmodifiableList(fileMatches);
}
示例7: getData
import org.apache.commons.collections.ListUtils; //導入方法依賴的package包/類
@DataProvider(name="data")
public Object[][] getData() {
// the sequence dictionary
final SAMSequenceDictionary dictionary = new SAMSequenceDictionary();
dictionary.addSequence(new SAMSequenceRecord("1", 1000000));
dictionary.addSequence(new SAMSequenceRecord("2", 1000000));
// the set of intervals
final List<SimpleInterval> intervals_1 = Arrays.asList(new SimpleInterval("1:500-600"), new SimpleInterval("1:700-800"));
final List<SimpleInterval> intervals_2 = Arrays.asList(new SimpleInterval("2:100-200"), new SimpleInterval("2:400-1000"));
// some records
final SimpleInterval record_1_1_100 = new SimpleInterval("1:1-100");
final SimpleInterval record_1_1_800 = new SimpleInterval("1:1-800");
final SimpleInterval record_1_500_600 = new SimpleInterval("1:500-600");
final SimpleInterval record_1_700_750 = new SimpleInterval("1:700-750");
final SimpleInterval record_2_100_150 = new SimpleInterval("2:100-150");
final SimpleInterval record_2_900_999 = new SimpleInterval("2:900-999");
// test cases
return new Object[][] {
// first record starts before the first interval, second record overlaps the first interval
{intervals_1, dictionary, new SimpleInterval[]{record_1_1_100, record_1_500_600, record_2_900_999}, new SimpleInterval[]{record_1_500_600}},
// first record starts after the first interval, second interval overlaps the first record
{intervals_1, dictionary, new SimpleInterval[]{record_1_700_750, record_2_900_999}, new SimpleInterval[]{record_1_700_750}},
// first interval is on a later contig than the first record, but overlaps later records
{intervals_2, dictionary, new SimpleInterval[]{record_1_1_100, record_2_900_999}, new SimpleInterval[]{record_2_900_999}},
// first interval is on an earlier contig than the first record, but later records overlap later intervals
{ListUtils.union(intervals_1, intervals_2), dictionary, new SimpleInterval[]{record_2_100_150, record_2_900_999}, new SimpleInterval[]{record_2_100_150, record_2_900_999}},
// no records overlap any intervals
{intervals_1, dictionary, new SimpleInterval[]{record_2_900_999}, new SimpleInterval[0]},
// an interval overlaps multiple records
{intervals_1, dictionary, new SimpleInterval[]{record_1_1_800, record_1_500_600, record_2_900_999}, new SimpleInterval[]{record_1_1_800, record_1_500_600}},
// a record overlaps multiple intervals
{intervals_1, dictionary, new SimpleInterval[]{record_1_1_800, record_2_100_150}, new SimpleInterval[]{record_1_1_800}}
};
}
示例8: combine_two_lists_in_java_with_apache_commons
import org.apache.commons.collections.ListUtils; //導入方法依賴的package包/類
@Test
public void combine_two_lists_in_java_with_apache_commons () {
@SuppressWarnings("unchecked")
List<String> allStates = ListUtils.union(
firstHalfStates,
secondHalfStates);
assertTrue(allStates.size() == 50);
}
示例9: saveTmpGeneric
import org.apache.commons.collections.ListUtils; //導入方法依賴的package包/類
public Map saveTmpGeneric(String type, List elems) {
Map results = new HashMap();
HttpSession session = ExecutionContext.get().getSession(false);
//put the element into an arraylist in the session...doesnt exist? create it
List al = new ArrayList();
if(session.getAttribute(type) != null) {
al = (List) session.getAttribute(type);
if(elems!=null && elems.size()>0){
al = ListUtils.union(al, elems);
//remove duplicats since union() keeps dups
HashSet<String> h = new HashSet<String>();
for (int i = 0; i < al.size(); i++)
h.add((String)al.get(i));
List<String> cleanList = new ArrayList<String>();
for(String n : h) {
cleanList.add(n);
}
al=cleanList;
}
}
else if(elems!=null && elems.size()>0) {
al = elems;
}
if(al!=null && al.size()>0){
session.setAttribute(type, al); //put in session
}
String tmpElems = "";
for(int i = 0; i<al.size(); i++)
tmpElems += al.get(i) + "<br/>";
results.put("count", al.size());
results.put("elements", tmpElems);
return results;
}
示例10: getOnboardingTransactionEntityIdsTemp
import org.apache.commons.collections.ListUtils; //導入方法依賴的package包/類
public List<String> getOnboardingTransactionEntityIdsTemp() {
return ListUtils.union(onboardingTransactionEntityIdsTemp, onboardingTransactionEntityIds);
}
示例11: addMissingAlleles
import org.apache.commons.collections.ListUtils; //導入方法依賴的package包/類
/**
* Add alleles that are missing in the read-likelihoods collection giving all reads a default
* likelihood value.
* @param candidateAlleles the potentially missing alleles.
* @param defaultLikelihood the default read likelihood value for that allele.
*
* @return {@code true} iff the the read-likelihood collection was modified by the addition of the input alleles.
* So if all the alleles in the input collection were already present in the read-likelihood collection this method
* will return {@code false}.
*
* @throws IllegalArgumentException if {@code candidateAlleles} is {@code null} or there is more than
* one missing allele that is a reference or there is one but the collection already has
* a reference allele.
*/
public boolean addMissingAlleles(final Collection<A> candidateAlleles, final double defaultLikelihood) {
Utils.nonNull(candidateAlleles, "the candidateAlleles list cannot be null");
if (candidateAlleles.isEmpty()) {
return false;
}
final List<A> allelesToAdd = candidateAlleles.stream().filter(allele -> !alleles.containsAllele(allele)).collect(Collectors.toList());
if (allelesToAdd.isEmpty()) {
return false;
}
final int oldAlleleCount = alleles.numberOfAlleles();
final int newAlleleCount = alleles.numberOfAlleles() + allelesToAdd.size();
alleleList = null;
int referenceIndex = this.referenceAlleleIndex;
@SuppressWarnings("unchecked")
final List<A> newAlleles = ListUtils.union(alleles.asListOfAlleles(), allelesToAdd);
alleles = new IndexedAlleleList<>(newAlleles);
// if we previously had no reference allele, update the reference index if a reference allele is added
// if we previously had a reference and try to add another, throw an exception
final OptionalInt indexOfReferenceInAllelesToAdd = IntStream.range(0, allelesToAdd.size())
.filter(n -> allelesToAdd.get(n).isReference()).findFirst();
if (referenceIndex != MISSING_REF) {
Utils.validateArg(!indexOfReferenceInAllelesToAdd.isPresent(), "there can only be one reference allele");
} else if (indexOfReferenceInAllelesToAdd.isPresent()){
referenceAlleleIndex = oldAlleleCount + indexOfReferenceInAllelesToAdd.getAsInt();
}
//copy old allele likelihoods and set new allele likelihoods to the default value
for (int s = 0; s < samples.numberOfSamples(); s++) {
final int sampleReadCount = readsBySampleIndex[s].length;
final double[][] newValuesBySampleIndex = Arrays.copyOf(valuesBySampleIndex[s], newAlleleCount);
for (int a = oldAlleleCount; a < newAlleleCount; a++) {
newValuesBySampleIndex[a] = new double[sampleReadCount];
if (defaultLikelihood != 0.0) {
Arrays.fill(newValuesBySampleIndex[a], defaultLikelihood);
}
}
valuesBySampleIndex[s] = newValuesBySampleIndex;
}
return true;
}
示例12: beforeTxn
import org.apache.commons.collections.ListUtils; //導入方法依賴的package包/類
@Override
public void beforeTxn(SSConnection conn, CatalogDAO c, WorkerGroup wg) throws PEException {
final SchemaContext sc = SchemaContext.createContext(conn);
sc.forceMutableSource();
/*
* Build a sample table on which we then perform a trial conversion
* to get the resultant column types.
*/
final PETable sampleTarget = this.alterTarget.recreate(sc, this.alterTarget.getDeclaration(), new LockInfo(
com.tesora.dve.lockmanager.LockType.RSHARED, "transient alter table statement"));
final PEDatabase sampleTargetDatabase = sampleTarget.getPEDatabase(sc);
final List<TableModifier> sampleTargetModifiers = new ArrayList<TableModifier>();
for (final TableModifier entry : sampleTarget.getModifiers().getModifiers()) {
if (entry != null) {
sampleTargetModifiers.add(entry);
}
}
/* FKs would not resolve on the sample site. */
sampleTarget.removeForeignKeys(sc);
final List<TableComponent<?>> sampleTargetFieldsAndKeys = ListUtils.union(sampleTarget.getColumns(sc), sampleTarget.getKeys(sc));
final QualifiedName sampleTargetName = new QualifiedName(
sampleTargetDatabase.getName().getUnqualified(),
new UnqualifiedName(UserTable.getNewTempTableName())
);
final PEPersistentGroup sg = buildOneSiteGroup(sc, false);
/*
* Make sure the actual sample gets created as a TEMPORARY table in
* the user database so that it always gets removed.
*/
final ComplexPETable temporarySampleTarget = new ComplexPETable(sc,
sampleTargetName, sampleTargetFieldsAndKeys,
sampleTarget.getDistributionVector(sc), sampleTargetModifiers,
sg, sampleTargetDatabase, TableState.SHARED);
temporarySampleTarget.withTemporaryTable(sc);
final TableInstance targetTableInstance = new TableInstance(temporarySampleTarget, temporarySampleTarget.getName(), null, true);
final PECreateTableStatement createSampleTable = new PECreateTableStatement(temporarySampleTarget, false);
final PEAlterTableStatement alterSampleTable =
new PEAlterTableStatement(sc, targetTableInstance.getTableKey(), Collections.singletonList(this.alterAction.makeTransientOnlyClone()));
final ColumnTypeMetadataCollector metadataFilter = new ColumnTypeMetadataCollector(temporarySampleTarget, this.metadata);
final PEDropTableStatement dropSampleTable = new PEDropTableStatement(sc, Collections.singletonList(targetTableInstance.getTableKey()), Collections.<Name> emptyList(), true,
targetTableInstance.getTableKey().isUserlandTemporaryTable());
final ExecutionSequence es = new ExecutionSequence(null);
es.append(new SessionExecutionStep(null, sg, createSampleTable.getSQL(sc)));
es.append(new SessionExecutionStep(null, sg, alterSampleTable.getSQL(sc)));
es.append(metadataFilter.getCollectorExecutionStep(sc));
es.append(new SessionExecutionStep(null, sg, dropSampleTable.getSQL(sc)));
es.schedule(null, this.plan, null, sc, new IdentityConnectionValuesMap(cv), null);
}
示例13: verify
import org.apache.commons.collections.ListUtils; //導入方法依賴的package包/類
private void verify(String duration, List<TimestampedDatasetVersion> toBeDeleted,
List<TimestampedDatasetVersion> toBeRetained) {
@SuppressWarnings("unchecked")
List<TimestampedDatasetVersion> allVersions = ListUtils.union(toBeRetained, toBeDeleted);
List<TimestampedDatasetVersion> deletableVersions =
Lists.newArrayList(new TimeBasedRetentionPolicy(duration).listDeletableVersions(allVersions));
assertThat(deletableVersions, Matchers.containsInAnyOrder(toBeDeleted.toArray()));
assertThat(deletableVersions, Matchers.not(Matchers.containsInAnyOrder(toBeRetained.toArray())));
}