com.almworks.jira.structure.util
Class La<T,R>

java.lang.Object
  extended by com.almworks.jira.structure.util.La<T,R>
All Implemented Interfaces:
com.atlassian.jira.util.Predicate<T>, com.google.common.base.Function<T,R>

public abstract class La<T,R>
extends Object
implements com.google.common.base.Function<T,R>, com.atlassian.jira.util.Predicate<T>

La is a utility generic-purpose class for functional expressions.

Author:
Igor Sereda

Nested Class Summary
static class La.ComparableComparator<B extends Comparable<B>>
           
static class La.LaComparator<A,B>
           
 
Constructor Summary
protected La()
           
protected La(Class<R> rClass)
          Use this constructor to have class-aware instance, which is needed only for few methods like array(java.util.Collection).
 
Method Summary
 boolean accepts(T value)
           
static
<T,R> La<T,R>
adapt(com.google.common.base.Function<T,R> f)
           
<C extends Collection<R>>
C
addTo(Collection<? extends T> from, C to, boolean acceptFalsy)
           
 La<T,Boolean> and(La<T,?> second)
           
<A> La<A,R>
apply(La<A,? extends T> f)
           
 R apply(T from)
           
 R[] array(Collection<? extends T> from)
           
 R[] array(Collection<? extends T> from, boolean acceptFalsy)
           
 List<R> arrayList(Collection<? extends T> from)
           
 List<R> arrayList(Collection<? extends T> from, boolean acceptFalsy)
           
 Comparator<T> comparator(Comparator<? super R> comparator)
           
static
<A,B extends Comparable<B>>
Comparator<A>
comparator(La<A,B> function)
           
static
<A,B,C> La<A,C>
compose(La<B,C> g, La<A,? extends B> f)
           
static
<T,R> La<T,R>
constant(R result)
           
 boolean evaluate(T input)
           
<D extends T>
List<D>
filter(Collection<D> collection)
           
<X extends T>
X
find(Collection<X> collection, R sample)
           
static
<T,R> La<T,R>
fromMap(Map<? super T,? extends R> map, Class<R> rClass)
           
 Map<R,T> hashMap(Collection<? extends T> collection)
           
<V> Map<R,V>
hashMap(Collection<? extends T> collection, La<T,V> valueFunction)
           
 Set<R> hashSet(Collection<? extends T> from)
           
static
<T> La<T,Boolean>
inCollection(Collection<T> collection)
           
 int indexOf(List<? extends T> list, R sample)
           
static
<T> La<T,Boolean>
instanceOf(Class<? extends T> instanceClass)
           
static
<T> La<T,Boolean>
isEqual(T value)
           
abstract  R la(T argument)
           
<V> Map<R,V>
linkedHashMap(Collection<? extends T> collection, La<T,V> valueFunction)
           
 Map<R,T> mapInto(Collection<? extends T> fromCollection, Map<R,T> toMap)
           
<V> Map<R,V>
mapInto(Collection<? extends T> fromCollection, Map<R,V> toMap, La<T,V> valueFunction)
           
 La<T,Boolean> not()
           
static
<T> La<T,Boolean>
notNull()
           
static
<T> La<T,T>
self()
           
<A> La<T,A>
supply(La<? super R,A> g)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.google.common.base.Function
equals
 

Constructor Detail

La

protected La()

La

protected La(Class<R> rClass)
Use this constructor to have class-aware instance, which is needed only for few methods like array(java.util.Collection).

Parameters:
rClass - the class of the result
Method Detail

la

public abstract R la(T argument)

adapt

@NotNull
public static <T,R> La<T,R> adapt(com.google.common.base.Function<T,R> f)

constant

@NotNull
public static <T,R> La<T,R> constant(R result)

isEqual

@NotNull
public static <T> La<T,Boolean> isEqual(@Nullable
                                                T value)

inCollection

@NotNull
public static <T> La<T,Boolean> inCollection(@Nullable
                                                     Collection<T> collection)

instanceOf

@NotNull
public static <T> La<T,Boolean> instanceOf(@Nullable
                                                   Class<? extends T> instanceClass)

compose

@NotNull
public static <A,B,C> La<A,C> compose(La<B,C> g,
                                              La<A,? extends B> f)

self

@NotNull
public static <T> La<T,T> self()

fromMap

@NotNull
public static <T,R> La<T,R> fromMap(Map<? super T,? extends R> map,
                                            Class<R> rClass)

apply

public final R apply(T from)
Specified by:
apply in interface com.google.common.base.Function<T,R>

evaluate

public boolean evaluate(T input)
Specified by:
evaluate in interface com.atlassian.jira.util.Predicate<T>

apply

@NotNull
public <A> La<A,R> apply(La<A,? extends T> f)

supply

@NotNull
public <A> La<T,A> supply(La<? super R,A> g)

filter

@NotNull
public <D extends T> List<D> filter(@Nullable
                                            Collection<D> collection)

accepts

public boolean accepts(T value)

hashSet

@NotNull
public Set<R> hashSet(@Nullable
                              Collection<? extends T> from)

arrayList

@NotNull
public List<R> arrayList(@Nullable
                                 Collection<? extends T> from)

arrayList

@NotNull
public List<R> arrayList(@Nullable
                                 Collection<? extends T> from,
                                 boolean acceptFalsy)

addTo

@NotNull
public <C extends Collection<R>> C addTo(@Nullable
                                                 Collection<? extends T> from,
                                                 @NotNull
                                                 C to,
                                                 boolean acceptFalsy)

array

@NotNull
public R[] array(@Nullable
                         Collection<? extends T> from)

array

@NotNull
public R[] array(@Nullable
                         Collection<? extends T> from,
                         boolean acceptFalsy)

mapInto

@NotNull
public Map<R,T> mapInto(@Nullable
                                Collection<? extends T> fromCollection,
                                @NotNull
                                Map<R,T> toMap)

mapInto

@NotNull
public <V> Map<R,V> mapInto(@Nullable
                                    Collection<? extends T> fromCollection,
                                    @NotNull
                                    Map<R,V> toMap,
                                    @NotNull
                                    La<T,V> valueFunction)

hashMap

@NotNull
public Map<R,T> hashMap(@Nullable
                                Collection<? extends T> collection)

hashMap

@NotNull
public <V> Map<R,V> hashMap(@Nullable
                                    Collection<? extends T> collection,
                                    @NotNull
                                    La<T,V> valueFunction)

linkedHashMap

@NotNull
public <V> Map<R,V> linkedHashMap(@Nullable
                                          Collection<? extends T> collection,
                                          @NotNull
                                          La<T,V> valueFunction)

indexOf

public int indexOf(@Nullable
                   List<? extends T> list,
                   R sample)

find

@Nullable
public <X extends T> X find(@Nullable
                                     Collection<X> collection,
                                     R sample)

not

@NotNull
public La<T,Boolean> not()

and

public La<T,Boolean> and(La<T,?> second)

comparator

public Comparator<T> comparator(Comparator<? super R> comparator)

comparator

public static <A,B extends Comparable<B>> Comparator<A> comparator(La<A,B> function)

notNull

public static <T> La<T,Boolean> notNull()


Copyright © 2013 ALMWorks. All Rights Reserved.