本文整理汇总了Java中java.util.Set.containsAll方法的典型用法代码示例。如果您正苦于以下问题:Java Set.containsAll方法的具体用法?Java Set.containsAll怎么用?Java Set.containsAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Set
的用法示例。
在下文中一共展示了Set.containsAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isTargetRegistered
import java.util.Set; //导入方法依赖的package包/类
/**
* Is target registered.
*
* @param targetObject the target object.
* @param targetChannelId the target channel id.
* @return is target registered.
*/
private boolean isTargetRegistered(Object targetObject, List<String> targetChannelId) {
Set<String> currentlyRegisteredChannelId = new HashSet<>();
for (Map.Entry<Class<?>, ConcurrentHashMap<Object, ConcurrentHashMap<String,
SubscriberHolder>>> mEventsToTargetsMapEntry : mEventsToTargetsMap.entrySet()) {
ConcurrentHashMap<Object, ConcurrentHashMap<String, SubscriberHolder>> mTargetMap =
mEventsToTargetsMapEntry.getValue();
if (mTargetMap.containsKey(targetObject)) {
ConcurrentHashMap<String, SubscriberHolder> subscribeMethods = mTargetMap.get
(targetObject);
for (Map.Entry<String, SubscriberHolder> subscribeMethodEntry : subscribeMethods.entrySet()) {
for (String methodChannelID : subscribeMethodEntry.getValue().subscribedChannelID) {
currentlyRegisteredChannelId.add(methodChannelID);
}
}
}
}
return currentlyRegisteredChannelId.size() > 0 && currentlyRegisteredChannelId.containsAll(targetChannelId);
}
示例2: difference
import java.util.Set; //导入方法依赖的package包/类
/**
* Returns an unmodifiable <b>view</b> of the difference of two sets. The
* returned set contains all elements that are contained by {@code set1} and
* not contained by {@code set2}. {@code set2} may also contain elements not
* present in {@code set1}; these are simply ignored. The iteration order of
* the returned set matches that of {@code set1}.
*
* <p>Results are undefined if {@code set1} and {@code set2} are sets based
* on different equivalence relations (as {@code HashSet}, {@code TreeSet},
* and the keySet of an {@code IdentityHashMap} all are).
*/
public static <E> SetView<E> difference(
final Set<E> set1, final Set<?> set2) {
checkNotNull(set1, "set1");
checkNotNull(set2, "set2");
final Predicate<Object> notInSet2 = Predicates.not(Predicates.in(set2));
return new SetView<E>() {
@Override public Iterator<E> iterator() {
return Iterators.filter(set1.iterator(), notInSet2);
}
@Override public int size() {
return Iterators.size(iterator());
}
@Override public boolean isEmpty() {
return set2.containsAll(set1);
}
@Override public boolean contains(Object element) {
return set1.contains(element) && !set2.contains(element);
}
};
}
示例3: equalsSetHelper
import java.util.Set; //导入方法依赖的package包/类
public static <T> boolean equalsSetHelper(Set<T> set, Object object) {
boolean z = true;
if (set == object) {
return true;
}
if (!(object instanceof Set)) {
return false;
}
Set<?> s = (Set) object;
try {
if (!(set.size() == s.size() && set.containsAll(s))) {
z = false;
}
return z;
} catch (NullPointerException e) {
return false;
} catch (ClassCastException e2) {
return false;
}
}
示例4: includeSoleDependencies
import java.util.Set; //导入方法依赖的package包/类
private Set<ResourceReference> includeSoleDependencies(Set<ResourceReference> dependents) {
while (true) {
Set<ResourceReference> newDependents = new HashSet<>(dependents);
for (ResourceReference dependent: dependents) {
for (ResourceReference dependency: dependencyMap.get(dependent).getDependencies()) {
if (!dependency.getClass().isAnnotationPresent(ResourceBundle.class)
&& dependents.containsAll(dependentMap.get(dependency))) {
newDependents.add(dependency);
}
}
}
if (!newDependents.equals(dependents)) {
dependents = newDependents;
} else {
break;
}
}
return dependents;
}
示例5: of
import java.util.Set; //导入方法依赖的package包/类
public static Imports of(Set<String> all, Map<String, String> classes) {
if (all.isEmpty() && classes.isEmpty()) {
return EMPTY;
}
if (!all.containsAll(classes.values())) {
// This check initially appeared as some imports might be skipped,
// but all classes imported are tracked, but it should be not a problem
}
return new Imports(all, classes);
}
示例6: selectorToString
import java.util.Set; //导入方法依赖的package包/类
private <E extends Enum<E>> void selectorToString(StringBuilder sb, Set<E> c, E[] values) {
if (!c.containsAll(Arrays.asList(values))) {
sb.append(c.stream()
.sorted((x, y) -> x.ordinal() - y.ordinal())
.map(v -> v.name().toLowerCase(Locale.US))
.collect(new Collector<CharSequence, StringJoiner, String>() {
@Override
public BiConsumer<StringJoiner, CharSequence> accumulator() {
return StringJoiner::add;
}
@Override
public Supplier<StringJoiner> supplier() {
return () -> new StringJoiner(",", (sb.length() == 0)? "" : "-", "")
.setEmptyValue("");
}
@Override
public BinaryOperator<StringJoiner> combiner() {
return StringJoiner::merge;
}
@Override
public Function<StringJoiner, String> finisher() {
return StringJoiner::toString;
}
@Override
public Set<Characteristics> characteristics() {
return Collections.emptySet();
}
}));
}
}
示例7: attachComponent
import java.util.Set; //导入方法依赖的package包/类
boolean attachComponent(Component component, Set<Integer> acceptableDeviceClasses) {
if (attachedComponents.isEmpty()) {
// If this is the first/only attached component, we keep the acceptableDeviceClasses.
this.acceptableDeviceClasses = (acceptableDeviceClasses == null)
? null
: new HashSet<Integer>(acceptableDeviceClasses);
} else {
// If there is already one or more attached components, the acceptableDeviceClasses must be
// the same as what we already have.
if (this.acceptableDeviceClasses == null) {
if (acceptableDeviceClasses != null) {
return false;
}
} else {
if (acceptableDeviceClasses == null) {
return false;
}
if (!this.acceptableDeviceClasses.containsAll(acceptableDeviceClasses)) {
return false;
}
if (!acceptableDeviceClasses.containsAll(this.acceptableDeviceClasses)) {
return false;
}
}
}
attachedComponents.add(component);
return true;
}
示例8: areAvailableVariables
import java.util.Set; //导入方法依赖的package包/类
public Boolean areAvailableVariables(Set<Name> needed) {
Set<Name> available = this.getAvailableVariables();
//If the prospective operations does not need any variables from upstream
//(available is a superset of needeld so the test is sound - the available set includes all the uses)
//(because, for example, it uses fields or other variables that remain in scope even after refactoring)
if (available.isEmpty()) {
//then the needed variables propagate from the downstream operation in order to facillitate chaining.
//(both to the needed and available sets).
available.addAll(needed);
this.getNeededVariables().addAll(needed);
return true;
}
return available.containsAll(needed);
}
示例9: matches
import java.util.Set; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean matches(Object argument) {
Set<E> collection = (Set<E>) argument;
return collection.containsAll(elements);
}
示例10: checkPermission
import java.util.Set; //导入方法依赖的package包/类
private int checkPermission(Tenant tenant, Set<Permission> required, HttpServletRequest req) {
if (required.isEmpty()) {
return 0;
}
String authHeader = req.getHeader("Authorization");
if (authHeader == null) {
return 401;
}
final String[] authHeaderComponents = authHeader.split(" ");
if (authHeaderComponents.length < 2) {
return 403;
}
try {
final String credentials = new String(
Base64.getDecoder().decode(authHeaderComponents[1]), "UTF-8").trim();
final String[] credentialComponents = credentials.split(":", 2);
if (credentialComponents.length < 2) {
return 403;
}
securityApi.login(credentialComponents[0], credentialComponents[1]);
TenantContext context = new EasyTaxTenantContext(tenant.getId(), null);
Set<Permission> granted = securityApi.getCurrentUserPermissions(context);
if (granted == null) {
return 403;
}
if (granted.containsAll(required)) {
return 0;
}
} catch (Exception e) {
// ignore and deny
log.info("Permission check failed for Authorization header {}: {}", authHeader,
e.getMessage());
}
return 403;
}
示例11: visitRuleset
import java.util.Set; //导入方法依赖的package包/类
@Override
public void visitRuleset(RulesetTree tree) {
Set<Combinations> combinations = EnumSet.noneOf(Combinations.class);
for (PropertyDeclarationTree propertyDeclarationTree : tree.block().propertyDeclarations()) {
PropertyTree propertyTree = propertyDeclarationTree.property();
if (isBoxSizing(propertyTree)) {
combinations.clear();
combinations.add(Combinations.IS_BOX_SIZING);
}
if (!combinations.contains(Combinations.IS_BOX_SIZING)) {
if (!combinations.contains(Combinations.WIDTH_FOUND) && isWidth(propertyTree)) {
combinations.add(Combinations.WIDTH_FOUND);
} else if (!combinations.contains(Combinations.HEIGHT_FOUND) && isHeight(propertyTree)) {
combinations.add(Combinations.HEIGHT_FOUND);
}
if (isWidthSizing(propertyDeclarationTree)) {
combinations.add(Combinations.WIDTH_SIZING);
}
if (isHeightSizing(propertyDeclarationTree)) {
combinations.add(Combinations.HEIGHT_SIZING);
}
}
}
if (combinations.containsAll(Arrays.asList(Combinations.WIDTH_FOUND, Combinations.WIDTH_SIZING))
|| combinations.containsAll(Arrays.asList(Combinations.HEIGHT_FOUND, Combinations.HEIGHT_SIZING))) {
addPreciseIssue(CheckUtils.rulesetIssueLocation(tree), "Check this potential box model size issue.");
}
super.visitRuleset(tree);
}
示例12: checkContainment
import java.util.Set; //导入方法依赖的package包/类
private boolean checkContainment(int ref, int dep, boolean countFP) throws Exception {
Set<String> refValueSet = this.parent.getValueSetFor(ref);
Set<String> depValueSet = this.parent.getValueSetFor(dep);
if (refValueSet.containsAll(depValueSet)) {
return true;
} else {
if (countFP)
this.falsePositives++;
return false;
}
}
示例13: properlyOverlap
import java.util.Set; //导入方法依赖的package包/类
public static boolean properlyOverlap(ReteStaticMapping one, ReteStaticMapping theOther) {
boolean result = false;
Set<RuleNode> nodes1 = new TreeHashSet<>();
nodes1.addAll(one.getLhsNodes());
Set<RuleNode> nodes2 = new TreeHashSet<>();
nodes2.addAll(theOther.getLhsNodes());
if ((one.getNNode() instanceof QuantifierCountChecker)
|| (theOther.getNNode() instanceof QuantifierCountChecker)) {
result = true;
if (one.getNNode() instanceof QuantifierCountChecker) {
nodes1.remove(one.getNNode()
.getPattern()[one.getNNode()
.getPattern().length - 1]);
result = result && nodes2.containsAll(nodes1);
}
if (theOther.getNNode() instanceof QuantifierCountChecker) {
nodes2.remove(theOther.getNNode()
.getPattern()[theOther.getNNode()
.getPattern().length - 1]);
result = result && nodes1.containsAll(nodes2);
}
} else {
for (RuleNode n : nodes1) {
result = nodes2.contains(n);
if (result) {
break;
}
}
}
return result;
}
示例14: setPattern
import java.util.Set; //导入方法依赖的package包/类
@SuppressWarnings("All")
public void setPattern(Set pattern) {
if (pattern.size() == 1 && pattern.containsAll(Collections.singletonList(1))) {
finalResultPattern = "1";
patternPronounce = null;
} else if (pattern.size() == 2 && pattern.containsAll(Arrays.asList(1, 2))) {
finalResultPattern = "2";
patternPronounce = null;
} else if (pattern.size() == 2 && pattern.containsAll(Arrays.asList(1, 4))) {
finalResultPattern = "3";
patternPronounce = null;
} else if (pattern.size() == 2 && pattern.containsAll(Arrays.asList(1, 5))) {
finalResultPattern = "5";
patternPronounce = null;
} else if (pattern.size() == 2 && pattern.containsAll(Arrays.asList(2, 4))) {
finalResultPattern = "9";
patternPronounce = null;
} else if (pattern.size() == 3 && pattern.containsAll(Arrays.asList(1, 4, 5))) {
finalResultPattern = "4";
patternPronounce = null;
} else if (pattern.size() == 3 && pattern.containsAll(Arrays.asList(1, 2, 4))) {
finalResultPattern = "6";
patternPronounce = null;
} else if (pattern.size() == 3 && pattern.containsAll(Arrays.asList(1, 2, 5))) {
finalResultPattern = "8";
patternPronounce = null;
} else if (pattern.size() == 3 && pattern.containsAll(Arrays.asList(2, 4, 5))) {
finalResultPattern = "0";
patternPronounce = null;
} else if (pattern.size() == 4 && pattern.containsAll(Arrays.asList(1, 2, 4, 5))) {
finalResultPattern = "7";
patternPronounce = null;
} else if (pattern.size() == 4 && pattern.containsAll(Arrays.asList(3, 4, 5, 6))) {
finalResultPattern = "#";
patternPronounce = context.getString(R.string.hash_pattern);
} else {
finalResultPattern = null;
patternPronounce = null;
}
}
示例15: isSuperset
import java.util.Set; //导入方法依赖的package包/类
public static <T> boolean isSuperset(Set<T> setA, Set<T> setB) {
return setA.containsAll(setB);
}