-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from oneteme/release-4.1.1
Release 4.1.1
- Loading branch information
Showing
137 changed files
with
5,093 additions
and
2,810 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
src/main/java/org/usf/jquery/core/AggregationFunction.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.usf.jquery.core; | ||
|
||
import static org.usf.jquery.core.JDBCType.typeOf; | ||
import static org.usf.jquery.core.Validation.requireAtLeastNArgs; | ||
|
||
import java.util.function.Function; | ||
|
||
/** | ||
* | ||
* @author u$f | ||
* | ||
*/ | ||
interface ArgTypeRef extends Function<Object[], JDBCType> { | ||
|
||
static ArgTypeRef firstArgJdbcType() { | ||
return arr-> typeOf(requireAtLeastNArgs(1, arr, | ||
()-> "ArgTypeRef function")[0]).orElse(null); // not sure | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.usf.jquery.core; | ||
|
||
import static org.usf.jquery.core.Validation.requireNArgs; | ||
|
||
/** | ||
* | ||
* @author u$f | ||
* | ||
*/ | ||
@FunctionalInterface | ||
interface ArithmeticOperator extends Operator { | ||
|
||
@Override | ||
default String sql(QueryParameterBuilder builder, Object[] args) { | ||
requireNArgs(2, args, ArithmeticOperator.class::getSimpleName); | ||
return "(" + builder.appendLiteral(args[0]) + id() + builder.appendLiteral(args[1]) + ")"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/org/usf/jquery/core/BadArgumentException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.usf.jquery.core; | ||
|
||
import static org.usf.jquery.core.Utils.joinArray; | ||
|
||
/** | ||
* | ||
* @author u$f | ||
* | ||
*/ | ||
@SuppressWarnings("serial") | ||
public final class BadArgumentException extends JQueryException { | ||
|
||
public BadArgumentException(String message) { | ||
super(message); | ||
} | ||
|
||
public BadArgumentException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public static BadArgumentException badArgumentTypeException(JavaType[] types, Object actual) { | ||
String type = actual instanceof DBColumn c ? ":"+ c.getType() : ""; | ||
return new BadArgumentException(formatMessage("bad argument type", joinArray("|", types), actual + type)); | ||
} | ||
|
||
public static BadArgumentException badArgumentCountException(int count, int actual) { | ||
return new BadArgumentException(formatMessage("bad argument count", count, actual)); | ||
} | ||
|
||
public static BadArgumentException badArgumentsException(String exp, String actual, Exception e) { | ||
return new BadArgumentException(formatMessage("bad arguments", exp, actual), e); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,33 @@ | ||
package org.usf.jquery.core; | ||
|
||
import static org.usf.jquery.core.Validation.requireNArgs; | ||
|
||
import java.util.function.IntFunction; | ||
import static org.usf.jquery.core.Validation.requireAtLeastNArgs; | ||
|
||
/** | ||
* | ||
* @author u$f | ||
* | ||
*/ | ||
@FunctionalInterface | ||
public interface CastFunction extends DBFunction { | ||
public interface CastFunction extends FunctionOperator { | ||
|
||
String asType(); | ||
|
||
@Override | ||
default String name() { | ||
default String id() { | ||
return "CAST"; | ||
} | ||
|
||
@Override | ||
default String sql(QueryParameterBuilder builder, Object[] args, IntFunction<SQLType> indexedType) { | ||
var n = "VARCHAR".equals(asType()) ? 2 : 1; //require length | ||
requireNArgs(n, args, ()-> name() + "." + asType()); | ||
return new SqlStringBuilder(name()) | ||
.append("(").append(builder.appendLitteral(args[0], indexedType.apply(0))).append(" AS ").append(asType()) | ||
.appendIf(n == 2, ()-> "(" + builder.appendLitteral(args[1], indexedType.apply(1))+ ")") | ||
.append(")") | ||
.toString(); | ||
} | ||
|
||
static CastFunction castFunction(String type) { | ||
return ()-> type; | ||
default String sql(QueryParameterBuilder builder, Object[] args) { | ||
requireAtLeastNArgs(1, args, ()-> id() + "_AS_" + asType()); | ||
var sb = new SqlStringBuilder(id()) | ||
.append("(") | ||
.append(builder.appendLiteral(args[0])).append(" AS ").append(asType()); | ||
if(args.length > 1) { | ||
sb.append("(") | ||
.append(builder.appendLiteralArray(args, 1)) | ||
.append(")"); | ||
} | ||
return sb.append(")").toString(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.usf.jquery.core; | ||
|
||
import static org.usf.jquery.core.LogicalOperator.AND; | ||
import static org.usf.jquery.core.LogicalOperator.OR; | ||
|
||
/** | ||
* | ||
* @author u$f | ||
* | ||
*/ | ||
public interface Chainable<T extends Chainable<T>> { | ||
|
||
T append(LogicalOperator op, T exp); | ||
|
||
default T and(T exp) { | ||
return append(AND, exp); | ||
} | ||
|
||
default T or(T exp) { | ||
return append(OR, exp); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.