
br.com.objectos.core.lang.Preconditions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of preconditions Show documentation
Show all versions of preconditions Show documentation
A Java8, Guava compatible, Precondtions class.
The newest version!
/*
* Copyright 2015 Objectos, Fábrica de Software LTDA.
*
* 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 br.com.objectos.core.lang;
import java.util.Objects;
/**
* @author [email protected] (Marcio Endo)
*/
public class Preconditions {
private Preconditions() {
}
public static void checkArgument(boolean expression) {
if (!expression) {
throw new IllegalArgumentException();
}
}
public static void checkArgument(boolean expression, String message) {
if (!expression) {
throw new IllegalArgumentException(message);
}
}
public static void checkArgument(boolean expression, String format, Object... args) {
if (!expression) {
throw new IllegalArgumentException(String.format(format, args));
}
}
public static T checkNotNull(T reference) {
return Objects.requireNonNull(reference);
}
public static T checkNotNull(T reference, String message) {
return Objects.requireNonNull(reference, message);
}
public static T checkNotNull(T reference, String format, Object... args) {
return Objects.requireNonNull(reference, String.format(format, args));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy