本文整理汇总了Java中java.util.Collection.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Collection.isEmpty方法的具体用法?Java Collection.isEmpty怎么用?Java Collection.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Collection
的用法示例。
在下文中一共展示了Collection.isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSelectionToViewer
import java.util.Collection; //导入方法依赖的package包/类
/**
* This sets the selection into whichever viewer is active.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setSelectionToViewer(Collection<?> collection) {
final Collection<?> theSelection = collection;
// Make sure it's okay.
//
if (theSelection != null && !theSelection.isEmpty()) {
Runnable runnable =
new Runnable() {
public void run() {
// Try to select the items in the current content viewer of the editor.
//
if (currentViewer != null) {
currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true);
}
}
};
getSite().getShell().getDisplay().asyncExec(runnable);
}
}
示例2: Policy
import java.util.Collection; //导入方法依赖的package包/类
/**
* Constructor that should be overridden by child implementation. The constructor allows for easy toString() output
* customization.
*
* @param toStringName a general name of the object (such as 'policy' or 'nested policy') that will be used in the
* toString() method to identify the object.
* @param sets represents the collection of policy alternatives of the policy object created. During the creation of
* the new policy object, the content of the alternatives collection is copied into an internal policy object structure,
* thus any subsequent operations on the collection will have no impact on the newly constructed policy object. The
* collection may be {@code null} or empty. In such case a 'NULL' policy object is constructed.
*/
Policy(final String toStringName, final Collection<AssertionSet> sets) {
this.nsVersion = NamespaceVersion.getLatestVersion();
this.toStringName = toStringName;
if (sets == null || sets.isEmpty()) {
this.assertionSets = NULL_POLICY_ASSERTION_SETS;
this.vocabulary = EMPTY_VOCABULARY;
this.immutableVocabulary = EMPTY_VOCABULARY;
} else {
this.assertionSets = new LinkedList<AssertionSet>();
this.vocabulary = new TreeSet<QName>(PolicyUtils.Comparison.QNAME_COMPARATOR);
this.immutableVocabulary = Collections.unmodifiableCollection(this.vocabulary);
addAll(sets);
}
}
示例3: run
import java.util.Collection; //导入方法依赖的package包/类
@Override
public void run(HealthCheckRepository healthCheckRepository) {
lastTimeRun = LocalDateTime.now();
Collection<HealthCheck> all = healthCheckRepository.findAll(
healthCheck -> statuses.contains(healthCheck.getLastStatus().getHealth()) && healthCheck.getTags().containsAll(tags)
);
if (all == null || all.isEmpty()) {
return;
}
if (onlyOnChange) {
// Here we'll try to determine if something has changed since last notification
String newCheckSum = computeCheckSum(all);
if (!newCheckSum.equals(lastRunChecksum)) {
doRun(all);
lastRunChecksum = newCheckSum;
}
} else {
doRun(all);
}
}
示例4: filterByGlobPattern
import java.util.Collection; //导入方法依赖的package包/类
/**
* 找到了配合Glob模式的字符串。模式有多个,只要匹配一个模式,就返回这个字符串。
*/
public static Set<String> filterByGlobPattern(Collection<String> patterns, Collection<String> values) {
Set<String> ret = new HashSet<String>();
if(null == patterns || values == null || patterns.isEmpty() || values.isEmpty()) {
return ret;
}
for(String p : patterns) {
for(String v : values) {
if(isMatchGlobPattern(p, v)) {
ret.add(v);
}
}
}
return ret;
}
示例5: convert
import java.util.Collection; //导入方法依赖的package包/类
@Override
public Boolean convert(@NonNull final Pair<URL,String> p) {
if (!forIndexer.equals(p.second())) {
return null;
}
try {
final FileObject cacheFolder = CacheFolder.getDataFolder(p.first());
final FileObject indexer = cacheFolder.getFileObject(p.second());
final FileObject indexFolder = indexer.getFileObject("1/1");
final DocumentIndexCache cache = DocumentBasedIndexManager.getDefault().getCache(indexFolder.toURL());
final Class<?> c = Class.forName("org.netbeans.modules.parsing.impl.indexing.ClusteredIndexables$DocumentIndexCacheImpl"); //NOI18N
final Field f = c.getDeclaredField("toDeleteOutOfOrder"); //NOI18N
f.setAccessible(true);
final Collection<?> data = (Collection<?>) f.get(cache);
return data.isEmpty();
} catch (Exception e) {
return Boolean.FALSE;
}
}
示例6: addAllImpl
import java.util.Collection; //导入方法依赖的package包/类
/**
* An implementation of {@link Multiset#addAll}.
*/
static <E> boolean addAllImpl(Multiset<E> self, Collection<? extends E> elements) {
if (elements.isEmpty()) {
return false;
}
if (elements instanceof Multiset) {
Multiset<? extends E> that = cast(elements);
for (Entry<? extends E> entry : that.entrySet()) {
self.add(entry.getElement(), entry.getCount());
}
} else {
Iterators.addAll(self, elements.iterator());
}
return true;
}
示例7: retainAllAsync
import java.util.Collection; //导入方法依赖的package包/类
@Override
public RFuture<Boolean> retainAllAsync(Collection<?> c) {
if (c.isEmpty()) {
return deleteAsync();
}
return commandExecutor.evalWriteAsync(getName(), codec, RedisCommands.EVAL_BOOLEAN,
"redis.call('sadd', KEYS[2], unpack(ARGV)); "
+ "local prevSize = redis.call('scard', KEYS[1]); "
+ "local size = redis.call('sinterstore', KEYS[1], KEYS[1], KEYS[2]);"
+ "redis.call('del', KEYS[2]); "
+ "return size ~= prevSize and 1 or 0; ",
Arrays.<Object>asList(getName(), "redisson_temp__{" + getName() + "}"), encode(c).toArray());
}
示例8: _finishComponentReferenceInitialization
import java.util.Collection; //导入方法依赖的package包/类
/**
* Ensure that all DeferredComponentReferences are fully initialized before the
* request completes
*/
private void _finishComponentReferenceInitialization(ExternalContext ec)
{
Map<String, Object> requestMap = ec.getRequestMap();
Collection<ComponentReference<?>> initializeList =
(Collection<ComponentReference<?>>) requestMap.get(_FINISH_INITIALIZATION_LIST_KEY);
if ((initializeList != null) && !initializeList.isEmpty())
{
RuntimeException initializationException = null;
for (ComponentReference<?> reference: initializeList)
{
try
{
reference.ensureInitialization();
}
catch (RuntimeException rte)
{
initializationException = rte;
}
}
// we've initialized everything, so we're done
initializeList.clear();
// rethrow the exception now that we are all done cleaning up
if (initializationException != null)
{
throw initializationException;
}
}
}
示例9: save
import java.util.Collection; //导入方法依赖的package包/类
/**
* Persist a collection of entities
*
* @param entities The collection of entities to persist
*/
public void save(Collection<T> entities) {
if (entities != null && !entities.isEmpty()) {
new ManagedTransaction(emf)
.withExceptionConsumer(e -> logger.error("Could not save entities", e))
.executeWithinTransaction(session -> entities.stream()
.filter(Objects::nonNull)
.forEach(session::saveOrUpdate));
}
}
示例10: putAll
import java.util.Collection; //导入方法依赖的package包/类
public HeaderMap putAll(HttpString headerName, Collection<String> headerValues) {
if (headerName == null) {
throw new IllegalArgumentException("headerName is null");
}
if (headerValues == null || headerValues.isEmpty()) {
remove(headerName);
}
final HeaderValues entry = getOrCreateEntry(headerName);
entry.clear();
entry.addAll(headerValues);
return this;
}
示例11: getListOfStringsMatchingLastWord
import java.util.Collection; //导入方法依赖的package包/类
public static List<String> getListOfStringsMatchingLastWord(String[] inputArgs, Collection<?> possibleCompletions)
{
String s = inputArgs[inputArgs.length - 1];
List<String> list = Lists.<String>newArrayList();
if (!possibleCompletions.isEmpty())
{
for (String s1 : Iterables.transform(possibleCompletions, Functions.toStringFunction()))
{
if (doesStringStartWith(s, s1))
{
list.add(s1);
}
}
if (list.isEmpty())
{
for (Object object : possibleCompletions)
{
if (object instanceof ResourceLocation && doesStringStartWith(s, ((ResourceLocation)object).getResourcePath()))
{
list.add(String.valueOf(object));
}
}
}
}
return list;
}
示例12: PingRecord
import java.util.Collection; //导入方法依赖的package包/类
PingRecord() {
final Collection<Player> onlinePlayers = Server.getInstance().getOnlinePlayers().values();
int totalPing = 0;
for (Player player : onlinePlayers) {
totalPing += player.getPing();
}
this.avg = onlinePlayers.isEmpty() ? 0 : totalPing / onlinePlayers.size();
}
示例13: isEmpty
import java.util.Collection; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public static Boolean isEmpty(Collection collection) {
return collection.isEmpty();
}
示例14: register
import java.util.Collection; //导入方法依赖的package包/类
/**
* Register a new class to add injection to it
*
* @param classes list of the classes
*
* @throws IOException rethrown from {@link org.objectweb.asm.ClassReader} constructor
* @throws UnmodifiableClassException if any of the given class is unmodifiable
*/
public void register(final Class<?>... classes) throws IOException, UnmodifiableClassException
{
if (!InstrumentationHolder.isInstrumentationAvailable())
{
throw new RuntimeException("Instrumentation not available", InstrumentationHolder.getUnavailabilityCause());
}
if (!InternalContainer.isContainerPresent(this.containerId))
{
InternalContainer.registerInjector(this);
}
final Collection<ClassDefinition> definitions = new ArrayList<>(classes.length);
for (final Class<?> clazz : classes)
{
if (this.registered.contains(clazz))
{
continue;
}
final ReflectAnnotatedClass reflectClass = this.gasketAnnotationProcessor.getJavaReflectClass(clazz);
final List<String> fields = new ArrayList<>(reflectClass.getFields().length);
for (final AnnotatedField field : reflectClass.getFields())
{
if (field.isAnnotationPresent(Inject.class))
{
fields.add(field.getName());
}
}
if (!fields.isEmpty())
{
final String javaClassPath = AsmUtils.getJavaClassPath(clazz.getName());
final byte[] bytes = IOUtils.toByteArray(clazz.getClassLoader().getResourceAsStream(javaClassPath));
definitions.add(new ClassDefinition(clazz, new InjectionClassModifier(bytes, fields, this.getContainerId()).modify()));
}
for (final InjectionProvider injectionProvider : this.injectionProviders)
{
injectionProvider.register(this, clazz);
}
this.registered.add(clazz);
}
if (!definitions.isEmpty())
{
try
{
final ClassDefinition[] definitionsArray = new ClassDefinition[definitions.size()];
definitions.toArray(definitionsArray);
InstrumentationHolder.getInstrumentation().redefineClasses(definitionsArray);
}
catch (final ClassNotFoundException e)
{
throw new Error("According to the documentation this can't happen, but it did, not my problem", e);
}
}
}
示例15: lookupTag
import java.util.Collection; //导入方法依赖的package包/类
public static String lookupTag(List<LanguageRange> priorityList,
Collection<String> tags) {
if (priorityList.isEmpty() || tags.isEmpty()) {
return null;
}
int splitIndex = splitRanges(priorityList);
List<LanguageRange> nonZeroRanges;
List<LanguageRange> zeroRanges;
if (splitIndex != -1) {
nonZeroRanges = priorityList.subList(0, splitIndex);
zeroRanges = priorityList.subList(splitIndex, priorityList.size());
} else {
nonZeroRanges = priorityList;
zeroRanges = List.of();
}
for (LanguageRange lr : nonZeroRanges) {
String range = lr.getRange();
// Special language range ("*") is ignored in lookup.
if (range.equals("*")) {
continue;
}
String rangeForRegex = range.replace("*", "\\p{Alnum}*");
while (rangeForRegex.length() > 0) {
for (String tag : tags) {
// change to lowercase for case-insensitive matching
String lowerCaseTag = tag.toLowerCase(Locale.ROOT);
if (lowerCaseTag.matches(rangeForRegex)
&& !shouldIgnoreLookupMatch(zeroRanges, lowerCaseTag)) {
return tag; // preserve the case of the input tag
}
}
// Truncate from the end....
rangeForRegex = truncateRange(rangeForRegex);
}
}
return null;
}