groovy.lang.Tuple Java Examples

The following examples show how to use groovy.lang.Tuple. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtractIndexAndSql.java    From groovy with Apache License 2.0 6 votes vote down vote up
private static String adaptForNamedParams(String sql, List<Tuple<?>> indexPropList) {
    StringBuilder newSql = new StringBuilder();
    int txtIndex = 0;

    Matcher matcher = NAMED_QUERY_PATTERN.matcher(sql);
    while (matcher.find()) {
        newSql.append(sql, txtIndex, matcher.start()).append('?');
        String indexStr = matcher.group(1);
        if (indexStr == null) indexStr = matcher.group(3);
        int index = (indexStr == null || indexStr.length() == 0 || ":".equals(indexStr)) ? 0 : Integer.parseInt(indexStr) - 1;
        String prop = matcher.group(2);
        if (prop == null) prop = matcher.group(4);
        indexPropList.add(new Tuple<Object>(index, prop == null || prop.length() == 0 ? "<this>" : prop));
        txtIndex = matcher.end();
    }
    newSql.append(sql, txtIndex, sql.length()); // append ending SQL after last param.
    return newSql.toString();
}
 
Example #2
Source File: TextEditor.java    From groovy with Apache License 2.0 5 votes vote down vote up
private void setRenderRange(int start, int stop) {
    DocumentFilter documentFilter = ((DefaultStyledDocument) TextEditor.this.getDocument()).getDocumentFilter();
    if (documentFilter instanceof SmartDocumentFilter) {
        SmartDocumentFilter smartDocumentFilter = (SmartDocumentFilter) documentFilter;
        smartDocumentFilter.setRenderRange(Tuple.tuple(start, stop));
    }
}
 
Example #3
Source File: StaticTypesMethodReferenceExpressionWriter.java    From groovy with Apache License 2.0 5 votes vote down vote up
/**
 * Choose the best method node for method reference.
 */
private MethodNode chooseMethodRefMethodCandidate(Expression methodRef, List<MethodNode> candidates) {
    if (1 == candidates.size()) return candidates.get(0);

    return candidates.stream()
            .map(e -> Tuple.tuple(e, matchingScore(e, methodRef)))
            .min((t1, t2) -> Integer.compare(t2.getV2(), t1.getV2()))
            .map(Tuple2::getV1)
            .orElse(null);
}
 
Example #4
Source File: SyntaxErrorReportable.java    From groovy with Apache License 2.0 4 votes vote down vote up
default void require(boolean condition, String msg, int offset, boolean toAttachPositionInfo) {
    require(condition, msg, Tuple.tuple(0, offset), toAttachPositionInfo);
}
 
Example #5
Source File: SyntaxErrorReportable.java    From groovy with Apache License 2.0 4 votes vote down vote up
default void require(boolean condition, String msg, int offset) {
    require(condition, msg, Tuple.tuple(0, offset));
}
 
Example #6
Source File: SyntaxErrorReportable.java    From groovy with Apache License 2.0 4 votes vote down vote up
default void throwSyntaxError(String msg, int offset, boolean toAttachPositionInfo) {
    throwSyntaxError(msg, Tuple.tuple(0, offset), toAttachPositionInfo);
}
 
Example #7
Source File: SyntaxErrorReportable.java    From groovy with Apache License 2.0 4 votes vote down vote up
default PositionInfo genPositionInfo(int offset) {
    return genPositionInfo(Tuple.tuple(0, offset));
}
 
Example #8
Source File: ExtractIndexAndSql.java    From groovy with Apache License 2.0 4 votes vote down vote up
List<Tuple<?>> getIndexPropList() {
    return indexPropList;
}
 
Example #9
Source File: BatchingPreparedStatementWrapper.java    From groovy with Apache License 2.0 4 votes vote down vote up
public BatchingPreparedStatementWrapper(PreparedStatement delegate, List<Tuple> indexPropList, int batchSize, Logger log, Sql sql) {
    super(delegate, batchSize, log);
    this.delegate = delegate;
    this.indexPropList = indexPropList;
    this.sql = sql;
}
 
Example #10
Source File: ScriptBytecodeAdapter.java    From groovy with Apache License 2.0 4 votes vote down vote up
public static Tuple createTuple(Object[] array) {
    return new Tuple(array);
}
 
Example #11
Source File: InvokerHelper.java    From groovy with Apache License 2.0 4 votes vote down vote up
public static Tuple createTuple(Object[] array) {
    return new Tuple(array);
}