Apply the provided mapping operator to the {@code optional} if a value is present,
and return an {@code OptionalDouble} describing the result.

@param optional the optional
@param operator the operator
@return an optional
191436
public static @NonNull OptionalDouble map(final @NonNull OptionalDouble optional, final @NonNull DoubleUnaryOperator operator) {
    requireNonNull(operator, "operator");
    return optional.isPresent() ? OptionalDouble.of(operator.applyAsDouble(optional.getAsDouble())) : OptionalDouble.empty();
  }
420695
public static String operatorToString(int op) {
        String result = operatorNames.get(op);
        if (result == null)
            throw new IllegalArgumentException("Invalid operator: " + op);
        return result;
    }
563767
public static <T> @NonNull Optional<T> cast(final @Nullable Object object, final @NonNull Class<T> type) {
    return type.isInstance(object) ? Optional.of((T) object) : Optional.empty();
  }
327130
public static Expression map(String operator, Val<Expression> arg, QueryExprMeta parent) {
        if (parent == null) {
            throw new QuerySyntaxException(Messages.get("dsl.arguments.error5", operator));
        } else if (!parent.operator().equals("option")) {
            throw new QuerySyntaxException(Messages.get("dsl.arguments.error6", operator, "option"));
        }
        return MapExpression.of(operator, arg);
    }
215640
public static <A> Maybe<A> fromOptional(Optional<? extends A> optional) {
        return optional.map(Maybe::<A>just).orElse(Maybe.nothing());
    }
1256565
public static <T> @NonNull Optional<T> cast(final @NonNull Optional<?> optional, final @NonNull Class<T> type) {
    // not necessary to re-wrap, we can just cast
    return isInstance(optional, type) ? (Optional<T>) optional : Optional.empty();
  }
1171790
public static <K,V> Optional<V> getOpt(Map<K,V> map, K key) {
        return Optional.ofNullable(map.get(key));
    }
1237653
public static Expression having(String operator, Val<Expression>[] args) {
        if (args.length > 0) {
            return HavingExpression.of(transformArgsToList(operator, args));
        }
        throw new QuerySyntaxException(Messages.get("dsl.arguments.error0", operator));
    }
1134169
public @NotNull <T> Optional<T> findOptional(@NotNull Class<T> cl, @NotNull SqlQuery query) {
        return executeQuery(rowMapperForClass(cl).optional(), query);
    }
534687
static <T> Optional<Equivalence.Wrapper<T>> wrapOptionalInEquivalence(
      Equivalence<T> equivalence, Optional<T> optional) {
    return optional.isPresent()
        ? Optional.of(equivalence.wrap(optional.get()))
        : Optional.<Equivalence.Wrapper<T>>absent();
  }
1351870
public <X> DataSet<X> runOperation(CustomUnaryOperation<T, X> operation) {
		Validate.notNull(operation, "The custom operator must not be null.");
		operation.setInput(this);
		return operation.createResult();
	}
298041
@Pure
	@Inline(value="$3.$4of($1, $2)", imported=Pair.class)
	public static <A, B> Pair<A, B> operator_mappedTo(A a, B b) {
		return Pair.of(a, b);
	}
164499
public static Function<? super ReactiveSeq<Double>, ? extends ReactiveSeq<Double>> mapDoubles(DoubleUnaryOperator b){

        return a->a.doubles(i->i,s->s.map(b));
    }
1232801
public static <E> Optional<E> maybeOne(Iterator<E> iterator) {
        return new MaybeOneElement<E>().apply(iterator);
    }
585773
public static function doUnaryOperation($operator, &$value)
    {
        if (self::$unaryOperations === null) {
            self::$unaryOperations = [
                    self::BITWISE_NOT   => function (&$i) { return ~$i; },
                    self::NOT           => function (&$i) { return !$i; },
                    self::INCREMENT     => function (&$i) { return $i++; },
                    self::DECREMENT     => function (&$i) { return $i--; },
                    self::PRE_INCREMENT => function (&$i) { return ++$i; },
                    self::PRE_DECREMENT => function (&$i) { return --$i; },
                    self::NEGATION      => function (&$i) { return -$i; },
                    self::PLUS          => function (&$i) { return +$i; },
            ];
        }

        if (!isset(self::$unaryOperations[$operator])) {
            throw new PinqException('Unary operator \'%s\' is not supported', $operator);
        }

        $operation = self::$unaryOperations[$operator];

        return $operation($value);
    }
571522
@SuppressWarnings("unchecked")
	public <T extends Operator> T geInstance(Opcode opcode) {
		Operator operator = this.operators.get(opcode);
		if (operator == null) {
			throw new TemplateException("Operator |%s| is not implemented.", opcode);
		}
		return (T) operator;
	}
275379
public static <T extends Enum<T>> EnumOperation<T> enumOperation(Class<? extends T> type, Operator operator,
                                                                     Expression<?>... args) {
        return new EnumOperation<T>(type, operator, args);
    }