fj.data.Option.isSome()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中fj.data.Option.isSome()方法的一些代码示例,展示了Option.isSome()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option.isSome()方法的具体详情如下:
包路径:fj.data.Option
类名称:Option
方法名:isSome

Option.isSome介绍

[英]Returns true if this optional value has a value, false otherwise.
[中]如果此可选值有值,则返回true,否则返回false

代码示例

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns this optional value if there is one, otherwise, returns the argument optional value.
 *
 * @param o The optional value to return if this optional value has no value.
 * @return This optional value if there is one, otherwise, returns the argument optional value.
 */
public final Option<A> orElse(final Option<A> o) {
 return isSome() ? this : o;
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns true if this promise has been fulfilled.
 *
 * @return true if this promise has been fulfilled.
 */
public boolean isFulfilled() {
 return v.isSome();
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns the length of this optional value; 1 if there is a value, 0 otherwise.
 *
 * @return The length of this optional value; 1 if there is a value, 0 otherwise.
 */
public final int length() {
 return isSome() ? 1 : 0;
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns <code>true</code> if the predicate holds for at least one of the elements of this list,
 * <code>false</code> otherwise (<code>false</code> for the empty list).
 *
 * @param f The predicate function to test on the elements of this list.
 * @return <code>true</code> if the predicate holds for at least one of the elements of this
 *         list.
 */
public final boolean exists(final F<A, Boolean> f) {
 return find(f).isSome();
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Deletes the given element from this hash set.
 *
 * @param a The element to delete from this hash set.
 * @return <code>true</code> if this hash set contained the given element prior to deletion, <code>false</code>
 *         otherwise.
 */
public boolean delete(final A a) {
 return m.getDelete(a).isSome();
}

代码示例来源:origin: no.arktekk.unix/unix-common

public String getMavenVersion()
{
  String v = revision.isSome() ? version + "-" + revision.some() : version;
  if ( snapshot )
  {
    return v + "-SNAPSHOT";
  }
  return v;
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Performs a side-effect for the value of this optional value.
 *
 * @param f The side-effect to perform for the given element.
 */
public final void foreachDoEffect(final Effect1<A> f) {
 if (isSome())
  f.f(some());
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns <code>true</code> is this optional value has a value and the given predicate function
 * holds on that value, <code>false</code> otherwise.
 *
 * @param f the predicate function to test on the value of this optional value.
 * @return <code>true</code> is this optional value has a value and the given predicate function
 *         holds on that value, <code>false</code> otherwise.
 */
public final boolean exists(final F<A, Boolean> f) {
 return isSome() && f.f(some());
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns the value of this optional value or fails with the given message.
 *
 * @param message The message to fail with if this optional value has no value.
 * @return The value of this optional value if there there is one.
 */
public final A valueE(final String message) {
 if(isSome())
  return some();
 else
  throw error(message);
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns the value of this optional value or the given argument.
 *
 * @param a The argument to return if this optiona value has no value.
 * @return The value of this optional value or the given argument.
 */
public final A orSome(final F0<A> a) {
 return isSome() ? some() : a.f();
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns the value of this optional value or fails with the given message.
 *
 * @param message The message to fail with if this optional value has no value.
 * @return The value of this optional value if there there is one.
 */
public final A valueE(final F0<String> message) {
 if(isSome())
  return some();
 else
  throw error(message.f());
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Performs a reduction on this optional value using the given arguments.
 *
 * @param b The value to return if this optional value has no value.
 * @param f The function to apply to the value of this optional value.
 * @return A reduction on this optional value.
 */
public final <B> B option(final F0<B> b, final F<A, B> f) {
 return isSome() ? f.f(some()) : b.f();
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns an either projection of this optional value; the given argument in <code>Left</code> if
 * no value, or the value in <code>Right</code>.
 *
 * @param x The value to return in left if this optional value has no value.
 * @return An either projection of this optional value.
 */
public final <X> Either<X, A> toEither(final X x) {
 return isSome() ? Either.right(some()) : Either.left(x);
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Performs a side-effect for the value of this optional value.
 *
 * @param f The side-effect to perform for the given element.
 * @return The unit value.
 */
public final Unit foreach(final F<A, Unit> f) {
 return isSome() ? f.f(some()) : unit();
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns an array projection of this optional value.
 *
 * @return An array projection of this optional value.
 */
@SuppressWarnings("unchecked")
public final Array<A> toArray() {
 return isSome() ? Array.array(some()) : Array.empty();
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns an either projection of this optional value; the given argument in <code>Left</code> if
 * no value, or the value in <code>Right</code>.
 *
 * @param x The value to return in left if this optional value has no value.
 * @return An either projection of this optional value.
 */
public final <X> Either<X, A> toEither(final F0<X> x) {
 return isSome() ? Either.right(some()) : Either.left(x.f());
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns a list projection of this optional value.
 *
 * @return A list projection of this optional value.
 */
public final List<A> toList() {
 return isSome() ? cons(some(), List.nil()) : List.nil();
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Maps the given function across this optional value.
 *
 * @param f The function to map across this optional value.
 * @return A new optional value after the given function has been applied to its element.
 */
public final <B> Option<B> map(final F<A, B> f) {
 return isSome() ? some(f.f(some())) : Option.none();
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Filters elements from this optional value by returning only elements which produce
 * <code>true</code> when the given function is applied to them.
 *
 * @param f The predicate function to filter on.
 * @return A new optional value whose value matches the given predicate if it has one.
 */
public final Option<A> filter(final F<A, Boolean> f) {
 return isSome() ? f.f(some()) ? this : Option.none() : Option.none();
}

代码示例来源:origin: org.functionaljava/functionaljava

/**
 * Returns a stream projection of this optional value.
 *
 * @return A stream projection of this optional value.
 */
public final Stream<A> toStream() {
 return isSome() ? Stream.<A>nil().cons(some()) : Stream.nil();
}

相关文章