All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.arbeitsagentur.opdt.keycloak.cassandra.clientScope.persistence.entities.ClientScopes Maven / Gradle / Ivy

package de.arbeitsagentur.opdt.keycloak.cassandra.clientScope.persistence.entities;

import com.datastax.oss.driver.api.mapper.annotations.CqlName;
import com.datastax.oss.driver.api.mapper.annotations.Entity;
import com.datastax.oss.driver.api.mapper.annotations.PartitionKey;
import de.arbeitsagentur.opdt.keycloak.cassandra.transaction.TransactionalEntity;
import lombok.*;

import java.util.*;

@EqualsAndHashCode(of = "realmId")
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
@CqlName("client_scopes")
public class ClientScopes implements TransactionalEntity {
    @PartitionKey
    private String realmId;

    private Long version;

    @Builder.Default
    private Set clientScopes = new HashSet<>();

    @Override
    public String getId() {
        return realmId;
    }

    public Set getClientScopes() {
        if (clientScopes == null) {
            return new HashSet<>();
        }
        return clientScopes;
    }

    public ClientScopeValue getClientScopeById(String id) {
        ClientScopeValue clientScope = clientScopes.stream().filter(s -> s.getId().equals(id)).findFirst().orElse(null);
        if (clientScope == null) {
            return clientScopes.stream().filter(r -> r.getId().equals(id)).findFirst().orElse(null);
        }
        return clientScope;
    }

    public void addClientScope(ClientScopeValue clientScopeValue) {
        clientScopes.add(clientScopeValue);
    }

    public boolean removeClientScope(String id) {
        return clientScopes.removeIf(s -> Objects.equals(s.getId(), id));
    }

    public Map> getAttributes() {
        return Collections.emptyMap();
    }

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy