package net.ssehub.kernel_haven.util.null_checks;

/**
 * Contains helper methods for {@link NonNull} and {@link Nullable} annotations. These are useful when static analysis
 * tools are used. 
 * 
 * @author Adam
 */
public class NullHelpers {

    /**
     * Don't allow any instances.
     */
    public NullHelpers() {
    }
    
    /**
     * Converts a {@link Nullable} (or undefined) value to a {@link NonNull} one. This method should only be called,
     * if the caller is sure that the value must be {@link NonNull}.
     * 
     * @param value The value that should actually be {@link NonNull}.
     * @param msg An error message for the assertion if the value is <code>null</code>.
     * 
     * @return The same value, with a {@link NonNull} annotation.
     */
    public static @NonNull <T> T assertNonNull(@Nullable T value, @Nullable String msg) {
        if (value == null) {
            throw new AssertionError(msg);
        }
        return value;
    }
    
    /**
     * Converts a {@link Nullable} (or undefined) value to a {@link NonNull} one. This method should only be called,
     * if the caller is sure that the value must be {@link NonNull}.
     * 
     * @param value The value that should actually be {@link NonNull}.
     * 
     * @return The same value, with a {@link NonNull} annotation.
     */
    public static @NonNull <T> T assertNonNull(@Nullable T value) {
        if (value == null) {
            throw new AssertionError("Supplied value is null, but was expected not null");
        }
        return value;
    }
    
}

@@ -754,32 +754,105 @@
 ll%7D annotation.%0A
+     * %0A     * @throws AssertionError If the value is %3Ccode%3Enull%3C/code%3E.%0A
      */%0A    publ
@@ -872,33 +872,27 @@
 nNull %3CT%3E T 
-assertNon
+not
 Null(@Nullab
@@ -924,16 +924,38 @@
 ing msg)
+ throws AssertionError
  %7B%0A     
@@ -1407,24 +1407,97 @@
 annotation.%0A
+     * %0A     * @throws AssertionError If the value is %3Ccode%3Enull%3C/code%3E.%0A
      */%0A    
@@ -1529,17 +1529,11 @@
 %3E T 
-assertNon
+not
 Null
@@ -1551,16 +1551,38 @@
 T value)
+ throws AssertionError
  %7B%0A     
@@ -1739,10 +1739,352 @@
  %7D%0A    %0A
+    /**%0A     * Declares an unmarked value as %7B@link Nullable%7D. This may be needed for some calls of methods from libraries.%0A     * %0A     * @param value The value that may be %3Ccode%3Enull%3C/code%3E.%0A     * @return The %7B@link Nullable%7D annotated value.%0A     */%0A    public static @Nullable %3CT%3E T maybeNull(T value) %7B%0A        return value;%0A    %7D%0A    %0A
 %7D%0A

Add maybeNull() to NullHelpers. Rename assertNonNull() -> notNull()