Installation

Installing Hyper9 Common is a simple two step process:

1. Add the Hyper9 Maven Repository to your Maven settings file or to your project's POM file.

<repository>
    <id>maven.hyper9.com</id>
    <name>Hyper9 Maven Repository</name>
    <url>http://maven.hyper9.com/repo/</url>
    <layout>default</layout>
    <releases>
        <updatePolicy>never</updatePolicy>
        <checksumPolicy>fail</checksumPolicy>
    </releases>
    <snapshots>
        <updatePolicy>always</updatePolicy>
        <checksumPolicy>fail</checksumPolicy>
    </snapshots>
</repository>

2. List Hyper9 Common as a dependency in your project's POM file.

<dependency>
    <groupId>com.hyper9</groupId>
    <artifactId>hyper9-common</artifactId>
    <version>0.0.1</version>
    <type>jar</type>
    <scope>compile</scope>
</dependency>

And that's all there is to installing Hyper9 Common.

Usage

Hyper9 Common provides several utility classes to assist rapid development. A few of these classes include:

Utility Classes

  • BitMask - A utility class for working with bit masks.
  • Function - A generic callback functor.
  • HttpClient - A simple HTTP client.
  • AnnotationUtils - A utility class for working with annotations.
  • AES - A utility class for encrypting/decrypting text using the AES algorithm.
  • Base64 - A utility class for encoding/decoding text to/from Base-64 strings.
  • Crc16 - A utility class for computing CRC 16 hashes.
  • Hex - A utility class for encoding/decoding text to/from Hex-16 strings.
  • MD5 - A utility class for computing MD5 hashes.
  • ListUtils - A utility class for working with lists.
  • MathUtils - A utility class for working with arithmetic.
  • ThrowableUtils - A utility class for working with Throwables.

Annotations

Hyper9 Common defines two Java 6 annotations.

SerializedInterface

SerializedInterface is an annotation that marks an interface as the type to represent a serialized object with. For example:

@SerializedInterface
public interface MyInterface extends Bean
{
    ...
}

public class MyClass implements MyInterface
{
    ...
}

...
  
MyClass mc = new MyClass();
System.out.println(mc.toString());

Because 'MyClass' implements 'MyInterface' which in turn is a 'Bean', and because 'MyInterface' is decorated with the 'SerialzedInterface' annotation, when the object is printed to stdout (JSON by default) it will look like:

{
  type: "MyInterface"
  ...
}

Transient

The Transient annotation is used to denote bean reader methods that should not be serialized along with the rest of the bean.