Skip to content

Commit b107e9d

Browse files
committed
Use Collection instead of List in the Public API
1 parent b8d0765 commit b107e9d

12 files changed

+63
-61
lines changed

src/main/java/org/mybatis/dynamic/sql/AbstractListValueCondition.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2018 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,21 +16,21 @@
1616
package org.mybatis.dynamic.sql;
1717

1818
import java.util.ArrayList;
19-
import java.util.List;
19+
import java.util.Collection;
2020
import java.util.Objects;
2121
import java.util.function.Function;
2222
import java.util.function.UnaryOperator;
2323
import java.util.stream.Stream;
2424

2525
public abstract class AbstractListValueCondition<T> implements VisitableCondition<T> {
26-
protected List<T> values;
26+
protected Collection<T> values;
2727
protected UnaryOperator<Stream<T>> valueStreamOperations;
2828

29-
protected AbstractListValueCondition(List<T> values) {
29+
protected AbstractListValueCondition(Collection<T> values) {
3030
this(values, UnaryOperator.identity());
3131
}
3232

33-
protected AbstractListValueCondition(List<T> values, UnaryOperator<Stream<T>> valueStreamOperations) {
33+
protected AbstractListValueCondition(Collection<T> values, UnaryOperator<Stream<T>> valueStreamOperations) {
3434
this.values = new ArrayList<>(Objects.requireNonNull(values));
3535
this.valueStreamOperations = Objects.requireNonNull(valueStreamOperations);
3636
}

src/main/java/org/mybatis/dynamic/sql/SqlBuilder.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2018 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
1616
package org.mybatis.dynamic.sql;
1717

1818
import java.util.Arrays;
19-
import java.util.List;
19+
import java.util.Collection;
2020
import java.util.function.Supplier;
2121

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

116-
static <T> BatchInsertDSL.IntoGatherer<T> insert(List<T> records) {
116+
static <T> BatchInsertDSL.IntoGatherer<T> insert(Collection<T> records) {
117117
return BatchInsertDSL.insert(records);
118118
}
119119

@@ -417,7 +417,7 @@ static <T> IsIn<T> isIn(T...values) {
417417
return isIn(Arrays.asList(values));
418418
}
419419

420-
static <T> IsIn<T> isIn(List<T> values) {
420+
static <T> IsIn<T> isIn(Collection<T> values) {
421421
return IsIn.of(values);
422422
}
423423

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

433-
static <T> IsInWhenPresent<T> isInWhenPresent(List<T> values) {
433+
static <T> IsInWhenPresent<T> isInWhenPresent(Collection<T> values) {
434434
return IsInWhenPresent.of(values);
435435
}
436436

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

442-
static <T> IsNotIn<T> isNotIn(List<T> values) {
442+
static <T> IsNotIn<T> isNotIn(Collection<T> values) {
443443
return IsNotIn.of(values);
444444
}
445445

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

455-
static <T> IsNotInWhenPresent<T> isNotInWhenPresent(List<T> values) {
455+
static <T> IsNotInWhenPresent<T> isNotInWhenPresent(Collection<T> values) {
456456
return IsNotInWhenPresent.of(values);
457457
}
458458

@@ -558,31 +558,31 @@ static IsInCaseInsensitive isInCaseInsensitive(String...values) {
558558
return isInCaseInsensitive(Arrays.asList(values));
559559
}
560560

561-
static IsInCaseInsensitive isInCaseInsensitive(List<String> values) {
561+
static IsInCaseInsensitive isInCaseInsensitive(Collection<String> values) {
562562
return IsInCaseInsensitive.of(values);
563563
}
564564

565565
static IsInCaseInsensitiveWhenPresent isInCaseInsensitiveWhenPresent(String...values) {
566566
return isInCaseInsensitiveWhenPresent(Arrays.asList(values));
567567
}
568568

569-
static IsInCaseInsensitiveWhenPresent isInCaseInsensitiveWhenPresent(List<String> values) {
569+
static IsInCaseInsensitiveWhenPresent isInCaseInsensitiveWhenPresent(Collection<String> values) {
570570
return IsInCaseInsensitiveWhenPresent.of(values);
571571
}
572572

573573
static IsNotInCaseInsensitive isNotInCaseInsensitive(String...values) {
574574
return isNotInCaseInsensitive(Arrays.asList(values));
575575
}
576576

577-
static IsNotInCaseInsensitive isNotInCaseInsensitive(List<String> values) {
577+
static IsNotInCaseInsensitive isNotInCaseInsensitive(Collection<String> values) {
578578
return IsNotInCaseInsensitive.of(values);
579579
}
580580

581581
static IsNotInCaseInsensitiveWhenPresent isNotInCaseInsensitiveWhenPresent(String...values) {
582582
return isNotInCaseInsensitiveWhenPresent(Arrays.asList(values));
583583
}
584584

585-
static IsNotInCaseInsensitiveWhenPresent isNotInCaseInsensitiveWhenPresent(List<String> values) {
585+
static IsNotInCaseInsensitiveWhenPresent isNotInCaseInsensitiveWhenPresent(Collection<String> values) {
586586
return IsNotInCaseInsensitiveWhenPresent.of(values);
587587
}
588588

src/main/java/org/mybatis/dynamic/sql/insert/BatchInsertDSL.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2017 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
1717

1818
import java.util.ArrayList;
1919
import java.util.Arrays;
20+
import java.util.Collection;
2021
import java.util.List;
2122

2223
import org.mybatis.dynamic.sql.SqlColumn;
@@ -29,11 +30,11 @@
2930

3031
public class BatchInsertDSL<T> {
3132

32-
private List<T> records;
33+
private Collection<T> records;
3334
private SqlTable table;
3435
private List<InsertMapping> columnMappings = new ArrayList<>();
3536

36-
private BatchInsertDSL(List<T> records, SqlTable table) {
37+
private BatchInsertDSL(Collection<T> records, SqlTable table) {
3738
this.records = records;
3839
this.table = table;
3940
}
@@ -54,14 +55,14 @@ public static <T> IntoGatherer<T> insert(T...records) {
5455
return new IntoGatherer<>(Arrays.asList(records));
5556
}
5657

57-
public static <T> IntoGatherer<T> insert(List<T> records) {
58+
public static <T> IntoGatherer<T> insert(Collection<T> records) {
5859
return new IntoGatherer<>(records);
5960
}
6061

6162
public static class IntoGatherer<T> {
62-
private List<T> records;
63+
private Collection<T> records;
6364

64-
private IntoGatherer(List<T> records) {
65+
private IntoGatherer(Collection<T> records) {
6566
this.records = records;
6667
}
6768

src/main/java/org/mybatis/dynamic/sql/insert/BatchInsertModel.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2017 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616
package org.mybatis.dynamic.sql.insert;
1717

1818
import java.util.ArrayList;
19+
import java.util.Collection;
1920
import java.util.Collections;
2021
import java.util.List;
2122
import java.util.Objects;
@@ -58,7 +59,7 @@ public BatchInsert<T> render(RenderingStrategy renderingStrategy) {
5859
.render();
5960
}
6061

61-
public static <T> Builder<T> withRecords(List<T> records) {
62+
public static <T> Builder<T> withRecords(Collection<T> records) {
6263
return new Builder<T>().withRecords(records);
6364
}
6465

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

75-
public Builder<T> withRecords(List<T> records) {
76+
public Builder<T> withRecords(Collection<T> records) {
7677
this.records.addAll(records);
7778
return this;
7879
}

src/main/java/org/mybatis/dynamic/sql/where/condition/IsIn.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2018 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
1717

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

20-
import java.util.List;
20+
import java.util.Collection;
2121
import java.util.function.UnaryOperator;
2222
import java.util.stream.Collectors;
2323
import java.util.stream.Stream;
@@ -26,11 +26,11 @@
2626

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

29-
protected IsIn(List<T> values, UnaryOperator<Stream<T>> valueStreamOperations) {
29+
protected IsIn(Collection<T> values, UnaryOperator<Stream<T>> valueStreamOperations) {
3030
super(values, valueStreamOperations);
3131
}
3232

33-
protected IsIn(List<T> values) {
33+
protected IsIn(Collection<T> values) {
3434
super(values);
3535
}
3636

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

47-
public static <T> IsIn<T> of(List<T> values) {
47+
public static <T> IsIn<T> of(Collection<T> values) {
4848
return new IsIn<>(values);
4949
}
5050
}

src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitive.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2018 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
1515
*/
1616
package org.mybatis.dynamic.sql.where.condition;
1717

18-
import java.util.List;
18+
import java.util.Collection;
1919
import java.util.function.UnaryOperator;
2020
import java.util.stream.Collectors;
2121
import java.util.stream.Stream;
@@ -25,11 +25,11 @@
2525

2626
public class IsInCaseInsensitive extends AbstractListValueCondition<String> {
2727

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

32-
protected IsInCaseInsensitive(List<String> values, UnaryOperator<Stream<String>> valueStreamOperations) {
32+
protected IsInCaseInsensitive(Collection<String> values, UnaryOperator<Stream<String>> valueStreamOperations) {
3333
super(values, StringUtilities.upperCaseAfter(valueStreamOperations));
3434
}
3535

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

46-
public static IsInCaseInsensitive of(List<String> values) {
46+
public static IsInCaseInsensitive of(Collection<String> values) {
4747
return new IsInCaseInsensitive(values);
4848
}
4949
}

src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitiveWhenPresent.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2018 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,16 +15,16 @@
1515
*/
1616
package org.mybatis.dynamic.sql.where.condition;
1717

18-
import java.util.List;
18+
import java.util.Collection;
1919
import java.util.Objects;
2020

2121
public class IsInCaseInsensitiveWhenPresent extends IsInCaseInsensitive {
2222

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

27-
public static IsInCaseInsensitiveWhenPresent of(List<String> values) {
27+
public static IsInCaseInsensitiveWhenPresent of(Collection<String> values) {
2828
return new IsInCaseInsensitiveWhenPresent(values);
2929
}
3030
}

src/main/java/org/mybatis/dynamic/sql/where/condition/IsInWhenPresent.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2018 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,16 +15,16 @@
1515
*/
1616
package org.mybatis.dynamic.sql.where.condition;
1717

18-
import java.util.List;
18+
import java.util.Collection;
1919
import java.util.Objects;
2020

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

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

27-
public static <T> IsInWhenPresent<T> of(List<T> values) {
27+
public static <T> IsInWhenPresent<T> of(Collection<T> values) {
2828
return new IsInWhenPresent<>(values);
2929
}
3030
}

src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotIn.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2018 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
1717

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

20-
import java.util.List;
20+
import java.util.Collection;
2121
import java.util.function.UnaryOperator;
2222
import java.util.stream.Collectors;
2323
import java.util.stream.Stream;
@@ -26,11 +26,11 @@
2626

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

29-
protected IsNotIn(List<T> values, UnaryOperator<Stream<T>> valueStreamOperations) {
29+
protected IsNotIn(Collection<T> values, UnaryOperator<Stream<T>> valueStreamOperations) {
3030
super(values, valueStreamOperations);
3131
}
3232

33-
protected IsNotIn(List<T> values) {
33+
protected IsNotIn(Collection<T> values) {
3434
super(values);
3535
}
3636

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

48-
public static <T> IsNotIn<T> of(List<T> values) {
48+
public static <T> IsNotIn<T> of(Collection<T> values) {
4949
return new IsNotIn<>(values);
5050
}
5151
}

0 commit comments

Comments
 (0)