public static <T> T first(Comprehender<T> comp,Collection c){ Iterator<T> it = c.iterator(); if(it.hasNext()) return comp.of(it.next()); return comp.empty(); } }
public static <T> T first(Comprehender<T> comp,Collection c){ Iterator<T> it = c.iterator(); if(it.hasNext()) return comp.of(it.next()); return comp.empty(); } }
/** * Wrapper around filter * * @param t Monadic type being wrapped * @param p JDK Predicate to wrap * @return Result of call to <pre>{@code t.filter ( i -> p.test(i)); }</pre> */ default Object filter(T t, Predicate p){ return this.flatMap(t, d -> p.test(d) ? of(d) : empty()); }
/** * Wrapper around filter * * @param t Monadic type being wrapped * @param p JDK Predicate to wrap * @return Result of call to <pre>{@code t.filter ( i -> p.test(i)); }</pre> */ default Object filter(T t, Predicate p){ return this.flatMap(t, d -> p.test(d) ? of(d) : empty()); }
/** * Wrapper around filter * * @param t Monadic type being wrapped * @param p JDK Predicate to wrap * @return Result of call to <pre>{@code t.filter ( i -> p.test(i)); }</pre> */ default Object filter(T t, Predicate p){ return this.flatMap(t, d -> p.test(d) ? of(d) : empty()); }
if (((Optional) apply).isPresent()) return comp.of(((Optional) apply).get()); return comp.empty();
if (((Optional) apply).isPresent()) return comp.of(((Optional) apply).get()); return comp.empty();
if (((Optional) apply).isPresent()) return comp.of(((Optional) apply).get()); return comp.empty();
@Override public Object resolveForCrossTypeFlatMap(Comprehender comp,FeatureToggle apply){ return apply.matches( c -> c.isType((Enabled e)-> comp.of(e.get())).anyValues(), c-> c.isType( (Disabled d) -> comp.empty()).anyValues() ); }
@Override public Object resolveForCrossTypeFlatMap(Comprehender comp,FeatureToggle apply){ return apply.matches( c -> c.isType((Enabled e)-> comp.of(e.get())).anyValues(), c-> c.isType( (Disabled d) -> comp.empty()).anyValues() ); }
@SuppressWarnings("rawtypes") @Override public Object resolveForCrossTypeFlatMap(Comprehender comp,Try apply){ return apply.matches(c->c.isType( (Success s) -> comp.of(apply.get()) ).anyValues(), c->c.isType( (Failure f) -> comp.empty()).anyValues()); }
@SuppressWarnings("rawtypes") @Override public Object resolveForCrossTypeFlatMap(Comprehender comp,Try apply){ return apply.matches(c->c.isType( (Success s) -> comp.of(apply.get()) ).anyValues(), c->c.isType( (Failure f) -> comp.empty()).anyValues()); }
return (T)comprehender._1.empty();