
javarepl.console.ConsoleLog Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javarepl Show documentation
Show all versions of javarepl Show documentation
Java REPL is a simple Read-Eval-Print-Loop for Java language.
package javarepl.console;
import static javarepl.console.ConsoleLog.Type.*;
public class ConsoleLog {
public static enum Type {
INFO, SUCCESS, ERROR
}
private final Type type;
private final String message;
private ConsoleLog(Type type, String message) {
this.type = type;
this.message = message;
}
public static ConsoleLog success(String message) {
return consoleLog(SUCCESS, message);
}
public static ConsoleLog error(String message) {
return consoleLog(ERROR, message);
}
public static ConsoleLog info(String message) {
return consoleLog(INFO, message);
}
public static ConsoleLog consoleLog(ConsoleLog.Type type, String message) {
return new ConsoleLog(type, message);
}
public Type type() {
return type;
}
public String message() {
return message;
}
@Override
public String toString() {
return type + " " + message;
}
@Override
public int hashCode() {
return (type != null ? type.hashCode() : 0) +
(message != null ? message.hashCode() : 0);
}
@Override
public boolean equals(Object other) {
return other instanceof ConsoleLog &&
(type != null && type.equals(((ConsoleLog) other).type)) &&
(message != null && message.equals(((ConsoleLog) other).message));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy