org.op4j.functions
Class Get<T,R>

Object
  extended by org.op4j.functions.Function<T,R>
      extended by org.op4j.functions.Get<T,R>
All Implemented Interfaces:
IFunction<T,R>

public final class Get<T,R>
extends Function<T,R>

Function hub class for executing attribute getters in target objects.

Since:
1.0
Author:
Daniel Fernández

Method Summary
static
<R> Function<Object,R[]>
arrayOf(org.javaruntype.type.Type<R> resultType, String attributeName)
           Abbreviation for {attrOfArrayOf(Type, String).
static Function<Object,String[]> arrayOfString(String attributeName)
           Abbreviation for {attrOfArrayOfString(String).
static
<R> Function<Object,R>
attrOf(org.javaruntype.type.Type<R> resultType, String attributeName)
           Executes a getter (getX()) on the target object which returns R, being R the specified type.
static
<R> Function<Object,R[]>
attrOfArrayOf(org.javaruntype.type.Type<R> resultType, String attributeName)
           Executes a getter (getX()) on the target object which returns R[], being R the specified type.
static Function<Object,String[]> attrOfArrayOfString(String attributeName)
           Executes a getter (getX()) on the target object which returns String[].
static Function<Object,BigDecimal> attrOfBigDecimal(String attributeName)
           Executes a getter (getX()) on the target object which returns BigDecimal.
static Function<Object,BigInteger> attrOfBigInteger(String attributeName)
           Executes a getter (getX()) on the target object which returns BigInteger.
static Function<Object,Boolean> attrOfBoolean(String attributeName)
           Executes a getter (getX()) on the target object which returns Boolean.
static Function<Object,Byte> attrOfByte(String attributeName)
           Executes a getter (getX()) on the target object which returns Byte.
static Function<Object,Calendar> attrOfCalendar(String attributeName)
           Executes a getter (getX()) on the target object which returns Calendar.
static Function<Object,Character> attrOfCharacter(String attributeName)
           Executes a getter (getX()) on the target object which returns Character.
static Function<Object,Date> attrOfDate(String attributeName)
           Executes a getter (getX()) on the target object which returns Date.
static Function<Object,Double> attrOfDouble(String attributeName)
           Executes a getter (getX()) on the target object which returns Double.
static Function<Object,Float> attrOfFloat(String attributeName)
           Executes a getter (getX()) on the target object which returns Float.
static Function<Object,Integer> attrOfInteger(String attributeName)
           Executes a getter (getX()) on the target object which returns Integer.
static
<R> Function<Object,List<R>>
attrOfListOf(org.javaruntype.type.Type<R> resultType, String attributeName)
           Executes a getter (getX()) on the target object which returns List<R>, being R the specified type.
static Function<Object,List<String>> attrOfListOfString(String attributeName)
           Executes a getter (getX()) on the target object which returns List<String>.
static Function<Object,Long> attrOfLong(String attributeName)
           Executes a getter (getX()) on the target object which returns Long.
static Function<Object,Object> attrOfObject(String attributeName)
           Executes a getter (getX()) on the target object which returns Object.
static
<R> Function<Object,Set<R>>
attrOfSetOf(org.javaruntype.type.Type<R> resultType, String attributeName)
           Executes a getter (getX()) on the target object which returns Set<R>, being R the specified type.
static Function<Object,Set<String>> attrOfSetOfString(String attributeName)
           Executes a getter (getX()) on the target object which returns Set<String>.
static Function<Object,Short> attrOfShort(String attributeName)
           Executes a getter (getX()) on the target object which returns Short.
static Function<Object,String> attrOfString(String attributeName)
           Executes a getter (getX()) on the target object which returns String.
static Function<Object,Byte> b(String attributeName)
           Abbreviation for {attrOfByte(String).
static Function<Object,BigDecimal> bigDecimal(String attributeName)
           Abbreviation for {attrOfBigDecimal(String).
static Function<Object,BigInteger> bigInteger(String attributeName)
           Abbreviation for {attrOfBigInteger(String).
static Function<Object,Boolean> bool(String attributeName)
           Abbreviation for {attrOfBoolean(String).
static Function<Object,Character> c(String attributeName)
           Abbreviation for {attrOfCharacter(String).
static Function<Object,Calendar> calendar(String attributeName)
           Abbreviation for {attrOfCalendar(String).
static Function<Object,Double> d(String attributeName)
           Abbreviation for {attrOfDouble(String).
static Function<Object,Date> date(String attributeName)
           Abbreviation for {attrOfDate(String).
 R execute(T input, ExecCtx ctx)
           Executes the function on the current target object, which is passed as the input parameter.
static Function<Object,Float> f(String attributeName)
           Abbreviation for {attrOfFloat(String).
static Function<Object,Integer> i(String attributeName)
           Abbreviation for {attrOfInteger(String).
static Function<Object,Long> l(String attributeName)
           Abbreviation for {attrOfLong(String).
static
<R> Function<Object,List<R>>
listOf(org.javaruntype.type.Type<R> resultType, String attributeName)
           Abbreviation for {attrOfListOf(Type, String).
static Function<Object,List<String>> listOfString(String attributeName)
           Abbreviation for {attrOfListOfString(String).
static Function<Object,Object> obj(String attributeName)
           Abbreviation for {attrOfObject(String).
static
<R> Function<Object,R>
obj(org.javaruntype.type.Type<R> resultType, String attributeName)
           Abbreviation for {attrOf(Type, String).
static Function<Object,String> s(String attributeName)
           Abbreviation for {attrOfString(String).
static
<R> Function<Object,Set<R>>
setOf(org.javaruntype.type.Type<R> resultType, String attributeName)
           Abbreviation for {attrOfSetOf(Type, String).
static Function<Object,Set<String>> setOfString(String attributeName)
           Abbreviation for {attrOfSetOfString(String).
static Function<Object,Short> shr(String attributeName)
           Abbreviation for {attrOfShort(String).
 
Methods inherited from class org.op4j.functions.Function
execute
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

attrOfObject

public static Function<Object,Object> attrOfObject(String attributeName)

Executes a getter (getX()) on the target object which returns Object. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

obj

public static Function<Object,Object> obj(String attributeName)

Abbreviation for {attrOfObject(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOf

public static <R> Function<Object,R> attrOf(org.javaruntype.type.Type<R> resultType,
                                            String attributeName)

Executes a getter (getX()) on the target object which returns R, being R the specified type.

If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
resultType - the type of the attribute
attributeName - the name of the attribute
Returns:
the result of the method execution

obj

public static <R> Function<Object,R> obj(org.javaruntype.type.Type<R> resultType,
                                         String attributeName)

Abbreviation for {attrOf(Type, String).

Parameters:
resultType - the type of the attribute
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfBigInteger

public static Function<Object,BigInteger> attrOfBigInteger(String attributeName)

Executes a getter (getX()) on the target object which returns BigInteger. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

bigInteger

public static Function<Object,BigInteger> bigInteger(String attributeName)

Abbreviation for {attrOfBigInteger(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfBigDecimal

public static Function<Object,BigDecimal> attrOfBigDecimal(String attributeName)

Executes a getter (getX()) on the target object which returns BigDecimal. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

bigDecimal

public static Function<Object,BigDecimal> bigDecimal(String attributeName)

Abbreviation for {attrOfBigDecimal(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfBoolean

public static Function<Object,Boolean> attrOfBoolean(String attributeName)

Executes a getter (getX()) on the target object which returns Boolean. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

bool

public static Function<Object,Boolean> bool(String attributeName)

Abbreviation for {attrOfBoolean(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfByte

public static Function<Object,Byte> attrOfByte(String attributeName)

Executes a getter (getX()) on the target object which returns Byte. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

b

public static Function<Object,Byte> b(String attributeName)

Abbreviation for {attrOfByte(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfCharacter

public static Function<Object,Character> attrOfCharacter(String attributeName)

Executes a getter (getX()) on the target object which returns Character. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

c

public static Function<Object,Character> c(String attributeName)

Abbreviation for {attrOfCharacter(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfCalendar

public static Function<Object,Calendar> attrOfCalendar(String attributeName)

Executes a getter (getX()) on the target object which returns Calendar. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

calendar

public static Function<Object,Calendar> calendar(String attributeName)

Abbreviation for {attrOfCalendar(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfDate

public static Function<Object,Date> attrOfDate(String attributeName)

Executes a getter (getX()) on the target object which returns Date. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

date

public static Function<Object,Date> date(String attributeName)

Abbreviation for {attrOfDate(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfDouble

public static Function<Object,Double> attrOfDouble(String attributeName)

Executes a getter (getX()) on the target object which returns Double. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

d

public static Function<Object,Double> d(String attributeName)

Abbreviation for {attrOfDouble(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfFloat

public static Function<Object,Float> attrOfFloat(String attributeName)

Executes a getter (getX()) on the target object which returns Float. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

f

public static Function<Object,Float> f(String attributeName)

Abbreviation for {attrOfFloat(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfInteger

public static Function<Object,Integer> attrOfInteger(String attributeName)

Executes a getter (getX()) on the target object which returns Integer. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

i

public static Function<Object,Integer> i(String attributeName)

Abbreviation for {attrOfInteger(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfLong

public static Function<Object,Long> attrOfLong(String attributeName)

Executes a getter (getX()) on the target object which returns Long. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

l

public static Function<Object,Long> l(String attributeName)

Abbreviation for {attrOfLong(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfShort

public static Function<Object,Short> attrOfShort(String attributeName)

Executes a getter (getX()) on the target object which returns Short. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

shr

public static Function<Object,Short> shr(String attributeName)

Abbreviation for {attrOfShort(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfString

public static Function<Object,String> attrOfString(String attributeName)

Executes a getter (getX()) on the target object which returns String. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

s

public static Function<Object,String> s(String attributeName)

Abbreviation for {attrOfString(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfListOfString

public static Function<Object,List<String>> attrOfListOfString(String attributeName)

Executes a getter (getX()) on the target object which returns List<String>. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

listOfString

public static Function<Object,List<String>> listOfString(String attributeName)

Abbreviation for {attrOfListOfString(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfSetOfString

public static Function<Object,Set<String>> attrOfSetOfString(String attributeName)

Executes a getter (getX()) on the target object which returns Set<String>. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

setOfString

public static Function<Object,Set<String>> setOfString(String attributeName)

Abbreviation for {attrOfSetOfString(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfArrayOfString

public static Function<Object,String[]> attrOfArrayOfString(String attributeName)

Executes a getter (getX()) on the target object which returns String[]. If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution

arrayOfString

public static Function<Object,String[]> arrayOfString(String attributeName)

Abbreviation for {attrOfArrayOfString(String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfListOf

public static <R> Function<Object,List<R>> attrOfListOf(org.javaruntype.type.Type<R> resultType,
                                                        String attributeName)

Executes a getter (getX()) on the target object which returns List<R>, being R the specified type.

If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
resultType - the component type of the result list type.
attributeName - the name of the attribute
Returns:
the result of the method execution

listOf

public static <R> Function<Object,List<R>> listOf(org.javaruntype.type.Type<R> resultType,
                                                  String attributeName)

Abbreviation for {attrOfListOf(Type, String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfSetOf

public static <R> Function<Object,Set<R>> attrOfSetOf(org.javaruntype.type.Type<R> resultType,
                                                      String attributeName)

Executes a getter (getX()) on the target object which returns Set<R>, being R the specified type.

If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
resultType - the component type of the result set type.
attributeName - the name of the attribute
Returns:
the result of the method execution

setOf

public static <R> Function<Object,Set<R>> setOf(org.javaruntype.type.Type<R> resultType,
                                                String attributeName)

Abbreviation for {attrOfSetOf(Type, String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

attrOfArrayOf

public static <R> Function<Object,R[]> attrOfArrayOf(org.javaruntype.type.Type<R> resultType,
                                                     String attributeName)

Executes a getter (getX()) on the target object which returns R[], being R the specified type.

If the specified attribute is, for example, "name", the called method will be "getName()".

Parameters:
resultType - the component type of the result array type.
attributeName - the name of the attribute
Returns:
the result of the method execution

arrayOf

public static <R> Function<Object,R[]> arrayOf(org.javaruntype.type.Type<R> resultType,
                                               String attributeName)

Abbreviation for {attrOfArrayOf(Type, String).

Parameters:
attributeName - the name of the attribute
Returns:
the result of the method execution
Since:
1.1

execute

public R execute(T input,
                 ExecCtx ctx)
          throws Exception
Description copied from interface: IFunction

Executes the function on the current target object, which is passed as the input parameter. The ExecCtx parameter provides some metadata related to the execution, like the index in an iteration.

The execution of a function can throw any exception.

If you intend to call the execute method directly on any of your functions (outside an op4j expression), you might prefer using Function.execute(Object) instead.

Parameters:
input - the target object on which the function is to be executed
ctx - the context (metadata) for the function execution
Returns:
the result of executing the function
Throws:
Exception


Copyright © 2012 The OP4J team. All Rights Reserved.