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

com.sap.cloud.security.ams.dcl.client.dcn.Policy Maven / Gradle / Ivy

The newest version!
/************************************************************************
 * © 2019-2024 SAP SE or an SAP affiliate company. All rights reserved. *
 ************************************************************************/
package com.sap.cloud.security.ams.dcl.client.dcn;

import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;

import com.sap.cloud.security.ams.dcl.client.annotation.Beta;
import com.sap.cloud.security.ams.dcl.client.el.QualifiedName;

@Beta
public class Policy implements Annotated {

    private QualifiedName qualifiedName;

    private List rules;

    private List uses;

    private String description;

    private boolean defaultPolicy;

    private boolean internal;

    private Map annotations;

    private transient Object userData; // NOSONAR

    public QualifiedName qualifiedName() {
        return qualifiedName;
    }

    public Policy qualifiedName(QualifiedName qualifiedName) {
        this.qualifiedName = qualifiedName;
        return this;
    }

    public List rules() {
        return rules; // NOSONAR
    }

    public Policy rules(List rules) {
        this.rules = rules; // NOSONAR
        return this;
    }

    public List uses() {
        return uses; // NOSONAR
    }

    public Policy uses(List uses) {
        this.uses = uses; // NOSONAR
        return this;
    }

    public String description() {
        return description;
    }

    public Policy description(String description) {
        this.description = description;
        return this;
    }

    public boolean defaultPolicy() {
        return defaultPolicy;
    }

    public Policy defaultPolicy(boolean defaultPolicy) {
        this.defaultPolicy = defaultPolicy;
        return this;
    }

    public boolean internal() {
        return internal;
    }

    public Policy internal(boolean internal) {
        this.internal = internal;
        return this;
    }

    @Override
    public Map annotations() {
        return annotations; // NOSONAR
    }

    @Override
    public Policy annotations(Map annotations) {
        this.annotations = annotations; // NOSONAR
        return this;
    }

    /**
     * Gets the custom user data. This data is not stored or loaded (i.e transient). The value is not take into account for hashCode() or
     * equals(Object other).
     * 
     * @return user data
     */
    public Object userData() {
        return userData;
    }

    /**
     * Sets the user data. This data is not stored or loaded (i.e transient). The value is not take into account for hashCode() or equals(Object
     * other).
     * 
     * @param userData
     *            custom user data
     * @return this
     */
    public Policy userData(Object userData) {
        this.userData = userData;
        return this;
    }

    public Policy apply(Consumer consumer) {
        consumer.accept(this);
        return this;
    }

    //

    @Override
    public String toString() {
        return "Policy [qualifiedName=" + qualifiedName
                + ", rules=" + rules
                + ", uses=" + uses
                + ", description=" + description
                + ", default=" + defaultPolicy
                + ", internal=" + internal
                + ", annotations=" + annotations
                + "]";
    }

    @Override
    public int hashCode() {
        return Objects.hash(annotations, defaultPolicy, internal, description, qualifiedName, rules, uses);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Policy other = (Policy) obj;
        return Objects.equals(annotations, other.annotations)
                && defaultPolicy == other.defaultPolicy
                && internal == other.internal
                && Objects.equals(description, other.description)
                && Objects.equals(qualifiedName, other.qualifiedName)
                && Objects.equals(rules, other.rules)
                && Objects.equals(uses, other.uses);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy