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
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2018 the original author or authors.
* Copyright 2016-2019 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,21 +16,21 @@
package org.mybatis.dynamic.sql;

import java.util.ArrayList;
import java.util.List;
import java.util.Collection;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.UnaryOperator;
import java.util.stream.Stream;

public abstract class AbstractListValueCondition<T> implements VisitableCondition<T> {
protected List<T> values;
protected Collection<T> values;
protected UnaryOperator<Stream<T>> valueStreamOperations;

protected AbstractListValueCondition(List<T> values) {
protected AbstractListValueCondition(Collection<T> values) {
this(values, UnaryOperator.identity());
}

protected AbstractListValueCondition(List<T> values, UnaryOperator<Stream<T>> valueStreamOperations) {
protected AbstractListValueCondition(Collection<T> values, UnaryOperator<Stream<T>> valueStreamOperations) {
this.values = new ArrayList<>(Objects.requireNonNull(values));
this.valueStreamOperations = Objects.requireNonNull(valueStreamOperations);
}
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/org/mybatis/dynamic/sql/SqlBuilder.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-2019 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;

import java.util.Arrays;
import java.util.List;
import java.util.Collection;
import java.util.function.Supplier;

import org.mybatis.dynamic.sql.delete.DeleteDSL;
Expand Down Expand Up @@ -113,7 +113,7 @@ static <T> BatchInsertDSL.IntoGatherer<T> insert(T...records) {
return BatchInsertDSL.insert(records);
}

static <T> BatchInsertDSL.IntoGatherer<T> insert(List<T> records) {
static <T> BatchInsertDSL.IntoGatherer<T> insert(Collection<T> records) {
return BatchInsertDSL.insert(records);
}

Expand Down Expand Up @@ -417,7 +417,7 @@ static <T> IsIn<T> isIn(T...values) {
return isIn(Arrays.asList(values));
}

static <T> IsIn<T> isIn(List<T> values) {
static <T> IsIn<T> isIn(Collection<T> values) {
return IsIn.of(values);
}

Expand All @@ -430,7 +430,7 @@ static <T> IsInWhenPresent<T> isInWhenPresent(T...values) {
return isInWhenPresent(Arrays.asList(values));
}

static <T> IsInWhenPresent<T> isInWhenPresent(List<T> values) {
static <T> IsInWhenPresent<T> isInWhenPresent(Collection<T> values) {
return IsInWhenPresent.of(values);
}

Expand All @@ -439,7 +439,7 @@ static <T> IsNotIn<T> isNotIn(T...values) {
return isNotIn(Arrays.asList(values));
}

static <T> IsNotIn<T> isNotIn(List<T> values) {
static <T> IsNotIn<T> isNotIn(Collection<T> values) {
return IsNotIn.of(values);
}

Expand All @@ -452,7 +452,7 @@ static <T> IsNotInWhenPresent<T> isNotInWhenPresent(T...values) {
return isNotInWhenPresent(Arrays.asList(values));
}

static <T> IsNotInWhenPresent<T> isNotInWhenPresent(List<T> values) {
static <T> IsNotInWhenPresent<T> isNotInWhenPresent(Collection<T> values) {
return IsNotInWhenPresent.of(values);
}

Expand Down Expand Up @@ -558,31 +558,31 @@ static IsInCaseInsensitive isInCaseInsensitive(String...values) {
return isInCaseInsensitive(Arrays.asList(values));
}

static IsInCaseInsensitive isInCaseInsensitive(List<String> values) {
static IsInCaseInsensitive isInCaseInsensitive(Collection<String> values) {
return IsInCaseInsensitive.of(values);
}

static IsInCaseInsensitiveWhenPresent isInCaseInsensitiveWhenPresent(String...values) {
return isInCaseInsensitiveWhenPresent(Arrays.asList(values));
}

static IsInCaseInsensitiveWhenPresent isInCaseInsensitiveWhenPresent(List<String> values) {
static IsInCaseInsensitiveWhenPresent isInCaseInsensitiveWhenPresent(Collection<String> values) {
return IsInCaseInsensitiveWhenPresent.of(values);
}

static IsNotInCaseInsensitive isNotInCaseInsensitive(String...values) {
return isNotInCaseInsensitive(Arrays.asList(values));
}

static IsNotInCaseInsensitive isNotInCaseInsensitive(List<String> values) {
static IsNotInCaseInsensitive isNotInCaseInsensitive(Collection<String> values) {
return IsNotInCaseInsensitive.of(values);
}

static IsNotInCaseInsensitiveWhenPresent isNotInCaseInsensitiveWhenPresent(String...values) {
return isNotInCaseInsensitiveWhenPresent(Arrays.asList(values));
}

static IsNotInCaseInsensitiveWhenPresent isNotInCaseInsensitiveWhenPresent(List<String> values) {
static IsNotInCaseInsensitiveWhenPresent isNotInCaseInsensitiveWhenPresent(Collection<String> values) {
return IsNotInCaseInsensitiveWhenPresent.of(values);
}

Expand Down
13 changes: 7 additions & 6 deletions src/main/java/org/mybatis/dynamic/sql/insert/BatchInsertDSL.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-2019 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.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import org.mybatis.dynamic.sql.SqlColumn;
Expand All @@ -29,11 +30,11 @@

public class BatchInsertDSL<T> {

private List<T> records;
private Collection<T> records;
private SqlTable table;
private List<InsertMapping> columnMappings = new ArrayList<>();

private BatchInsertDSL(List<T> records, SqlTable table) {
private BatchInsertDSL(Collection<T> records, SqlTable table) {
this.records = records;
this.table = table;
}
Expand All @@ -54,14 +55,14 @@ public static <T> IntoGatherer<T> insert(T...records) {
return new IntoGatherer<>(Arrays.asList(records));
}

public static <T> IntoGatherer<T> insert(List<T> records) {
public static <T> IntoGatherer<T> insert(Collection<T> records) {
return new IntoGatherer<>(records);
}

public static class IntoGatherer<T> {
private List<T> records;
private Collection<T> records;

private IntoGatherer(List<T> records) {
private IntoGatherer(Collection<T> records) {
this.records = records;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2017 the original author or authors.
* Copyright 2016-2019 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,6 +16,7 @@
package org.mybatis.dynamic.sql.insert;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -58,7 +59,7 @@ public BatchInsert<T> render(RenderingStrategy renderingStrategy) {
.render();
}

public static <T> Builder<T> withRecords(List<T> records) {
public static <T> Builder<T> withRecords(Collection<T> records) {
return new Builder<T>().withRecords(records);
}

Expand All @@ -72,7 +73,7 @@ public Builder<T> withTable(SqlTable table) {
return this;
}

public Builder<T> withRecords(List<T> records) {
public Builder<T> withRecords(Collection<T> records) {
this.records.addAll(records);
return this;
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/mybatis/dynamic/sql/where/condition/IsIn.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-2019 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,7 +17,7 @@

import static org.mybatis.dynamic.sql.util.StringUtilities.spaceAfter;

import java.util.List;
import java.util.Collection;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand All @@ -26,11 +26,11 @@

public class IsIn<T> extends AbstractListValueCondition<T> {

protected IsIn(List<T> values, UnaryOperator<Stream<T>> valueStreamOperations) {
protected IsIn(Collection<T> values, UnaryOperator<Stream<T>> valueStreamOperations) {
super(values, valueStreamOperations);
}

protected IsIn(List<T> values) {
protected IsIn(Collection<T> values) {
super(values);
}

Expand All @@ -44,7 +44,7 @@ public IsIn<T> withValueStreamOperations(UnaryOperator<Stream<T>> valueStreamOpe
return new IsIn<>(values, valueStreamOperations);
}

public static <T> IsIn<T> of(List<T> values) {
public static <T> IsIn<T> of(Collection<T> values) {
return new IsIn<>(values);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2018 the original author or authors.
* Copyright 2016-2019 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 @@ -15,7 +15,7 @@
*/
package org.mybatis.dynamic.sql.where.condition;

import java.util.List;
import java.util.Collection;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand All @@ -25,11 +25,11 @@

public class IsInCaseInsensitive extends AbstractListValueCondition<String> {

protected IsInCaseInsensitive(List<String> values) {
protected IsInCaseInsensitive(Collection<String> values) {
super(values, s -> s.map(StringUtilities::safelyUpperCase));
}

protected IsInCaseInsensitive(List<String> values, UnaryOperator<Stream<String>> valueStreamOperations) {
protected IsInCaseInsensitive(Collection<String> values, UnaryOperator<Stream<String>> valueStreamOperations) {
super(values, StringUtilities.upperCaseAfter(valueStreamOperations));
}

Expand All @@ -43,7 +43,7 @@ public IsInCaseInsensitive withValueStreamOperations(UnaryOperator<Stream<String
return new IsInCaseInsensitive(values, valueStreamOperations);
}

public static IsInCaseInsensitive of(List<String> values) {
public static IsInCaseInsensitive of(Collection<String> values) {
return new IsInCaseInsensitive(values);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2018 the original author or authors.
* Copyright 2016-2019 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 @@ -15,16 +15,16 @@
*/
package org.mybatis.dynamic.sql.where.condition;

import java.util.List;
import java.util.Collection;
import java.util.Objects;

public class IsInCaseInsensitiveWhenPresent extends IsInCaseInsensitive {

protected IsInCaseInsensitiveWhenPresent(List<String> values) {
protected IsInCaseInsensitiveWhenPresent(Collection<String> values) {
super(values, s -> s.filter(Objects::nonNull));
}

public static IsInCaseInsensitiveWhenPresent of(List<String> values) {
public static IsInCaseInsensitiveWhenPresent of(Collection<String> values) {
return new IsInCaseInsensitiveWhenPresent(values);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2018 the original author or authors.
* Copyright 2016-2019 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 @@ -15,16 +15,16 @@
*/
package org.mybatis.dynamic.sql.where.condition;

import java.util.List;
import java.util.Collection;
import java.util.Objects;

public class IsInWhenPresent<T> extends IsIn<T> {

protected IsInWhenPresent(List<T> values) {
protected IsInWhenPresent(Collection<T> values) {
super(values, s -> s.filter(Objects::nonNull));
}

public static <T> IsInWhenPresent<T> of(List<T> values) {
public static <T> IsInWhenPresent<T> of(Collection<T> values) {
return new IsInWhenPresent<>(values);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2018 the original author or authors.
* Copyright 2016-2019 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,7 +17,7 @@

import static org.mybatis.dynamic.sql.util.StringUtilities.spaceAfter;

import java.util.List;
import java.util.Collection;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand All @@ -26,11 +26,11 @@

public class IsNotIn<T> extends AbstractListValueCondition<T> {

protected IsNotIn(List<T> values, UnaryOperator<Stream<T>> valueStreamOperations) {
protected IsNotIn(Collection<T> values, UnaryOperator<Stream<T>> valueStreamOperations) {
super(values, valueStreamOperations);
}

protected IsNotIn(List<T> values) {
protected IsNotIn(Collection<T> values) {
super(values);
}

Expand All @@ -45,7 +45,7 @@ public IsNotIn<T> withValueStreamOperations(UnaryOperator<Stream<T>> valueStream
return new IsNotIn<>(values, valueStreamOperations);
}

public static <T> IsNotIn<T> of(List<T> values) {
public static <T> IsNotIn<T> of(Collection<T> values) {
return new IsNotIn<>(values);
}
}
Loading