本文整理汇总了Java中java.util.Collection.addAll方法的典型用法代码示例。如果您正苦于以下问题:Java Collection.addAll方法的具体用法?Java Collection.addAll怎么用?Java Collection.addAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Collection
的用法示例。
在下文中一共展示了Collection.addAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllFrames
import java.util.Collection; //导入方法依赖的package包/类
private static Collection<JInternalFrame> getAllFrames(Container parent) {
int i, count;
Collection<JInternalFrame> results = new LinkedHashSet<>();
count = parent.getComponentCount();
for (i = 0; i < count; i++) {
Component next = parent.getComponent(i);
if (next instanceof JInternalFrame) {
results.add((JInternalFrame) next);
} else if (next instanceof JInternalFrame.JDesktopIcon) {
JInternalFrame tmp = ((JInternalFrame.JDesktopIcon) next).getInternalFrame();
if (tmp != null) {
results.add(tmp);
}
} else if (next instanceof Container) {
results.addAll(getAllFrames((Container) next));
}
}
return results;
}
示例2: get
import java.util.Collection; //导入方法依赖的package包/类
/**
* Get all of the ParameterMapping for this StmtParameter, regardless of the catalog_stmt_index
* @param catalog_stmt
* @param catalog_stmt_param
* @return
*/
protected Collection<ParameterMapping> get(Statement catalog_stmt, StmtParameter catalog_stmt_param) {
assert(catalog_stmt != null);
assert(catalog_stmt_param != null);
Collection<ParameterMapping> set = new TreeSet<ParameterMapping>();
StatementMappings mappings = this.stmtIndex.get(catalog_stmt);
if (mappings != null) {
for (SortedMap<StmtParameter, SortedSet<ParameterMapping>> m : mappings.values()) {
if (m.containsKey(catalog_stmt_param)) {
set.addAll(m.get(catalog_stmt_param));
}
} // FOR
}
return (set);
}
示例3: read
import java.util.Collection; //导入方法依赖的package包/类
@Override
public Collection<Relay.Bundle> read(Uuid teamId, Secret teamSecret, Uuid root, int range) {
final Collection<Relay.Bundle> result = new ArrayList<>();
try (final Connection connection = source.connect()) {
Serializers.INTEGER.write(connection.out(), NetworkCode.RELAY_READ_REQUEST);
Uuid.SERIALIZER.write(connection.out(), teamId);
Secret.SERIALIZER.write(connection.out(), teamSecret);
Uuid.SERIALIZER.write(connection.out(), root);
Serializers.INTEGER.write(connection.out(), range);
if (Serializers.INTEGER.read(connection.in()) == NetworkCode.RELAY_READ_RESPONSE) {
result.addAll(Serializers.collection(BUNDLE_SERIALIZER).read(connection.in()));
} else {
LOG.error("Server did not handle RELAY_READ_REQUEST");
}
} catch (Exception ex) {
LOG.error(ex, "Unexpected error when sending RELAY_READ_REQUEST");
}
return result;
}
示例4: pruneInvalidMessages
import java.util.Collection; //导入方法依赖的package包/类
/**
* Sorts any invalid messages by moving them from the msgList. The net result
* is a new list returned containing the invalid messages and a pruned msgList
* containing only those messages that are valid for the given role of the controller
* and OpenFlow version of the switch.
*
* @param msgList the list of messages to sort
* @param valid the list of valid messages (caller must allocate)
* @param swVersion the OFVersion of the switch
* @param isSlave true if controller is slave; false otherwise
* @return list of messages that are not valid, removed from input parameter msgList
*/
protected static Collection<OFMessage> pruneInvalidMessages(Iterable<OFMessage> msgList, Collection<OFMessage> valid, OFVersion swVersion, boolean isActive) {
if (isActive) { /* master or equal/other support all */
valid.addAll(IterableUtils.toCollection(msgList));
return Collections.emptyList();
} else { /* slave */
Set<OFType> invalidSlaveMsgs = invalidSlaveMsgsByOFVersion.get(swVersion);
List<OFMessage> invalid = new ArrayList<OFMessage>();
Iterator<OFMessage> itr = msgList.iterator();
while (itr.hasNext()) {
OFMessage m = itr.next();
if (invalidSlaveMsgs.contains(m.getType())) {
invalid.add(m);
} else {
valid.add(m);
}
}
return invalid;
}
}
示例5: handleGetCollidingDutyRosterTurns
import java.util.Collection; //导入方法依赖的package包/类
@Override
protected Collection<DutyRosterTurnOutVO> handleGetCollidingDutyRosterTurns(
AuthenticationVO auth, Long courseParticipationStatusEntryId, Boolean isRelevantForCourseAppointments) throws Exception {
CourseParticipationStatusEntry courseParticipationStatusEntry = CheckIDUtil.checkCourseParticipationStatusEntryId(courseParticipationStatusEntryId,
this.getCourseParticipationStatusEntryDao());
Collection collidingDutyRosterTurns = new HashSet(); // ArrayList();
Long staffId = courseParticipationStatusEntry.getStaff().getId();
DutyRosterTurnDao dutyRosterTurnDao = this.getDutyRosterTurnDao();
Iterator<InventoryBooking> it = this.getInventoryBookingDao()
.findByCourseSorted(courseParticipationStatusEntry.getCourse().getId(), isRelevantForCourseAppointments, false).iterator();
while (it.hasNext()) {
InventoryBooking courseInventoryBooking = it.next();
collidingDutyRosterTurns.addAll(dutyRosterTurnDao.findByStaffTrialCalendarInterval(staffId, null, null, courseInventoryBooking.getStart(),
courseInventoryBooking.getStop()));
}
dutyRosterTurnDao.toDutyRosterTurnOutVOCollection(collidingDutyRosterTurns);
return new ArrayList<DutyRosterTurnOutVO>(collidingDutyRosterTurns);
}
示例6: mapEdges
import java.util.Collection; //导入方法依赖的package包/类
Collection<ResourceDemandEntry> mapEdges(
SubstrateNetwork sNetwork,
VirtualNetwork vNetwork,
MappingCandidate<VirtualNode, SubstrateNode> candidate,
NodeLinkMapping m,
Collection<ResourceDemandEntry> demandedNodeEnergyResource,
int epsilon) {
Collection<ResourceDemandEntry> out = mapOutEdges(
sNetwork, vNetwork, candidate, m, epsilon);
if (out == null) {
return null;
}
Collection<ResourceDemandEntry> in = mapInEdges(
sNetwork, vNetwork, candidate, m, epsilon);
if (in == null) {
Utils.freeResources(out);
return null;
}
out.addAll(in);
return out;
}
示例7: getEndpoints
import java.util.Collection; //导入方法依赖的package包/类
protected Collection<Endpoint> getEndpoints ( final EquinoxApplication app )
{
final Collection<Endpoint> result = new LinkedList<> ();
if ( app == null )
{
return result;
}
for ( final Exporter exporter : app.getExporter () )
{
result.addAll ( exporter.getEndpoints () );
}
return result;
}
示例8: sendCurrentView
import java.util.Collection; //导入方法依赖的package包/类
void sendCurrentView() {
NetView v = currentView;
if (v != null) {
InstallViewMessage msg = new InstallViewMessage(v,
services.getAuthenticator().getCredentials(localAddress), false);
Collection<InternalDistributedMember> recips =
new ArrayList<>(v.size() + v.getCrashedMembers().size());
recips.addAll(v.getMembers());
recips.remove(localAddress);
recips.addAll(v.getCrashedMembers());
msg.setRecipients(recips);
// use sendUnreliably since we are sending to crashed members &
// don't want any retransmission tasks set up for them
services.getMessenger().sendUnreliably(msg);
}
}
示例9: testToArray_threadSafe
import java.util.Collection; //导入方法依赖的package包/类
public void testToArray_threadSafe() {
for (int delta : new int[] { +1, 0, -1 }) {
for (int i = 0; i < VALUES.length; i++) {
List<Character> list = Chars.asList(VALUES).subList(0, i);
Collection<Character> misleadingSize =
Helpers.misleadingSizeCollection(delta);
misleadingSize.addAll(list);
char[] arr = Chars.toArray(misleadingSize);
assertEquals(i, arr.length);
for (int j = 0; j < i; j++) {
assertEquals(VALUES[j], arr[j]);
}
}
}
}
示例10: getAllowedPackageResourceTypes
import java.util.Collection; //导入方法依赖的package包/类
private Collection<QName> getAllowedPackageResourceTypes()
{
// look for content nodes or links to content
// NOTE: folders within workflow packages are ignored for now
Collection<QName> allowedTypes = dictionaryService.getSubTypes(ContentModel.TYPE_CONTENT, true);
allowedTypes.addAll(dictionaryService.getSubTypes(ApplicationModel.TYPE_FILELINK, true));
return allowedTypes;
}
示例11: onDisable
import java.util.Collection; //导入方法依赖的package包/类
@Override
public void onDisable() {
pipeThread.setRunning(false);
try {
pipeThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
savingManager.saveDuctsSync(true);
// despawn all pipes and items
Map<World, Map<BlockLoc, Duct>> fullDuctMap = getFullDuctMap();
synchronized (fullDuctMap) {
for (Map<BlockLoc, Duct> ductMap : fullDuctMap.values()) {
for (Duct duct : ductMap.values()) {
ductManager.destroyDuct(duct);
if (duct instanceof Pipe) {
Pipe pipe = (Pipe) duct;
Collection<PipeItem> allItems = new ArrayList<>();
synchronized (pipe.pipeItems) {
allItems.addAll(pipe.pipeItems.keySet());
}
synchronized (pipe.tempPipeItems) {
allItems.addAll(pipe.tempPipeItems.keySet());
}
synchronized (pipe.tempPipeItemsWithSpawn) {
allItems.addAll(pipe.tempPipeItemsWithSpawn.keySet());
}
for (PipeItem pi : allItems) {
ductManager.destroyPipeItem(pi);
}
}
}
}
}
}
示例12: checkArgs
import java.util.Collection; //导入方法依赖的package包/类
/**
* Extract values from command line entries and use as a means of configuration.
*
* @param line parsed command line
* @return paths extracted from the command line
*/
private static Collection<Path> checkArgs(CommandLine line) {
Collection<Path> validFiles = new LinkedList<>();
for (String arg : checkFlags(line).getArgs()) {
validFiles.addAll(checkPath(arg));
}
return validFiles;
}
示例13: loadWhiteLists
import java.util.Collection; //导入方法依赖的package包/类
/**
* Loads white lists of properties and group classes and add them to the given collections.
*/
private void loadWhiteLists(Resource[] resources, Collection<String> classes, Collection<String> names) throws IOException {
for (Resource resource : resources) {
Properties properties = new Properties();
properties.load(resource.getInputStream());
classes.addAll(Arrays.asList(StringUtils.delimitedListToStringArray(properties.getProperty(CONFIGURATION_PROPERTIES_CLASSES), ",", " ")));
names.addAll(Arrays.asList(StringUtils.delimitedListToStringArray(properties.getProperty(CONFIGURATION_PROPERTIES_NAMES), ",", " ")));
}
}
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:12,代码来源:BootApplicationConfigurationMetadataResolver.java
示例14: addCompletions
import java.util.Collection; //导入方法依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null) {
return;
}
final Collection<PhpClassMember> members = new THashSet<>();
String prefix = result.getPrefixMatcher().getPrefix();
if (!(prefix.lastIndexOf("::") > 0 && prefix.lastIndexOf("\\") > 0
&& prefix.lastIndexOf("::") > prefix.lastIndexOf("\\"))) {
return;
}
String className = prefix.substring(0, prefix.lastIndexOf("::"));
PhpIndex phpIndex = PhpIndex.getInstance(parameters.getPosition().getProject());
for (PhpClass phpClass : phpIndex.getAnyByFQN(className)) {
members.addAll(phpClass.getFields());
members.addAll(phpClass.getMethods());
}
for (PhpClassMember member : members) {
if (Field.class.isInstance(member)) {
result.addElement(
LookupElementBuilder
.create(className + (((Field) member).isConstant() ? "::" : "::$") + member.getName())
.withIcon(member.getIcon())
);
} else {
result.addElement(
LookupElementBuilder
.create(className + "::" + member.getName() + "()")
.withIcon(member.getIcon())
);
}
}
}
示例15: create
import java.util.Collection; //导入方法依赖的package包/类
/**
* Generic algorithm that takes an iterable over T objects, a getter routine to extract the reads in T,
* and returns a FragmentCollection that contains the T objects whose underlying reads either overlap (or
* not) with their mate pairs.
*
* @param readContainingObjects An iterator of objects that contain GATKSAMRecords
* @param nElements the number of elements to be provided by the iterator, which is usually known upfront and
* greatly improves the efficiency of the fragment calculation
* @param getter a helper function that takes an object of type T and returns is associated GATKSAMRecord
* @param <T>
* @return a fragment collection
*/
private static <T> FragmentCollection<T> create(final Iterable<T> readContainingObjects, final int nElements, final ReadGetter<T> getter) {
Collection<T> singletons = null;
Collection<List<T>> overlapping = null;
Map<String, T> nameMap = null;
int lastStart = -1;
// build an initial map, grabbing all of the multi-read fragments
for ( final T p : readContainingObjects ) {
final SAMRecord read = getter.get(p);
if ( read.getAlignmentStart() < lastStart ) {
throw new IllegalArgumentException(String.format(
"FragmentUtils.create assumes that the incoming objects are ordered by " +
"SAMRecord alignment start, but saw a read %s with alignment start " +
"%d before the previous start %d", read.getSAMString(), read.getAlignmentStart(), lastStart));
}
lastStart = read.getAlignmentStart();
final int mateStart = read.getMateAlignmentStart();
if ( mateStart == 0 || mateStart > read.getAlignmentEnd() ) {
// if we know that this read won't overlap its mate, or doesn't have one, jump out early
if ( singletons == null ) singletons = new ArrayList<T>(nElements); // lazy init
singletons.add(p);
} else {
// the read might overlap it's mate, or is the rightmost read of a pair
final String readName = read.getReadName();
final T pe1 = nameMap == null ? null : nameMap.get(readName);
if ( pe1 != null ) {
// assumes we have at most 2 reads per fragment
if ( overlapping == null ) overlapping = new ArrayList<List<T>>(); // lazy init
overlapping.add(Arrays.asList(pe1, p));
nameMap.remove(readName);
} else {
if ( nameMap == null ) nameMap = new HashMap<String, T>(nElements); // lazy init
nameMap.put(readName, p);
}
}
}
// add all of the reads that are potentially overlapping but whose mate never showed
// up to the oneReadPile
if ( nameMap != null && ! nameMap.isEmpty() ) {
if ( singletons == null )
singletons = nameMap.values();
else
singletons.addAll(nameMap.values());
}
return new FragmentCollection<T>(singletons, overlapping);
}