/**
 * Jooby https://jooby.io
 * Apache License Version 2.0 https://jooby.io/LICENSE.txt
 * Copyright 2014 Edgar Espina
 */
package io.jooby.exception;

import javax.annotation.Nonnull;

/**
 * Missing exception. Used when a required attribute/value is missing.
 *
 * @since 2.0.0
 * @author edgar
 */
public class MissingValueException extends BadRequestException {
  private final String name;

  /**
   * Creates a missing exception.
   *
   * @param name Parameter/attribute name.
   */
  public MissingValueException(@Nonnull String name) {
    super("Missing value: '" + name + "'");
    this.name = name;
  }

  /**
   * Parameter/attribute name.
   *
   * @return Parameter/attribute name.
   */
  public String getName() {
    return name;
  }

  public static <T> T requireNonNull(String name, T value)  {
    if (value == null) {
      throw new MissingValueException(name);
    }
    return value;
  }
}

@@ -178,16 +178,50 @@
 Nonnull;
+%0Aimport javax.annotation.Nullable;
 %0A%0A/**%0A *
@@ -781,16 +781,246 @@
 e;%0A  %7D%0A%0A
+  /**%0A   * Check if the given value is null and throw a %7B@link MissingValueException%7D exception.%0A   *%0A   * @param name Attribute's name.%0A   * @param value Value to check.%0A   * @param %3CT%3E Value type.%0A   * @return Input value%0A   */%0A
   public
@@ -1048,16 +1048,25 @@
 NonNull(
+@Nonnull 
 String n
@@ -1069,16 +1069,26 @@
 ng name,
+ @Nullable
  T value

document MissingValueException.requireNonNull