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

com.sap.cloud.security.ams.dcl.client.dcn.Rule 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;

@Beta
public class Rule implements Annotated, PolicyMember {

    private Effect effect;

    private List actions;

    private List resources;

    private Object condition;

    private Map annotations;

    private transient Object userData; // NOSONAR

    public Effect effect() {
        return effect;
    }

    public Rule effect(Effect effect) {
        this.effect = effect;
        return this;
    }

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

    public Rule actions(List actions) {
        this.actions = actions; // NOSONAR
        return this;
    }

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

    public Rule resources(List resources) {
        this.resources = resources; // NOSONAR
        return this;
    }

    public Object condition() {
        return condition;
    }

    public Rule condition(Object condition) {
        this.condition = condition;
        return this;
    }

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

    @Override
    public Rule 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 Rule userData(Object userData) {
        this.userData = userData;
        return this;
    }

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

    //

    @Override
    public String toString() {
        return "Rule [effect=" + effect
                + ", actions=" + actions
                + ", resources=" + resources
                + ", condition=" + condition
                + ", annotations=" + annotations
                + "]";
    }

    @Override
    public int hashCode() {
        return Objects.hash(effect, actions, resources, condition, annotations);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Rule other = (Rule) obj;
        return effect == other.effect
                && Objects.equals(actions, other.actions)
                && Objects.equals(resources, other.resources)
                && Objects.equals(condition, other.condition)
                && Objects.equals(annotations, other.annotations);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy