|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.abhinavsarkar.spelhelper.ImplicitMethods
public final class ImplicitMethods
Provides some implicit methods which can be invoked on the instances of class of the first parameter of the method inside a SpEL expression.
Constructor Summary | |
---|---|
ImplicitMethods()
|
Method Summary | ||
---|---|---|
static
|
distinct(List<? extends T> list)
Provides implicit method distinct on the List class. |
|
static
|
drop(List<T> list,
int n)
Provides implicit method drop on the List class. |
|
static
|
reversed(List<? extends T> list)
Provides implicit method reversed on the List class. |
|
static
|
sorted(List<? extends T> list)
Provides implicit method sorted on the List class. |
|
static
|
take(List<T> list,
int n)
Provides implicit method take on the List class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ImplicitMethods()
Method Detail |
---|
public static <T> Set<T> distinct(List<? extends T> list)
Provides implicit method distinct
on the List
class.
Example: "#list('a','b','a').distinct()" //should return List('a','b')
With implicit property support provided by SpelHelper
this can
also be written as:
"#list('a','b','a').distinct" //same output as earlier
T
- Type of the list's elements.list
- The list to call this method upon.
Set
containing the distinct items of the list.public static <T extends Comparable<? super T>> List<T> sorted(List<? extends T> list)
Provides implicit method sorted
on the List
class.
Example: "#list('c','b','a').sorted()" //should return List('a','b','c')
With implicit property support provided by SpelHelper
this can
also be written as:
"#list('c','b','a').sorted" //same output as earlier
T
- Type of the list's elements.list
- The list to call this method upon.
List
containing the sorted items
of the list.Collections.sort(List)
public static <T> List<T> reversed(List<? extends T> list)
Provides implicit method reversed
on the List
class.
Example: "#list('c','b','a').reversed()" //should return List('a','b','c')
With implicit property support provided by SpelHelper
this can
also be written as:
"#list('c','b','a').reversed" //same output as earlier
T
- Type of the list's elements.list
- The list to call this method upon.
List
containing the items of the
list in reverse order.Collections.reverse(List)
public static <T> List<T> take(List<T> list, int n)
Provides implicit method take
on the List
class.
Example: "#list('c','b','a').take(2)" //should return List('a','b')
T
- Type of the list's elements.list
- The list to call this method upon.n
- Number of items to take from the list.
List
containing the first n
items
of the list.public static <T> List<T> drop(List<T> list, int n)
Provides implicit method drop
on the List
class.
Example: "#list('c','b','a').drop(2)" //should return List('a')
T
- Type of the list's elements.list
- The list to call this method upon.n
- Number of items to drop from the list.
List
containing the items after the
first n
items of the list.
|
Code hosted at github | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |