+ /**
+ * Return value and check whether specified value is {@code null} and if so throws exception. This method supports
+ * require default getter methods.
+ *
+ * @param value Value itself
+ * @param name Name of the value
+ * @return Non-null value
+ * @throws NoSuchElementException if value is {@code null}
+ */
+ public static <T> @NonNull T require(final @Nullable T value, final @NonNull String name) {
+ if (value == null) {
+ throw new NoSuchElementException("Value of " + name + " is not present");
+ }
+ return value;
+ }
+
+ /**
+ * A shortcut for {@code Preconditions.checkNotNull(value, "Key component \"%s\" must not be null", name)}.
+ *
+ * @param value Value itself
+ * @param name Name of the value
+ * @return Non-null value
+ * @throws NullPointerException if value is {@code null}
+ */
+ public static <T> @NonNull T requireKeyProp(final @Nullable T value, final @NonNull String name) {
+ if (value == null) {
+ throw new NullPointerException("Key component \"" + name + "\" may not be null");
+ }
+ return value;
+ }
+