Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* =============================================================================
*
* Copyright (c) 2010, The OP4J team (http://www.op4j.org)
*
* 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.op4j.functions;
import java.math.BigDecimal;
import java.math.BigInteger;
import org.apache.commons.lang.Validate;
import org.javaruntype.type.Type;
import org.javaruntype.type.Types;
import org.op4j.exceptions.ExecutionException;
/**
*
* @since 1.0
*
* @author Soraya Sánchez
*
*/
public final class FnBoolean {
private static final ToNumber TO_BIG_DECIMAL = new ToNumber(Types.BIG_DECIMAL);
private static final ToNumber TO_BIG_INTEGER = new ToNumber(Types.BIG_INTEGER);
private static final ToNumber TO_DOUBLE = new ToNumber(Types.DOUBLE);
private static final ToNumber TO_FLOAT = new ToNumber(Types.FLOAT);
private static final ToNumber TO_LONG = new ToNumber(Types.LONG);
private static final ToNumber TO_INTEGER = new ToNumber(Types.INTEGER);
private static final ToNumber TO_SHORT = new ToNumber(Types.SHORT);
private static final ToNumber TO_BYTE = new ToNumber(Types.BYTE);
private static final Negate NEGATE = new Negate();
@SuppressWarnings("unchecked")
private static final Function IS_TRUE = (Function) (Function,?>) eq(true);
@SuppressWarnings("unchecked")
private static final Function IS_FALSE = (Function) (Function,?>) eq(false);
private FnBoolean() {
super();
}
/**
*
* Converts a Boolean to a BigDecimal. true = 1, false = 0.
*
*
* @return a BigDecimal representing the boolean target.
*/
public static final Function toBigDecimal() {
return TO_BIG_DECIMAL;
}
/**
*
* Converts a Boolean to a BigInteger. true = 1, false = 0.
*
*
* @return a BigInteger representing the boolean target.
*/
public static final Function toBigInteger() {
return TO_BIG_INTEGER;
}
/**
*
* Converts a Boolean to a Double. true = 1, false = 0.
*
*
* @return a Double representing the boolean target.
*/
public static final Function toDouble() {
return TO_DOUBLE;
}
/**
*
* Converts a Boolean to a Float. true = 1, false = 0.
*
*
* @return a Float representing the boolean target.
*/
public static final Function toFloat() {
return TO_FLOAT;
}
/**
*
* Converts a Boolean to a Long. true = 1, false = 0.
*
*
* @return a Long representing the boolean target.
*/
public static final Function toLong() {
return TO_LONG;
}
/**
*
* Converts a Boolean to a Integer. true = 1, false = 0.
*
*
* @return a Integer representing the boolean target.
*/
public static final Function toInteger() {
return TO_INTEGER;
}
/**
*
* Converts a Boolean to a Short. true = 1, false = 0.
*
*
* @return a Short representing the boolean target.
*/
public static final Function toShort() {
return TO_SHORT;
}
/**
*
* Converts a Boolean to a Byte. true = 1, false = 0.
*
*
* @return a Byte representing the boolean target.
*/
public static final Function toByte() {
return TO_BYTE;
}
/**
*
* Negates the target Boolean, returning Boolean.FALSE if the
* target object is Boolean.TRUE, and Boolean.TRUE if it is Boolean.FALSE.
*
*
* @return the negation of the target object.
*/
public static final Function negate() {
return NEGATE;
}
/**
*
* Determines whether the target object and the specified object are equal
* by calling the equals method on the target object.
*
*
* @param object the object to compare to the target
* @return true if both objects are equal, false if not.
*/
public static final Function