Konloch Software

Constants

Published 02/20/2023 Updated 02/26/2023

Constants is a very small zero dependency Java library packed with constants.

What Does It Do?

  • Small Java Library that provides static variables for dealing with Java Integers.
  • This library leverages the fact that constant expressions in Java turn into static numbers rather than being numerically expressed.
  • Example API Usage:
    • MS.MILLISECOND, MS.SECOND, MS.MINUTE, MS.HOUR, MS.DAY, MS.WEEK, MS.MONTH, MS.YEAR
    • NS.NANOSECOND, NS.MILLISECOND, NS.SECOND, NS.MINUTE, NS.HOUR, NS.DAY, NS.WEEK, NS.MONTH, NS.YEAR
    • INT.ONE, INT.TEN, INT.HUNDRED, INT.THOUSAND, INT.TEN_THOUSAND, INT.HUNDRED_THOUSAND, INT.MILLION
    • LONG.ONE, LONG.TEN, LONG.HUNDRED, LONG.THOUSAND, LONG.TEN_THOUSAND, LONG.HUNDRED_THOUSAND, LONG.MILLION

Links

Requirements

  • Java 8 or greater

How To Integrate as a Dependency

Add the following to your pom.xml as a maven dependency, or just download the latest release and import it with your IDE.

<dependency>
	<groupId>com.konloch</groupId>
	<artifactId>Constants</artifactId>
	<version>1.1.0</version>
</dependency>

How To Use

There are four main constant categories, Milliseconds, Nanoseconds, Integer and Long.

This library leverages the fact that constant expressions in Java turn into static numbers rather than being numerically expressed.

So on a bytecode level when compiled, x = 5 * MS.HOUR turns into x = 18000000. This makes using the constants in this library extremely performant.

Milliseconds are under MS, Nanoseconds are under NS, Integer is under INT and Long is under LONG.

Latest Updates

Constants v1.1.0

This is the second public release of the library, it has been heavily tested but please feel free to report any issues found.

To add it as a…

Read More

Constants v1.0.0

This is the first public release of the library, it has been heavily tested but please feel free to report any issues found.

To add it as a…

Read More