/** * Returns an error to represent undefinedness in a computation. * * @return An error to represent undefinedness in a computation. */ public static Error undefined() { return error("undefined"); }
public static TypeTraitement fromCode(String code) { switch (code) { case "AS": return AccesSelectif; case "ET": return EnAttente; case "TR": return Transfert; case "VA": return ValidationAcquis; default: throw error(code + " cannot be associated with any existing TypeTraitement"); } } // getters for jsf
public PackageFileSystemObject<PrototypeEntry> setPath( RelativePath path ) { throw error( "Not applicable" ); } }
public PackageFileSystemObject<PrototypeEntry> withUnixFsObject( UnixFsObject object ) { throw error( "Not applicable" ); } }
public PackageFileSystemObject<PrototypeEntry> setPath( RelativePath path ) { throw error( "Not applicable" ); } }
public A reduceRight(final F<A, F<A, A>> aff) { throw error("Reduction of empty tree"); }
public A some() { throw error("some on None"); } }
/** * Represents a deconstruction failure that was non-exhaustive. * * @param c The type being deconstructed. * @return A deconstruction failure that was non-exhaustive. */ @SuppressWarnings("UnnecessaryFullyQualifiedName") public static <A> Error decons(final java.lang.Class<A> c) { return error("Deconstruction failure on type " + c); }
private Natural(final BigInteger i) { if (i.compareTo(BigInteger.ZERO) < 0) throw error("Natural less than zero"); value = i; }
/** * Represents a deconstruction failure that was non-exhaustive. * * @param a The value being deconstructed. * @param sa The rendering for the value being deconstructed. * @return A deconstruction failure that was non-exhaustive. */ public static <A> Error decons(final A a, final Show<A> sa) { return error("Deconstruction failure on type " + a.getClass() + " with value " + sa.show(a).toString()); }
/** * 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); }
/** * Returns the value of this projection or fails with the given error message. * * @param err The error message to fail with. * @return The value of this projection */ public B valueE(final F0<String> err) { if (e.isRight()) //noinspection CastToConcreteClass return ((Right<A, B>) e).b; else throw error(err.f()); }
public static <A> A someE( Option<A> option, String msg ) { if ( option.isSome() ) { return option.some(); } throw Bottom.error( msg ); }
/** * Returns an infinite-length stream of the given elements cycling. Fails on the empty stream. * * @param as The elements to cycle infinitely. This must not be empty. * @return An infinite-length stream of the given elements cycling. */ public static <A> Stream<A> cycle(final Stream<A> as) { if (as.isEmpty()) throw error("cycle on empty list"); else return as.append(() -> cycle(as)); }
/** * Returns the failing value, or throws an error if there is no failing value. * * @return the failing value, or throws an error if there is no failing value. */ public final E fail() { if (isFail()) return e.left().value(); else throw error("Validation: fail on success value"); }
/** * Returns the success value, or throws an error if there is no success value. * * @return the success value, or throws an error if there is no success value. */ public final T success() { if (isSuccess()) return e.right().value(); else throw error("Validation: success on fail value"); }
/** * 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()); }
/** * Takes the first 2 elements of the list and applies the function to them, * then applies the function to the result and the third element and so on. * * @param f The function to apply on each element of the list. * @return The final result after the left-fold reduction. */ public final A foldLeft1(final F2<A, A, A> f) { if (isEmpty()) throw error("Undefined: foldLeft1 on empty list"); return tail().foldLeft(f, head()); }
/** * Takes the first 2 elements of the stream and applies the function to them, * then applies the function to the result and the third element and so on. * * @param f The function to apply on each element of the stream. * @return The final result after the left-fold reduction. */ public final A foldLeft1(final F2<A, A, A> f) { if (isEmpty()) throw error("Undefined: foldLeft1 on empty list"); return tail()._1().foldLeft(f, head()); }
/** * @param parent A zipper focused on the closest, existing parent * @param node The node to insert */ public TreeZipper<PackageFileSystemObject<A>> addChild( TreeZipper<PackageFileSystemObject<A>> parent, Tree<PackageFileSystemObject<A>> node ) { // System.out.println( "Adding to " + parent.getLabel().object.path + ": " + node.root().object.path + " which is a " + node.root().object.getClass() ); if ( parent.getLabel().getUnixFsObject() instanceof Directory ) { return parent.insertDownFirst( node ); } throw error( "Parent has to be a directory, parent: " + parent.getLabel().getUnixFsObject().path ); }