/** * Forces a get of the image. */ @Override public SingleImage getImage(int index, Supplier<String> custom_name) { initializeIfNeeded(); if (guiImages[index] == null) { String str_custom_name = custom_name != null ? custom_name.get() : null; if(str_custom_name == null) str_custom_name = ""; loadGuiImage(index, str_custom_name+file_name+"-G"+index); } return guiImages[index]; }
T_SPLITR get() { if (s == null) { s = supplier.get(); } return s; }
/** * Called before advancing to set up spliterator, if needed. */ final void init() { if (spliterator == null) { spliterator = spliteratorSupplier.get(); spliteratorSupplier = null; } }
T_SPLITR get() { if (s == null) { s = supplier.get(); } return s; }
/** * Called before advancing to set up spliterator, if needed. */ final void init() { if (spliterator == null) { spliterator = spliteratorSupplier.get(); spliteratorSupplier = null; } }
/** * If a value is present, returns the value, otherwise returns the result * produced by the supplying function. * * @param supplier the supplying function that produces a value to be returned * @return the value, if present, otherwise the result produced by the * supplying function * @throws NullPointerException if value is not present and the supplying * function is {@code null} */ public T orElseGet(Supplier<? extends T> supplier) { return value != null ? value : supplier.get(); }
/** * If a value is present, returns the value, otherwise returns the result * produced by the supplying function. * * @param supplier the supplying function that produces a value to be returned * @return the value, if present, otherwise the result produced by the * supplying function * @throws NullPointerException if value is not present and the supplying * function is {@code null} */ public T orElseGet(Supplier<? extends T> supplier) { return value != null ? value : supplier.get(); }
/** * Forces a get of the image. */ @Override public SingleImage getImage(int index, Supplier<String> custom_name) { initializeIfNeeded(); if (landscapeImages[index] == null) { String str_custom_name = custom_name != null ? custom_name.get() : null; if(str_custom_name == null) str_custom_name = ""; loadLandscapeImage(index, str_custom_name+file_name+"-L"+index); } return landscapeImages[index]; }
/** * If a value is present, returns the value, otherwise throws an exception * produced by the exception supplying function. * * <p><b>API Note:</b><br> * A method reference to the exception constructor with an empty argument * list can be used as the supplier. For example, * {@code IllegalStateException::new} * * @param <X> Type of the exception to be thrown * @param exceptionSupplier the supplying function that produces an * exception to be thrown * @return the value, if present * @throws X if no value is present * @throws NullPointerException if no value is present and the exception * supplying function is {@code null} */ public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X { if (value != null) { return value; } else { throw exceptionSupplier.get(); } }
/** * If a value is present, returns the value, otherwise throws an exception * produced by the exception supplying function. * * <p><b>API Note:</b><br> * A method reference to the exception constructor with an empty argument * list can be used as the supplier. For example, * {@code IllegalStateException::new} * * @param <X> Type of the exception to be thrown * @param exceptionSupplier the supplying function that produces an * exception to be thrown * @return the value, if present * @throws X if no value is present * @throws NullPointerException if no value is present and the exception * supplying function is {@code null} */ public <X extends Throwable> long orElseThrow(Supplier<? extends X> exceptionSupplier) throws X { if (isPresent) { return value; } else { throw exceptionSupplier.get(); } }
/** * If a value is present, returns the value, otherwise throws an exception * produced by the exception supplying function. * * <p><b>API Note:</b><br> * A method reference to the exception constructor with an empty argument * list can be used as the supplier. For example, * {@code IllegalStateException::new} * * @param <X> Type of the exception to be thrown * @param exceptionSupplier the supplying function that produces an * exception to be thrown * @return the value, if present * @throws X if no value is present * @throws NullPointerException if no value is present and the exception * supplying function is {@code null} */ public <X extends Throwable> int orElseThrow(Supplier<? extends X> exceptionSupplier) throws X { if (isPresent) { return value; } else { throw exceptionSupplier.get(); } }
/** * If a value is present, returns the value, otherwise throws an exception * produced by the exception supplying function. * * <p><b>API Note:</b><br> * A method reference to the exception constructor with an empty argument * list can be used as the supplier. For example, * {@code IllegalStateException::new} * * @param <X> Type of the exception to be thrown * @param exceptionSupplier the supplying function that produces an * exception to be thrown * @return the value, if present * @throws X if no value is present * @throws NullPointerException if no value is present and the exception * supplying function is {@code null} */ public <X extends Throwable> int orElseThrow(Supplier<? extends X> exceptionSupplier) throws X { if (isPresent) { return value; } else { throw exceptionSupplier.get(); } }
/** * If a value is present, returns the value, otherwise throws an exception * produced by the exception supplying function. * * <p><b>API Note:</b><br> * A method reference to the exception constructor with an empty argument * list can be used as the supplier. For example, * {@code IllegalStateException::new} * * @param <X> Type of the exception to be thrown * @param exceptionSupplier the supplying function that produces an * exception to be thrown * @return the value, if present * @throws X if no value is present * @throws NullPointerException if no value is present and the exception * supplying function is {@code null} */ public <X extends Throwable> double orElseThrow(Supplier<? extends X> exceptionSupplier) throws X { if (isPresent) { return value; } else { throw exceptionSupplier.get(); } }
/** * If a value is present, returns the value, otherwise throws an exception * produced by the exception supplying function. * * <p><b>API Note:</b><br> * A method reference to the exception constructor with an empty argument * list can be used as the supplier. For example, * {@code IllegalStateException::new} * * @param <X> Type of the exception to be thrown * @param exceptionSupplier the supplying function that produces an * exception to be thrown * @return the value, if present * @throws X if no value is present * @throws NullPointerException if no value is present and the exception * supplying function is {@code null} */ public <X extends Throwable> double orElseThrow(Supplier<? extends X> exceptionSupplier) throws X { if (isPresent) { return value; } else { throw exceptionSupplier.get(); } }
/** * If a value is present, returns the value, otherwise throws an exception * produced by the exception supplying function. * * <p><b>API Note:</b><br> * A method reference to the exception constructor with an empty argument * list can be used as the supplier. For example, * {@code IllegalStateException::new} * * @param <X> Type of the exception to be thrown * @param exceptionSupplier the supplying function that produces an * exception to be thrown * @return the value, if present * @throws X if no value is present * @throws NullPointerException if no value is present and the exception * supplying function is {@code null} */ public <X extends Throwable> long orElseThrow(Supplier<? extends X> exceptionSupplier) throws X { if (isPresent) { return value; } else { throw exceptionSupplier.get(); } }
/** * If a value is present, returns the value, otherwise throws an exception * produced by the exception supplying function. * * <p><b>API Note:</b><br> * A method reference to the exception constructor with an empty argument * list can be used as the supplier. For example, * {@code IllegalStateException::new} * * @param <X> Type of the exception to be thrown * @param exceptionSupplier the supplying function that produces an * exception to be thrown * @return the value, if present * @throws X if no value is present * @throws NullPointerException if no value is present and the exception * supplying function is {@code null} */ public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X { if (value != null) { return value; } else { throw exceptionSupplier.get(); } }
@Override public Action getAction() { if (selectedProvider == null || mapPositionProvider == null) { return null; } EMaterialType selected = selectedProvider.get(); ShortPoint2D mapPosition = mapPositionProvider.get(); if (selected == null || mapPosition == null) { return null; } return new SetAcceptedStockMaterialAction(mapPosition, selected, accept, local); }
/** * Checks that the specified object reference is not {@code null} and * throws a customized {@link NullPointerException} if it is. * * <p>Unlike the method {@link #requireNonNull(Object, String)}, * this method allows creation of the message to be deferred until * after the null check is made. While this may confer a * performance advantage in the non-null case, when deciding to * call this method care should be taken that the costs of * creating the message supplier are less than the cost of just * creating the string message directly. * * @param obj the object reference to check for nullity * @param messageSupplier supplier of the detail message to be * used in the event that a {@code NullPointerException} is thrown * @param <T> the type of the reference * @return {@code obj} if not {@code null} * @throws NullPointerException if {@code obj} is {@code null} * @since 1.8 */ public static <T> T requireNonNull(T obj, Supplier<String> messageSupplier) { if (obj == null) throw new NullPointerException(messageSupplier == null ? null : messageSupplier.get()); return obj; }
/** * Checks that the specified object reference is not {@code null} and * throws a customized {@link NullPointerException} if it is. * * <p>Unlike the method {@link #requireNonNull(Object, String)}, * this method allows creation of the message to be deferred until * after the null check is made. While this may confer a * performance advantage in the non-null case, when deciding to * call this method care should be taken that the costs of * creating the message supplier are less than the cost of just * creating the string message directly. * * @param obj the object reference to check for nullity * @param messageSupplier supplier of the detail message to be * used in the event that a {@code NullPointerException} is thrown * @param <T> the type of the reference * @return {@code obj} if not {@code null} * @throws NullPointerException if {@code obj} is {@code null} * @since 1.8 */ public static <T> T requireNonNull(T obj, Supplier<String> messageSupplier) { if (obj == null) throw new NullPointerException(messageSupplier == null ? null : messageSupplier.get()); return obj; }
private String getOrDefault(String key, Supplier<String> defaultProvider) { String value = get(key); return value != null ? value : defaultProvider.get(); }