org.tudalgo.algoutils.student.Student Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of algoutils-student Show documentation
Show all versions of algoutils-student Show documentation
Common utilities for the Fachgebiet Algorithmik of TU Darmstadt
The newest version!
package org.tudalgo.algoutils.student;
/**
* A utility class that contains some useful methods for student implementations.
*/
public final class Student {
private static boolean crashEnabled = true;
/**
* Sets if a call of {@link #crash(String...)} should crash the program.
*
* @param enabled if a call of {@link #crash(String...)} should crash the program
*/
public static void setCrashEnabled(boolean enabled) {
Student.crashEnabled = enabled;
}
/**
* A utility method that throws a {@code CrashException} with the specified message.
*
* @param messages the messages to hand to the exception. (will be concatenated with a newline)
* @param the type of the value to be returned.
* @return never returns anything (the method will always throw a {@code CrashException})
* @throws CrashException if the method is called.
* @see CrashException
*/
public static V crash(final String... messages) {
if (crashEnabled)
throw new CrashException(String.join("\n", messages));
return null;
}
}