/*
 * Copyright © 2013 Sebastian Hoß <mail@shoss.de>
 * This work is free. You can redistribute it and/or modify it under the
 * terms of the Do What The Fuck You Want To Public License, Version 2,
 * as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
 */
package com.github.sebhoss.nullanalysis;

import javax.annotation.Nullable;

/**
 * Utility classes which helps working with legacy (nullable) APIs.
 */
public final class Nullsafe {

    /**
     * @param reference
     *            A possible <code>null</code> reference.
     * @return Either the reference itself, or an {@link NullPointerException}, in case the reference was
     *         <code>null</code>.
     */
    public static <T> T nullsafe(@Nullable final T reference) {
        if (reference != null) {
            return reference;
        }

        throw new NullPointerException(); // NOPMD - we want to throw NPE here
    }

    /**
     * @param reference
     *            A possible <code>null</code> reference.
     * @param message
     *            The exception message to throw.
     * @return Either the reference itself, or an {@link NullPointerException}, in case the reference was
     *         <code>null</code>.
     */
    public static <T> T nullsafe(@Nullable final T reference, final String message) {
        if (reference != null) {
            return reference;
        }

        throw new NullPointerException(message); // NOPMD - we want to throw NPE here
    }

    private Nullsafe() {
        // utility class
    }

}

@@ -455,16 +455,73 @@
 safe %7B%0A%0A
+    private Nullsafe() %7B%0A        // utility class%0A    %7D%0A%0A
     /**%0A
@@ -775,32 +775,38 @@
  %3CT%3E T nullsafe(
+final 
 @Nullable final 
@@ -791,38 +791,32 @@
 final @Nullable 
-final 
 T reference) %7B%0A 
@@ -1317,16 +1317,22 @@
 ullsafe(
+final 
 @Nullabl
@@ -1333,22 +1333,16 @@
 ullable 
-final 
 T refere
@@ -1541,63 +1541,6 @@
  %7D%0A%0A
-    private Nullsafe() %7B%0A        // utility class%0A    %7D%0A%0A
 %7D%0A

Move annotation type information before final keyword