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

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

There is a newer version: 10.0.1
Show newest version
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 LoggedInUserPermissionsProperties implements EntityProperties {

    private final Set permissionTypes;

    private LoggedInUserPermissionsProperties() {
        this.permissionTypes = null;
    }

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

    public Set getPermissionTypes() {
        return permissionTypes;
    }

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

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy