Here you can find the source of assertPrecondition(boolean b)
@pre
tag) is satisfied.
Parameter | Description |
---|---|
b | The value of executing the condition |
public static void assertPrecondition(boolean b)
//package com.java2s; /*// ww w .j ava 2 s . c o m * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ public class Main { /** * Checks that a precondition (declared using the javadoc <code>@pre</code> * tag) is satisfied. * * @param b The value of executing the condition */ public static void assertPrecondition(boolean b) { assertTrue(b); } public static void assertPrecondition(boolean b, String condition) { assertTrue(b, condition); } /** * Throws an internal error if condition is not true. It would be called * <code>assert</code>, but that is a keyword as of JDK 1.4. */ public static void assertTrue(boolean b) { if (!b) { newInternal("assert failed"); } } public static void assertTrue(boolean b, String message) { if (!b) { newInternal("assert failed: " + message); } } /** * Creates an internal error with a given message. */ public static RuntimeException newInternal(String message) { return new RuntimeException(message); } /** * Creates an internal error with a given message and cause. */ public static RuntimeException newInternal(Throwable e, String message) { return new RuntimeException(message, e); } }