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

org.jmockring.utils.Functions Maven / Gradle / Ivy

Go to download

jmockring - Java test MOCKing tool for spRING. A test harness tool for projects using the following technology stack: - Java 6+ - Spring 3.1 or greater as a DI/Deployment container - JUnit 4 and Mockito for testing - Jetty/Servlet API 3.0 for web app (war) deployment - for testing only Main features: 1) Partial Spring context deployment with automatic bean mocking for unavailable beans 2) Bootstrapping embedded Jetty server via JUnit runners 3) Configurable web application contexts 4) Automatic injection of Spring beans and mocks in JUnit tests via Java5 annotations

The newest version!
package org.jmockring.utils;

/**
 * @author Pavel Lechev
 * @date 21/04/13
 */
public class Functions {

    /**
     * Return the second argument if the first one evaluates to null or empty string.
     *
     * @param optionOne
     * @param optionTwo
     * @param 
     *
     * @return
     */
    public static  T ifEmpty(T optionOne, T optionTwo) {
        if (optionOne == null || optionOne.toString() == null || optionOne.toString().isEmpty()) {
            return optionTwo;
        }
        return optionOne;
    }

    /**
     * Return optionOne if it does not equal criteria, else return optionTwo
     *
     * @param criteria
     * @param optionOne
     * @param optionTwo
     * @param 
     *
     * @return
     */
    public static  T ifNot(T criteria, T optionOne, T optionTwo) {
        if (!criteria.equals(optionOne)) {
            return optionOne;
        }
        return optionTwo;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy