How to check in java if Set contains object with some string value?

后端 未结 6 1526
北荒
北荒 2020-12-16 10:19

I have Set of objects. Each object has String value.

I need to select all objects that have this value equal to \"direction\".

Is it possibl

6条回答
  •  佛祖请我去吃肉
    2020-12-16 10:49

    In my user class I have initialized roles variable like this private Set<\Role> roles;. This has a getter method. In the Role class I have String role variable where it is used to store the value of role. In order to get the value of role. I can use below code.

    for (Role role : user.getRoles()) {
               rolevalue = role.getRole();
            }
    

提交回复
热议问题