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

net.sourceforge.jeuclid.Defense Maven / Gradle / Ivy

Go to download

This is the core module containing the basic JEuclid rendering and document handling classes.

There is a newer version: 3.1.9
Show newest version
/*
 * Copyright 2002 - 2007 JEuclid, http://jeuclid.sf.net
 * 
 * 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.
 */

/* $Id: Defense.java 518 2007-09-14 08:29:58Z maxberger $ */

package net.sourceforge.jeuclid;

import java.io.File;

/**
 * Internal class for defensive programming.
 * 

* Even though these methods are declared as public, there are not guaranteed * to be stable or work outside JEuclid. *

* http://en.wikipedia.org/wiki/Defensive_programming * * @version $Revision: 518 $ * */ public final class Defense { /** Default constructor. */ private Defense() { // Empty on purpose } /** * Makes sure a parameter is not null. * * @param o * parameter * @param name * name of the parameter */ public static void notNull(final Object o, final String name) { if (o != null) { return; } throw new NullPointerException("'" + name + "' cannot be null"); } /** * Makes sure a file exists. * * @param file * the file */ public static void fileExists(final File file) { if (!file.exists()) { throw new AssertionError(file.toString() + " doesn't exist"); } } /** * Makes sure a condition is true. * * @param b * condition * @param string * value */ public static void assertTrue(final boolean b, final String string) { if (!b) { throw new AssertionError("Condition failed:" + string); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy