/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2008 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: ConditionDecision.java,v 1.3 2009/09/05 00:24:04 veiming Exp $
*
* Portions copyright 2010-2015 ForgeRock AS.
*/
/**
* Class to represent {@link EntitlementCondition} evaluation match result and - if applicable - its advice.
*
* @supported.all.api
*/
public class ConditionDecision {
private final long timeToLive;
private final boolean satisfied;
/**
* Constructs an instance of <code>ConditionDecision</code>.
* <p/>
* Deprecated, favour the factory methods.
*
* @param satisfied
* result of this <code>ConditionDecision</code>.
* @param advices
* Advice map of this <code>ConditionDecision</code>.
*/
}
/**
* Constructs an instance of <code>ConditionDecision</code>.
* <p/>
* Deprecated, favour the factory methods.
*
* @param satisfied
* Result of this <code>ConditionDecision</code>.
* @param advices
* Advice map of this <code>ConditionDecision</code>.
* @param ttl
* The TTL of this <code>ConditionDecision</code>.
*/
this.responseAttributes = new HashMap<>();
this.timeToLive = ttl;
}
}
/**
* Whether this <code>ConditionDecision</code> is satisfied.
*
* @return <code>true</code> if <code>ConditionDecision</code> is fulfilled.
*/
public boolean isSatisfied() {
return satisfied;
}
/**
* Advices associated with this <code>ConditionDecision</code>.
*
* @return advice of <code>ConditionDecision</code>.
*/
}
/**
* Retrieves the response attributes.
*
* @return the response attributes
*/
}
/**
* Returns the time to live (TTL) of this <code>ConditionDecision</code>.
*
* @return The TTL time in ms.
*/
public long getTimeToLive() {
return timeToLive;
}
/**
* Clears the current advice associated with this <code>ConditionDecision</code>.
* <p/>
* Deprecated method as a given instance should be immutable.
*/
public void clearAdvices() {
}
/**
* Adds an advice (from another <code>ConditionDecision</code>) to this <code>ConditionDecision</code>.
* <p/>
* Deprecated method as a given instance should be immutable.
*
* @param decision
* The <code>ConditionDecision</code> whose advice should be added to this
* <code>ConditionDecision</code>.
*/
}
}
}
/**
* New decision builder.
*
* @param satisfied
* whether the decision represents a successful evaluation or not
*
* @return new builder instance
*/
}
/**
* New builder representing a satisfied.
*
* @return new builder instance
*/
return new Builder(true);
}
/**
* New builder representing a failure.
*
* @return new builder instance
*/
return new Builder(false);
}
/**
* Builder to help construct decisions.
*/
public static final class Builder {
private final boolean satisfied;
private long timeToLive;
responseAttributes = new HashMap<>();
}
/**
* Sets the advice.
*
* @param advice
* the advice
*
* @return this builder instance
*/
return this;
}
/**
* Sets the response attributes.
*
* @param responseAttributes
* the response attributes
*
* @return this builder instance
*/
this.responseAttributes = responseAttributes;
return this;
}
/**
* Sets the time to live.
*
* @param timeToLive
* the time to live
*
* @return this builder instance
*/
this.timeToLive = timeToLive;
return this;
}
/**
* Builds the decision.
*
* @return the decision instance
*/
return new ConditionDecision(this);
}
}
}