com.iodesystems.fn.Fn Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fn Show documentation
Show all versions of fn Show documentation
Fn is a lazy Java Library that helps utilize some rudimentary functional concepts with more nounular
objects
package com.iodesystems.fn;
import com.iodesystems.fn.aspects.Exceptions;
import com.iodesystems.fn.aspects.Generators;
import com.iodesystems.fn.aspects.Groups;
import com.iodesystems.fn.aspects.Indexes;
import com.iodesystems.fn.aspects.Iterables;
import com.iodesystems.fn.aspects.Joins;
import com.iodesystems.fn.aspects.Maps;
import com.iodesystems.fn.aspects.Pairs;
import com.iodesystems.fn.aspects.Ranges;
import com.iodesystems.fn.aspects.Sets;
import com.iodesystems.fn.aspects.SizedIterables;
import com.iodesystems.fn.aspects.Strings;
import com.iodesystems.fn.aspects.Trees;
import com.iodesystems.fn.aspects.Values;
import com.iodesystems.fn.aspects.Wheres;
import com.iodesystems.fn.data.Combine;
import com.iodesystems.fn.data.From;
import com.iodesystems.fn.data.From2;
import com.iodesystems.fn.data.Generator;
import com.iodesystems.fn.data.Option;
import com.iodesystems.fn.data.Pair;
import com.iodesystems.fn.logic.Condition;
import com.iodesystems.fn.logic.Handler;
import com.iodesystems.fn.logic.Where;
import com.iodesystems.fn.thread.Async;
import com.iodesystems.fn.thread.Deferred;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
public class Fn extends Option {
public static final Fn> EMPTY = of(Iterables.empty());
private final Iterable contents;
public Fn(Iterable contents) {
this.contents = contents;
}
public static Pair pair(A a, B b) {
return Pair.of(a, b);
}
public static Fn of(A source, From getSize, From2 getItem) {
return of(SizedIterables.of(source, getSize, getItem));
}
public static Fn of(Iterable contents) {
if (contents instanceof Fn) {
return (Fn) contents;
}
return new Fn<>(contents);
}
public static Fn of(B contents) {
return of(Iterables.of(contents));
}
@SafeVarargs
public static Fn of(B... contents) {
return of(Iterables.of(contents));
}
public static Fn of(Enumeration contents) {
return of(Iterables.of(contents));
}
public static Fn of(B initial, From next) {
return of(Generators.of(initial, next));
}
public static Fn of(Generator contents) {
return of(Iterables.of(contents));
}
public static Condition condition(Where where) {
return Condition.of(where);
}
public static Condition isNot(A value) {
return Condition.isNotValue(value);
}
public static Condition is(A value) {
return Condition.isValue(value);
}
public static Fn ofPresent(Iterable