作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个像这样定义的构造函数。现在我想过滤掉下面评论(代码中)中提到的一些记录,请告知如何实现这一点。
public class A
{
private HashSet<Integer> readPermissionGroup = new HashSet<Integer>();
//constructor
A
{
this.readPermissionGroup.add(10);
this.readPermissionGroup.add(11);
this.readPermissionGroup.add(15);
this.readPermissionGroup.add(16);
}
// ...
}
现在下面是另一段代码,它正在执行一些操作,如下所示
Set<Group> groups = user.getGroups();
for (Group group : groups) {
//?? now here I want to filter out the records where g.id not in (10,11,15,15)
//?? right now it is doing the opposite
if (readPermissionGroup.contains(group.getId())) // i want to filter those record whose
// value is not
// 10,11,15,16
{
hasAccess = true;
break;
}
}
return hasAccess;
最佳答案
在条件前面使用 not !
或恢复 boolean 值:
if (!readPermissionGroup.contains(group.getId()))
关于java - 过滤掉集合中的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18733098/
我正在编写一个快速的 preg_replace 来从 CSS 中删除注释。 CSS 注释通常有这样的语法: /* Development Classes*/ /* Un-comment me for
使用 MySQL,我有三个表: 项目: ID name 1 "birthday party" 2 "soccer match" 3 "wine tasting evening" 4
我是一名优秀的程序员,十分优秀!