Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
import org.mybatis.dynamic.sql.SqlColumn;
import org.mybatis.dynamic.sql.SqlTable;
import org.mybatis.dynamic.sql.util.AbstractColumnMapping;
import org.mybatis.dynamic.sql.util.Buildable;
import org.mybatis.dynamic.sql.util.ConstantMapping;
import org.mybatis.dynamic.sql.util.NullMapping;
import org.mybatis.dynamic.sql.util.StringConstantMapping;
import org.mybatis.dynamic.sql.util.ValueMapping;
import org.mybatis.dynamic.sql.util.ValueWhenPresentMapping;

public class GeneralInsertDSL {
public class GeneralInsertDSL implements Buildable<GeneralInsertModel> {
private List<AbstractColumnMapping> insertMappings = new ArrayList<>();
private SqlTable table;

Expand All @@ -40,7 +41,8 @@ private GeneralInsertDSL(SqlTable table) {
public <T> SetClauseFinisher<T> set(SqlColumn<T> column) {
return new SetClauseFinisher<>(column);
}


@Override
public GeneralInsertModel build() {
return new GeneralInsertModel.Builder()
.withTable(table)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,7 @@
import java.util.function.Function;
import java.util.stream.Stream;

import org.jetbrains.annotations.NotNull;
import org.mybatis.dynamic.sql.SqlTable;
import org.mybatis.dynamic.sql.insert.render.GeneralInsertRenderer;
import org.mybatis.dynamic.sql.insert.render.GeneralInsertStatementProvider;
Expand All @@ -45,6 +46,7 @@ public SqlTable table() {
return table;
}

@NotNull
public GeneralInsertStatementProvider render(RenderingStrategy renderingStrategy) {
return GeneralInsertRenderer.withInsertModel(this)
.withRenderingStrategy(renderingStrategy)
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/mybatis/dynamic/sql/insert/InsertDSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
import org.mybatis.dynamic.sql.SqlColumn;
import org.mybatis.dynamic.sql.SqlTable;
import org.mybatis.dynamic.sql.util.AbstractColumnMapping;
import org.mybatis.dynamic.sql.util.Buildable;
import org.mybatis.dynamic.sql.util.ConstantMapping;
import org.mybatis.dynamic.sql.util.NullMapping;
import org.mybatis.dynamic.sql.util.PropertyMapping;
import org.mybatis.dynamic.sql.util.PropertyWhenPresentMapping;
import org.mybatis.dynamic.sql.util.StringConstantMapping;

public class InsertDSL<T> {
public class InsertDSL<T> implements Buildable<InsertModel<T>> {

private T record;
private SqlTable table;
Expand All @@ -43,6 +44,7 @@ public <F> ColumnMappingFinisher<F> map(SqlColumn<F> column) {
return new ColumnMappingFinisher<>(column);
}

@Override
public InsertModel<T> build() {
return InsertModel.withRecord(record)
.withTable(table)
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/mybatis/dynamic/sql/insert/InsertModel.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,7 @@
import java.util.function.Function;
import java.util.stream.Stream;

import org.jetbrains.annotations.NotNull;
import org.mybatis.dynamic.sql.SqlTable;
import org.mybatis.dynamic.sql.insert.render.InsertRenderer;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
Expand Down Expand Up @@ -49,7 +50,8 @@ public T record() {
public SqlTable table() {
return table;
}


@NotNull
public InsertStatementProvider<T> render(RenderingStrategy renderingStrategy) {
return InsertRenderer.withInsertModel(this)
.withRenderingStrategy(renderingStrategy)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,12 +23,13 @@
import org.mybatis.dynamic.sql.SqlColumn;
import org.mybatis.dynamic.sql.SqlTable;
import org.mybatis.dynamic.sql.util.AbstractColumnMapping;
import org.mybatis.dynamic.sql.util.Buildable;
import org.mybatis.dynamic.sql.util.ConstantMapping;
import org.mybatis.dynamic.sql.util.NullMapping;
import org.mybatis.dynamic.sql.util.PropertyMapping;
import org.mybatis.dynamic.sql.util.StringConstantMapping;

public class MultiRowInsertDSL<T> {
public class MultiRowInsertDSL<T> implements Buildable<MultiRowInsertModel<T>> {

private Collection<T> records;
private SqlTable table;
Expand All @@ -42,7 +43,8 @@ private MultiRowInsertDSL(Collection<T> records, SqlTable table) {
public <F> ColumnMappingFinisher<F> map(SqlColumn<F> column) {
return new ColumnMappingFinisher<>(column);
}


@Override
public MultiRowInsertModel<T> build() {
return MultiRowInsertModel.withRecords(records)
.withTable(table)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@

import java.util.Collection;

import org.jetbrains.annotations.NotNull;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertRenderer;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.render.RenderingStrategy;
Expand All @@ -26,7 +27,8 @@ public class MultiRowInsertModel<T> extends AbstractMultiRowInsertModel<T> {
private MultiRowInsertModel(Builder<T> builder) {
super(builder);
}


@NotNull
public MultiRowInsertStatementProvider<T> render(RenderingStrategy renderingStrategy) {
return MultiRowInsertRenderer.withMultiRowInsertModel(this)
.withRenderingStrategy(renderingStrategy)
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/mybatis/dynamic/sql/select/GroupByModel.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2018 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@
package org.mybatis.dynamic.sql.select;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Stream;
Expand All @@ -26,15 +26,15 @@
public class GroupByModel {
private List<BasicColumn> columns = new ArrayList<>();

private GroupByModel(List<BasicColumn> columns) {
private GroupByModel(Collection<BasicColumn> columns) {
this.columns.addAll(columns);
}

public <R> Stream<R> mapColumns(Function<BasicColumn, R> mapper) {
return columns.stream().map(mapper);
}

public static GroupByModel of(BasicColumn...columns) {
return new GroupByModel(Arrays.asList(columns));
public static GroupByModel of(Collection<BasicColumn> columns) {
return new GroupByModel(columns);
}
}
10 changes: 5 additions & 5 deletions src/main/java/org/mybatis/dynamic/sql/select/OrderByModel.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2017 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@
package org.mybatis.dynamic.sql.select;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Stream;
Expand All @@ -26,15 +26,15 @@
public class OrderByModel {
private List<SortSpecification> columns = new ArrayList<>();

private OrderByModel(List<SortSpecification> columns) {
private OrderByModel(Collection<SortSpecification> columns) {
this.columns.addAll(columns);
}

public <R> Stream<R> mapColumns(Function<SortSpecification, R> mapper) {
return columns.stream().map(mapper);
}

public static OrderByModel of(SortSpecification...columns) {
return new OrderByModel(Arrays.asList(columns));
public static OrderByModel of(Collection<SortSpecification> columns) {
return new OrderByModel(columns);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -115,11 +115,19 @@ public JoinSpecificationStarter fullJoin(SqlTable joinTable, String tableAlias)
}

public GroupByFinisher groupBy(BasicColumn...columns) {
return groupBy(Arrays.asList(columns));
}

public GroupByFinisher groupBy(Collection<BasicColumn> columns) {
groupByModel = GroupByModel.of(columns);
return new GroupByFinisher();
}

public SelectDSL<R> orderBy(SortSpecification...columns) {
return orderBy(Arrays.asList(columns));
}

public SelectDSL<R> orderBy(Collection<SortSpecification> columns) {
selectDSL.orderBy(columns);
return selectDSL;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/mybatis/dynamic/sql/select/SelectDSL.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -138,7 +138,7 @@ QueryExpressionDSL<R> newQueryExpression(FromGatherer<R> fromGatherer, String ta
return queryExpression;
}

void orderBy(SortSpecification...columns) {
void orderBy(Collection<SortSpecification> columns) {
orderByModel = OrderByModel.of(columns);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,6 +19,7 @@
import java.util.Arrays;
import java.util.List;

import org.jetbrains.annotations.NotNull;
import org.mybatis.dynamic.sql.BindableColumn;
import org.mybatis.dynamic.sql.SqlCriterion;
import org.mybatis.dynamic.sql.VisitableCondition;
Expand All @@ -30,51 +31,61 @@ protected AbstractWhereDSL() {
super();
}

@NotNull
public <S> T where(BindableColumn<S> column, VisitableCondition<S> condition) {
addCriterion(column, condition);
return getThis();
}

@NotNull
public <S> T where(BindableColumn<S> column, VisitableCondition<S> condition, SqlCriterion<?>...subCriteria) {
addCriterion(column, condition, Arrays.asList(subCriteria));
return getThis();
}

@NotNull
public <S> T where(BindableColumn<S> column, VisitableCondition<S> condition, List<SqlCriterion<?>> subCriteria) {
addCriterion(column, condition, subCriteria);
return getThis();
}

@NotNull
public T applyWhere(WhereApplier whereApplier) {
whereApplier.accept(this);
return getThis();
}

@NotNull
public <S> T and(BindableColumn<S> column, VisitableCondition<S> condition) {
addCriterion("and", column, condition); //$NON-NLS-1$
return getThis();
}

@NotNull
public <S> T and(BindableColumn<S> column, VisitableCondition<S> condition, SqlCriterion<?>...subCriteria) {
addCriterion("and", column, condition, Arrays.asList(subCriteria)); //$NON-NLS-1$
return getThis();
}

@NotNull
public <S> T and(BindableColumn<S> column, VisitableCondition<S> condition, List<SqlCriterion<?>> subCriteria) {
addCriterion("and", column, condition, subCriteria); //$NON-NLS-1$
return getThis();
}

@NotNull
public <S> T or(BindableColumn<S> column, VisitableCondition<S> condition) {
addCriterion("or", column, condition); //$NON-NLS-1$
return getThis();
}

@NotNull
public <S> T or(BindableColumn<S> column, VisitableCondition<S> condition, SqlCriterion<?>...subCriteria) {
addCriterion("or", column, condition, Arrays.asList(subCriteria)); //$NON-NLS-1$
return getThis();
}

@NotNull
public <S> T or(BindableColumn<S> column, VisitableCondition<S> condition, List<SqlCriterion<?>> subCriteria) {
addCriterion("or", column, condition, subCriteria); //$NON-NLS-1$
return getThis();
Expand Down
Loading