Skip to content

Commit

Permalink
[#3748] Add public Routine T getValue(Parameter<T>) and setValue(Para…
Browse files Browse the repository at this point in the history
…meter<T>, T) methods
  • Loading branch information
lukaseder committed Mar 2, 2015
1 parent cd58f98 commit ab8b6a1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
40 changes: 31 additions & 9 deletions jOOQ/src/main/java/org/jooq/Routine.java
Expand Up @@ -89,6 +89,10 @@
*/
public interface Routine<T> extends QueryPart {

// -------------------------------------------------------------------------
// XXX: Meta information
// -------------------------------------------------------------------------

/**
* Get the routine schema
*/
Expand Down Expand Up @@ -143,15 +147,9 @@ public interface Routine<T> extends QueryPart {
*/
List<Parameter<?>> getParameters();

/**
* @return The routine's return value (if it is a function)
*/
T getReturnValue();

/**
* @return The routine's results (if available)
*/
List<Result<Record>> getResults();
// -------------------------------------------------------------------------
// XXX: Call API
// -------------------------------------------------------------------------

/**
* Execute the stored object using a {@link Configuration} object
Expand All @@ -166,4 +164,28 @@ public interface Routine<T> extends QueryPart {
* @throws DataAccessException if something went wrong executing the query
*/
int execute() throws DataAccessException;

// -------------------------------------------------------------------------
// XXX: Call data
// -------------------------------------------------------------------------

/**
* Set the routine's IN value for an IN parameter.
*/
<Z> void setValue(Parameter<Z> parameter, Z value);

/**
* @return The routine's OUT value for an OUT parameter.
*/
<Z> Z getValue(Parameter<Z> parameter);

/**
* @return The routine's return value (if it is a function)
*/
T getReturnValue();

/**
* @return The routine's results (if available)
*/
List<Result<Record>> getResults();
}
8 changes: 5 additions & 3 deletions jOOQ/src/main/java/org/jooq/impl/AbstractRoutine.java
Expand Up @@ -198,15 +198,16 @@ protected <X, Y> AbstractRoutine(String name, Schema schema, Package pkg, DataTy
// Initialise a routine call
// ------------------------------------------------------------------------

protected final void setNumber(Parameter<? extends Number> parameter, Number value) {
protected final <N extends Number> void setNumber(Parameter<N> parameter, Number value) {
setValue(parameter, Convert.convert(value, parameter.getType()));
}

protected final void setNumber(Parameter<? extends Number> parameter, Field<? extends Number> value) {
setField(parameter, value);
}

protected final void setValue(Parameter<?> parameter, Object value) {
@Override
public final <Z> void setValue(Parameter<Z> parameter, Z value) {
setField(parameter, val(value, parameter.getDataType()));
}

Expand Down Expand Up @@ -645,8 +646,9 @@ public final List<Result<Record>> getResults() {
return results;
}

@Override
@SuppressWarnings("unchecked")
protected final <Z> Z getValue(Parameter<Z> parameter) {
public final <Z> Z getValue(Parameter<Z> parameter) {
return (Z) outValues.get(parameter);
}

Expand Down

0 comments on commit ab8b6a1

Please sign in to comment.