org.ocpsoft.rewrite.config.Not Maven / Gradle / Ivy
/*
* Copyright 2011 Lincoln Baxter, III
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ocpsoft.rewrite.config;
import java.util.Arrays;
import java.util.List;
import org.ocpsoft.rewrite.context.EvaluationContext;
import org.ocpsoft.rewrite.event.Rewrite;
/**
* Evaluates all provided {@link Condition} instances. If all provided conditions return true
, this
* condition returns false
. If any provided conditions return false
, this condition returns
* true
.
*
* @author Lincoln Baxter, III
*
* @author Lincoln Baxter, III
*
*/
public final class Not extends DefaultConditionBuilder implements CompositeCondition
{
private final Condition condition;
private Not(final Condition condition)
{
this.condition = condition;
}
/**
* Evaluates all provided {@link Condition} instances. If all provided conditions return true
, this
* condition returns false
. If any provided conditions return false
, this condition returns
* true
.
*/
public static Not any(final Condition condition)
{
return new Not(condition);
}
@Override
public boolean evaluate(final Rewrite event, final EvaluationContext context)
{
return condition.evaluate(event, context) != true;
}
@Override
public List getConditions()
{
return Arrays.asList(condition);
}
@Override
public String toString()
{
return "Not [" + condition + "]";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy