[jOOQ/jOOQ#10420] Add Context.methodIf(Arg, boolean) for an "internal if" implementation
This commit is contained in:
parent
d50e8bd3f6
commit
a4b54b2436
@ -542,6 +542,12 @@ public interface Context<C extends Context<C>> extends Scope {
|
||||
@NotNull
|
||||
C paramType(ParamType paramType);
|
||||
|
||||
/**
|
||||
* Set the new context value for {@link #paramType()}, if a condition is true.
|
||||
*/
|
||||
@NotNull
|
||||
C paramTypeIf(ParamType paramType, boolean condition);
|
||||
|
||||
/**
|
||||
* The currently applied cast mode for bind values.
|
||||
*/
|
||||
@ -554,6 +560,12 @@ public interface Context<C extends Context<C>> extends Scope {
|
||||
@NotNull
|
||||
C castMode(CastMode mode);
|
||||
|
||||
/**
|
||||
* Set the new cast mode for {@link #castMode()}, if a condition is true.
|
||||
*/
|
||||
@NotNull
|
||||
C castModeIf(CastMode mode, boolean condition);
|
||||
|
||||
/**
|
||||
* Whether casting must be applied. The result follows this logic:
|
||||
* <table border="1">
|
||||
|
||||
@ -212,7 +212,7 @@ abstract class AbstractContext<C extends Context<C>> extends AbstractScope imple
|
||||
// Perform the actual visiting, or recurse into the replacement
|
||||
// -----------------------------------------------------------------
|
||||
QueryPart replacement = start(part);
|
||||
|
||||
|
||||
if (replacement != null) {
|
||||
QueryPartInternal internal = (QueryPartInternal) replacement;
|
||||
|
||||
@ -633,6 +633,14 @@ abstract class AbstractContext<C extends Context<C>> extends AbstractScope imple
|
||||
return (C) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final C paramTypeIf(ParamType p, boolean condition) {
|
||||
if (condition)
|
||||
paramType(p);
|
||||
|
||||
return (C) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean quote() {
|
||||
return quote;
|
||||
@ -687,6 +695,14 @@ abstract class AbstractContext<C extends Context<C>> extends AbstractScope imple
|
||||
return (C) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final C castModeIf(CastMode mode, boolean condition) {
|
||||
if (condition)
|
||||
castMode(mode);
|
||||
|
||||
return (C) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final Boolean cast() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user