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

patterntesting.runtime.NullConstants Maven / Gradle / Ivy

/**
 * $Id: NullConstants.java,v 1.2 2012/07/16 19:57:11 oboehm Exp $
 *
 * Copyright (c) 2009 by Oliver Boehm
 *
 * 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 orimplied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * (c)reated 13.06.2009 by oliver ([email protected])
 */
package patterntesting.runtime;

import java.io.File;
import java.util.Date;

/**
 * This class contains some constants (like a NULL_STRING) as constant.
 * It can be statically imported.
 *
 * @author oliver
 * @since 13.06.2009
 * @version $Revision: 1.2 $
 */
public final class NullConstants {

    /** to avoid that this class will be instantiated */
    private NullConstants() {}

    /**
     * If you have a method with a list of arguments where some arguments are
     * optional you can
     * 
    *
  • * provide the method with different signatures * (good idea, but not always feasible) *
  • *
  • * admit null arguments and handle it in the methode * (not a good idea because it can happen accidentally) *
  • *
  • * use this special NULL_OBJECT object to mark an argument as optional *
  • *
* Unfortunately this works only for object as argument. For String as * argument you can use NULL_STRING. * * @see #NULL_STRING */ public static final Object NULL_OBJECT = new Object(); /** * You need a null string and don't want to use null? Use * NULL_STRING and you can write code like *
     * if (name == NULL_STRING) ...
     * 
*/ public static final String NULL_STRING = ""; /** * You need a null file and don't want to use null? Use * NULL_FILE and you can write code like *
     * if (name == NULL_STRING) ...
     * 
*/ public static final File NULL_FILE = new File(NULL_STRING); /** * You need a null throwable and don't want to use null? Use * NULL_THROWABLE and you can write code like *
     * if (name == NULL_THROWABLE) ...
     * 
*/ public static final Throwable NULL_THROWABLE = new Throwable(); /** * You need a null exception and don't want to use null? Use * NULL_EXCEPTION and you can write code like *
     * if (name == NULL_EXCEPTION) ...
     * 
*/ public static final Throwable NULL_EXCEPTION = new Exception(); /** * You need a null date and don't want to use null? Use * NULL_DATE and you can write code like *
     * if (name == NULL_DATE) ...
     * 
* The NULL_DATE is defined here as 1.1.1970 (the epoch). */ public static final Date NULL_DATE = new Date(0L); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy