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

com.atlassian.bamboo.specs.api.model.permission.GroupPermissionProperties Maven / Gradle / Ivy

package com.atlassian.bamboo.specs.api.model.permission;

import com.atlassian.bamboo.specs.api.builders.permission.PermissionType;
import com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException;
import com.atlassian.bamboo.specs.api.model.EntityProperties;
import org.jetbrains.annotations.NotNull;

import javax.annotation.concurrent.Immutable;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Set;

@Immutable
public class GroupPermissionProperties implements EntityProperties {

    private final String group;
    private final Set permissionTypes;

    private GroupPermissionProperties() {
        this.group = null;
        this.permissionTypes = null;
    }

    public GroupPermissionProperties(@NotNull final String group,
                                     @NotNull final Collection permissionTypes) throws PropertiesValidationException {
        this.group = group;
        this.permissionTypes = Collections.unmodifiableSet(new LinkedHashSet<>(permissionTypes));
        validate();
    }

    public String getGroup() {
        return group;
    }

    public Set getPermissionTypes() {
        return permissionTypes;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        GroupPermissionProperties that = (GroupPermissionProperties) o;
        return Objects.equals(group, that.group) &&
                Objects.equals(permissionTypes, that.permissionTypes);
    }

    @Override
    public int hashCode() {
        return Objects.hash(group, permissionTypes);
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("GroupPermissionProperties{");
        sb.append("group='").append(group).append('\'');
        sb.append(", permissionTypes=").append(permissionTypes);
        sb.append('}');
        return sb.toString();
    }

    @Override
    public void validate() throws PropertiesValidationException {
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy