Skip to content

Latest commit

History

186 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

jlib

Frequently used code across all my Java projects inside one jar. Click here for maven/gradle/sbt/leinigen instructions (Java 8 or higher required).

Logging

The AL class (short for AutoPlug-Logger) contains static methods for logging with 4 levels: error, warn, info, and debug. All messages are pre-formatted and support ANSI colors.

It also allows registering listeners for specific or all messages and mirroring the console output to multiple files easily.

Json

The Json class contains static methods for retrieving Json from an URL and parsing it from/to a String. Under the hood it uses the Gson library (probably the fastest Json library for Java).

The abstract JsonFile class is optimal when you need json configurations for example. It makes serialisation easy and removes boilerplate, here is an example:

classMyConfigextendsJsonFile{
publicStringappName = "My cool app";
publicStringversion = 1;
publicPerson(){
//load() // Do NOT call load inside the constructor// This creates the file if not existing and fills it// with the default values above.super(newFile("my-config.json"));
version = 2;
save(); // To update "version" also in person.json (async).saveNow(); // Same as above, but blocks until finished.
}
}

Sorting

The QuickSort class implements the QuickSort algorithm and provides useful static methods to sort arrays and lists of any type (including JsonArrays). Usage example:

newQuickSort().sortJsonArray(arr, (thisEl, otherEl) -> {
intthisId = thisEl.el.getAsJsonObject().get("id").getAsInt();
intotherId = otherEl.el.getAsJsonObject().get("id").getAsInt();
returnInteger.compare(thisId, otherId);
});

Update finder

The Search class contains methods for finding assets/updates on Maven and Github.

UFDataIn/Out for enhanced Networking

Allows sending/receiving streams and files. Based on DataInput/OutputStream classes.

About

Frequently used code across all my Java projects inside one jar.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages