org.keycloak.models.jpa

## Class GroupAdapter

- java.lang.Object
- - org.keycloak.models.jpa.GroupAdapter

- All Implemented Interfaces:
    GroupModel, GroupModel.Streams, JpaModel<GroupEntity>, RoleMapperModel, RoleMapperModel.Streams

      public class GroupAdapter
      extends Object
      implements GroupModel.Streams, JpaModel<GroupEntity>

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.keycloak.models.GroupModel

      `GroupModel.GroupRemovedEvent, GroupModel.SearchableFields, GroupModel.Streams`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected javax.persistence.EntityManager` | `em`
    `protected GroupEntity` | `group`
    `protected RealmModel` | `realm`

    - ### Fields inherited from interface org.keycloak.models.GroupModel

      `COMPARE_BY_NAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GroupAdapter(RealmModel realm, javax.persistence.EntityManager em, GroupEntity group)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addChild(GroupModel subGroup)` Automatically calls setParent() on the subGroup
    `void` | `deleteRoleMapping(RoleModel role)` Removes the given role mapping from this object.
    `boolean` | `equals(Object o)`
    `Map<String,List<String>>` | `getAttributes()`
    `Stream<String>` | `getAttributeStream(String name)` Returns group attributes that match the given name as a stream.
    `Stream<RoleModel>` | `getClientRoleMappingsStream(ClientModel app)` Returns stream of client roles that are directly set to this object for the given client.
    `GroupEntity` | `getEntity()`
    `String` | `getFirstAttribute(String name)`
    `protected javax.persistence.TypedQuery<GroupRoleMappingEntity>` | `getGroupRoleMappingEntityTypedQuery(RoleModel role)`
    `String` | `getId()`
    `String` | `getName()`
    `GroupModel` | `getParent()`
    `String` | `getParentId()`
    `Stream<RoleModel>` | `getRealmRoleMappingsStream()` Returns stream of realm roles that are directly set to this object.
    `Stream<RoleModel>` | `getRoleMappingsStream()` Returns stream of all role (both realm all client) that are directly set to this object.
    `Stream<GroupModel>` | `getSubGroupsStream()` Returns all sub groups for the parent group as a stream.
    `void` | `grantRole(RoleModel role)` Grants the given role to this object.
    `int` | `hashCode()`
    `boolean` | `hasRole(RoleModel role)` Returns `true` if this object is directly or indirectly assigned the given role, `false` otherwise.
    `void` | `removeAttribute(String name)`
    `void` | `removeChild(GroupModel subGroup)` Automatically calls setParent() on the subGroup
    `void` | `setAttribute(String name, List<String> values)`
    `void` | `setName(String name)`
    `void` | `setParent(GroupModel parent)` You must also call addChild on the parent group, addChild on RealmModel if there is no parent group
    `void` | `setSingleAttribute(String name, String value)` Set single value of specified attribute.
    `static GroupEntity` | `toEntity(GroupModel model, javax.persistence.EntityManager em)`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.keycloak.models.GroupModel.Streams

      `getAttribute, getSubGroups`

    - ### Methods inherited from interface org.keycloak.models.RoleMapperModel.Streams

      `getClientRoleMappings, getRealmRoleMappings, getRoleMappings`

- - ### Field Detail

    - #### group

          protected GroupEntity group

    - #### em

          protected javax.persistence.EntityManager em

    - #### realm

          protected RealmModel realm

  - ### Constructor Detail

    - #### GroupAdapter

          public GroupAdapter(RealmModel realm,
                              javax.persistence.EntityManager em,
                              GroupEntity group)

  - ### Method Detail

    - #### getEntity

          public GroupEntity getEntity()

      Specified by:
        `getEntity` in interface `JpaModel<GroupEntity>`

    - #### getId

          public String getId()

      Specified by:
        `getId` in interface `GroupModel`

    - #### getName

          public String getName()

      Specified by:
        `getName` in interface `GroupModel`

    - #### setName

          public void setName(String name)

      Specified by:
        `setName` in interface `GroupModel`

    - #### getParent

          public GroupModel getParent()

      Specified by:
        `getParent` in interface `GroupModel`

    - #### getParentId

          public String getParentId()

      Specified by:
        `getParentId` in interface `GroupModel`

    - #### toEntity

          public static GroupEntity toEntity(GroupModel model,
                                             javax.persistence.EntityManager em)

    - #### setParent

          public void setParent(GroupModel parent)

      Description copied from interface: `GroupModel`
      You must also call addChild on the parent group, addChild on RealmModel if there is no parent group
      Specified by:
        `setParent` in interface `GroupModel`

    - #### addChild

          public void addChild(GroupModel subGroup)

      Description copied from interface: `GroupModel`
      Automatically calls setParent() on the subGroup
      Specified by:
        `addChild` in interface `GroupModel`

    - #### removeChild

          public void removeChild(GroupModel subGroup)

      Description copied from interface: `GroupModel`
      Automatically calls setParent() on the subGroup
      Specified by:
        `removeChild` in interface `GroupModel`

    - #### getSubGroupsStream

          public Stream<GroupModel> getSubGroupsStream()

      Description copied from interface: `GroupModel`
      Returns all sub groups for the parent group as a stream.
      Specified by:
        `getSubGroupsStream` in interface `GroupModel`
      Specified by:
        `getSubGroupsStream` in interface `GroupModel.Streams`
      Returns:
        Stream of `GroupModel`. Never returns `null`.

    - #### setSingleAttribute

          public void setSingleAttribute(String name,
                                         String value)

      Description copied from interface: `GroupModel`
      Set single value of specified attribute. Remove all other existing values
      Specified by:
        `setSingleAttribute` in interface `GroupModel`

    - #### setAttribute

          public void setAttribute(String name,
                                   List<String> values)

      Specified by:
        `setAttribute` in interface `GroupModel`

    - #### removeAttribute

          public void removeAttribute(String name)

      Specified by:
        `removeAttribute` in interface `GroupModel`

    - #### getFirstAttribute

          public String getFirstAttribute(String name)

      Specified by:
        `getFirstAttribute` in interface `GroupModel`
      Returns:
        null if there is not any value of specified attribute or first value otherwise. Don't throw exception if there are more values of the attribute

    - #### getAttributeStream

          public Stream<String> getAttributeStream(String name)

      Description copied from interface: `GroupModel`
      Returns group attributes that match the given name as a stream.
      Specified by:
        `getAttributeStream` in interface `GroupModel`
      Specified by:
        `getAttributeStream` in interface `GroupModel.Streams`
      Parameters:
        `name` - `String` Name of the attribute to be used as a filter.
      Returns:
        Stream of all attribute values or empty stream if there are not any values. Never return `null`.

    - #### getAttributes

          public Map<String,List<String>> getAttributes()

      Specified by:
        `getAttributes` in interface `GroupModel`

    - #### hasRole

          public boolean hasRole(RoleModel role)

      Description copied from interface: `RoleMapperModel`
      Returns `true` if this object is directly or indirectly assigned the given role, `false` otherwise.

      For example, `true` is returned for hasRole(R) if:

      - R is directly assigned to this object
      - R is not assigned to this object but this object belongs to a group G which is assigned the role R
      - R is not assigned to this object but this object belongs to a group G, and G belongs to group H which is assigned the role R
      Specified by:
        `hasRole` in interface `RoleMapperModel`
      Returns:
        see description

    - #### getGroupRoleMappingEntityTypedQuery

          protected javax.persistence.TypedQuery<GroupRoleMappingEntity> getGroupRoleMappingEntityTypedQuery(RoleModel role)

    - #### grantRole

          public void grantRole(RoleModel role)

      Description copied from interface: `RoleMapperModel`
      Grants the given role to this object.
      Specified by:
        `grantRole` in interface `RoleMapperModel`

    - #### getRealmRoleMappingsStream

          public Stream<RoleModel> getRealmRoleMappingsStream()

      Description copied from interface: `RoleMapperModel`
      Returns stream of realm roles that are directly set to this object.
      Specified by:
        `getRealmRoleMappingsStream` in interface `RoleMapperModel`
      Specified by:
        `getRealmRoleMappingsStream` in interface `RoleMapperModel.Streams`
      Returns:
        Stream of `RoleModel`. Never returns `null`.

    - #### getRoleMappingsStream

          public Stream<RoleModel> getRoleMappingsStream()

      Description copied from interface: `RoleMapperModel`
      Returns stream of all role (both realm all client) that are directly set to this object.
      Specified by:
        `getRoleMappingsStream` in interface `RoleMapperModel`
      Specified by:
        `getRoleMappingsStream` in interface `RoleMapperModel.Streams`
      Returns:
        Stream of `RoleModel`. Never returns `null`.

    - #### deleteRoleMapping

          public void deleteRoleMapping(RoleModel role)

      Description copied from interface: `RoleMapperModel`
      Removes the given role mapping from this object.
      Specified by:
        `deleteRoleMapping` in interface `RoleMapperModel`
      Parameters:
        `role` - Role to remove

    - #### getClientRoleMappingsStream

          public Stream<RoleModel> getClientRoleMappingsStream(ClientModel app)

      Description copied from interface: `RoleMapperModel`
      Returns stream of client roles that are directly set to this object for the given client.
      Specified by:
        `getClientRoleMappingsStream` in interface `RoleMapperModel`
      Specified by:
        `getClientRoleMappingsStream` in interface `RoleMapperModel.Streams`
      Parameters:
        `app` - `ClientModel` Client to get the roles for.
      Returns:
        Stream of `RoleModel`. Never returns `null`.

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

Copyright © 2021 JBoss by Red Hat. All rights reserved.