[#2438] Add ParamType Param.paramType() to indicate whether a parameter is INDEXED, NAMED, INLINED

This commit is contained in:
lukaseder 2016-03-07 15:32:02 +01:00
parent 1e714a567c
commit 23b5f7cf8a
2 changed files with 19 additions and 0 deletions

View File

@ -40,6 +40,7 @@
*/
package org.jooq;
import org.jooq.conf.ParamType;
import org.jooq.exception.DataTypeException;
import org.jooq.impl.DSL;
import org.jooq.tools.Convert;
@ -119,4 +120,9 @@ public interface Param<T> extends Field<T> {
* A flag on the bind value to force it to be inlined in rendered SQL
*/
boolean isInline();
/**
* The parameter type.
*/
ParamType getParamType();
}

View File

@ -42,7 +42,9 @@ package org.jooq.impl;
import static org.jooq.Clause.FIELD;
import static org.jooq.Clause.FIELD_VALUE;
import static org.jooq.conf.ParamType.INDEXED;
import static org.jooq.conf.ParamType.INLINED;
import static org.jooq.conf.ParamType.NAMED;
import static org.jooq.conf.ParamType.NAMED_OR_INLINED;
// ...
@ -51,6 +53,7 @@ import org.jooq.Context;
import org.jooq.DataType;
import org.jooq.Param;
import org.jooq.UDTRecord;
import org.jooq.conf.ParamType;
import org.jooq.tools.StringUtils;
/**
@ -157,4 +160,14 @@ abstract class AbstractParam<T> extends AbstractField<T> implements Param<T> {
|| (context.paramType() == INLINED)
|| (context.paramType() == NAMED_OR_INLINED && StringUtils.isBlank(paramName));
}
@Override
public final ParamType getParamType() {
return inline
? INLINED
: StringUtils.isBlank(paramName)
? INDEXED
: NAMED
;
}
}