Relib Util - TroyHisted/relib GitHub Wiki

Provides the following utilities.

  • Console - Wrapper for System.out that automatically adds context information (file and line number).
  • DynaList - Implementation of an ArrayList that will dynamically grow if an index greater than the current size is requested.
  • Strings - Some basic string manipulation methods.
  • ToString - Reflective ToString builder.

Console

Starts each log with the time and the file name/line number. The Eclipse console will convert the file name to a link that will take the user to the code that generated the log. The arguments are converted to strings using ToString.

Console.log("hello world");
Console.err("goodbye world");
22:10:48.709 (TestMain.java:27):"hello world"
22:10:48.712 (TestMain.java:28):"goodbye world"

Automatically returns the argument to allow easier in-lining of logging.

public String generateGreeting(String name) {
    return Console.log("Hello" + name);
}

22:10:59.709 (TestMain.java:42):"Hello Jim"

DynaList

List<String> list = new DynaList<String>(String.class);
list.add(3, "Foo");

Strings

Strings.equals("foo", null); // false
Strings.isBlank("  "); // true
Strings.isNumeric("123"); // true
Strings.substring("Racecar", 1, 3); // ace
Strings.trim("   abc  "); // abc
Strings.trim("/some/file/path/", '/'); // some/file/path
Strings.trim(null); // null
Strings.capitalize("noun"); // Noun
Strings.defaultString(null, "bar"); // bar

ToString

Reflectively builds a String representation of the specified object.

public String toString() {
    return ToString.of(this).build();
}
⚠️ **GitHub.com Fallback** ⚠️