diff --git a/src/main/java/org/mybatis/dynamic/sql/AbstractListValueCondition.java b/src/main/java/org/mybatis/dynamic/sql/AbstractListValueCondition.java index 2ce432e21..18daee42a 100644 --- a/src/main/java/org/mybatis/dynamic/sql/AbstractListValueCondition.java +++ b/src/main/java/org/mybatis/dynamic/sql/AbstractListValueCondition.java @@ -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. @@ -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 implements VisitableCondition { - protected List values; + protected Collection values; protected UnaryOperator> valueStreamOperations; - protected AbstractListValueCondition(List values) { + protected AbstractListValueCondition(Collection values) { this(values, UnaryOperator.identity()); } - protected AbstractListValueCondition(List values, UnaryOperator> valueStreamOperations) { + protected AbstractListValueCondition(Collection values, UnaryOperator> valueStreamOperations) { this.values = new ArrayList<>(Objects.requireNonNull(values)); this.valueStreamOperations = Objects.requireNonNull(valueStreamOperations); } diff --git a/src/main/java/org/mybatis/dynamic/sql/SqlBuilder.java b/src/main/java/org/mybatis/dynamic/sql/SqlBuilder.java index 9907c681c..14d034aa4 100644 --- a/src/main/java/org/mybatis/dynamic/sql/SqlBuilder.java +++ b/src/main/java/org/mybatis/dynamic/sql/SqlBuilder.java @@ -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. @@ -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; @@ -113,7 +113,7 @@ static BatchInsertDSL.IntoGatherer insert(T...records) { return BatchInsertDSL.insert(records); } - static BatchInsertDSL.IntoGatherer insert(List records) { + static BatchInsertDSL.IntoGatherer insert(Collection records) { return BatchInsertDSL.insert(records); } @@ -417,7 +417,7 @@ static IsIn isIn(T...values) { return isIn(Arrays.asList(values)); } - static IsIn isIn(List values) { + static IsIn isIn(Collection values) { return IsIn.of(values); } @@ -430,7 +430,7 @@ static IsInWhenPresent isInWhenPresent(T...values) { return isInWhenPresent(Arrays.asList(values)); } - static IsInWhenPresent isInWhenPresent(List values) { + static IsInWhenPresent isInWhenPresent(Collection values) { return IsInWhenPresent.of(values); } @@ -439,7 +439,7 @@ static IsNotIn isNotIn(T...values) { return isNotIn(Arrays.asList(values)); } - static IsNotIn isNotIn(List values) { + static IsNotIn isNotIn(Collection values) { return IsNotIn.of(values); } @@ -452,7 +452,7 @@ static IsNotInWhenPresent isNotInWhenPresent(T...values) { return isNotInWhenPresent(Arrays.asList(values)); } - static IsNotInWhenPresent isNotInWhenPresent(List values) { + static IsNotInWhenPresent isNotInWhenPresent(Collection values) { return IsNotInWhenPresent.of(values); } @@ -558,7 +558,7 @@ static IsInCaseInsensitive isInCaseInsensitive(String...values) { return isInCaseInsensitive(Arrays.asList(values)); } - static IsInCaseInsensitive isInCaseInsensitive(List values) { + static IsInCaseInsensitive isInCaseInsensitive(Collection values) { return IsInCaseInsensitive.of(values); } @@ -566,7 +566,7 @@ static IsInCaseInsensitiveWhenPresent isInCaseInsensitiveWhenPresent(String...va return isInCaseInsensitiveWhenPresent(Arrays.asList(values)); } - static IsInCaseInsensitiveWhenPresent isInCaseInsensitiveWhenPresent(List values) { + static IsInCaseInsensitiveWhenPresent isInCaseInsensitiveWhenPresent(Collection values) { return IsInCaseInsensitiveWhenPresent.of(values); } @@ -574,7 +574,7 @@ static IsNotInCaseInsensitive isNotInCaseInsensitive(String...values) { return isNotInCaseInsensitive(Arrays.asList(values)); } - static IsNotInCaseInsensitive isNotInCaseInsensitive(List values) { + static IsNotInCaseInsensitive isNotInCaseInsensitive(Collection values) { return IsNotInCaseInsensitive.of(values); } @@ -582,7 +582,7 @@ static IsNotInCaseInsensitiveWhenPresent isNotInCaseInsensitiveWhenPresent(Strin return isNotInCaseInsensitiveWhenPresent(Arrays.asList(values)); } - static IsNotInCaseInsensitiveWhenPresent isNotInCaseInsensitiveWhenPresent(List values) { + static IsNotInCaseInsensitiveWhenPresent isNotInCaseInsensitiveWhenPresent(Collection values) { return IsNotInCaseInsensitiveWhenPresent.of(values); } diff --git a/src/main/java/org/mybatis/dynamic/sql/insert/BatchInsertDSL.java b/src/main/java/org/mybatis/dynamic/sql/insert/BatchInsertDSL.java index 8bd617433..2c45a3764 100644 --- a/src/main/java/org/mybatis/dynamic/sql/insert/BatchInsertDSL.java +++ b/src/main/java/org/mybatis/dynamic/sql/insert/BatchInsertDSL.java @@ -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. @@ -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; @@ -29,11 +30,11 @@ public class BatchInsertDSL { - private List records; + private Collection records; private SqlTable table; private List columnMappings = new ArrayList<>(); - private BatchInsertDSL(List records, SqlTable table) { + private BatchInsertDSL(Collection records, SqlTable table) { this.records = records; this.table = table; } @@ -54,14 +55,14 @@ public static IntoGatherer insert(T...records) { return new IntoGatherer<>(Arrays.asList(records)); } - public static IntoGatherer insert(List records) { + public static IntoGatherer insert(Collection records) { return new IntoGatherer<>(records); } public static class IntoGatherer { - private List records; + private Collection records; - private IntoGatherer(List records) { + private IntoGatherer(Collection records) { this.records = records; } diff --git a/src/main/java/org/mybatis/dynamic/sql/insert/BatchInsertModel.java b/src/main/java/org/mybatis/dynamic/sql/insert/BatchInsertModel.java index cedf3cbf3..12024b396 100644 --- a/src/main/java/org/mybatis/dynamic/sql/insert/BatchInsertModel.java +++ b/src/main/java/org/mybatis/dynamic/sql/insert/BatchInsertModel.java @@ -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. @@ -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; @@ -58,7 +59,7 @@ public BatchInsert render(RenderingStrategy renderingStrategy) { .render(); } - public static Builder withRecords(List records) { + public static Builder withRecords(Collection records) { return new Builder().withRecords(records); } @@ -72,7 +73,7 @@ public Builder withTable(SqlTable table) { return this; } - public Builder withRecords(List records) { + public Builder withRecords(Collection records) { this.records.addAll(records); return this; } diff --git a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsIn.java b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsIn.java index 4a7bd2a5a..2b27cbbb5 100644 --- a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsIn.java +++ b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsIn.java @@ -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. @@ -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; @@ -26,11 +26,11 @@ public class IsIn extends AbstractListValueCondition { - protected IsIn(List values, UnaryOperator> valueStreamOperations) { + protected IsIn(Collection values, UnaryOperator> valueStreamOperations) { super(values, valueStreamOperations); } - protected IsIn(List values) { + protected IsIn(Collection values) { super(values); } @@ -44,7 +44,7 @@ public IsIn withValueStreamOperations(UnaryOperator> valueStreamOpe return new IsIn<>(values, valueStreamOperations); } - public static IsIn of(List values) { + public static IsIn of(Collection values) { return new IsIn<>(values); } } diff --git a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitive.java b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitive.java index f51be652c..8283a88f7 100644 --- a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitive.java +++ b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitive.java @@ -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. @@ -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; @@ -25,11 +25,11 @@ public class IsInCaseInsensitive extends AbstractListValueCondition { - protected IsInCaseInsensitive(List values) { + protected IsInCaseInsensitive(Collection values) { super(values, s -> s.map(StringUtilities::safelyUpperCase)); } - protected IsInCaseInsensitive(List values, UnaryOperator> valueStreamOperations) { + protected IsInCaseInsensitive(Collection values, UnaryOperator> valueStreamOperations) { super(values, StringUtilities.upperCaseAfter(valueStreamOperations)); } @@ -43,7 +43,7 @@ public IsInCaseInsensitive withValueStreamOperations(UnaryOperator values) { + public static IsInCaseInsensitive of(Collection values) { return new IsInCaseInsensitive(values); } } diff --git a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitiveWhenPresent.java b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitiveWhenPresent.java index 987c6b29f..90c70c657 100644 --- a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitiveWhenPresent.java +++ b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitiveWhenPresent.java @@ -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. @@ -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 values) { + protected IsInCaseInsensitiveWhenPresent(Collection values) { super(values, s -> s.filter(Objects::nonNull)); } - public static IsInCaseInsensitiveWhenPresent of(List values) { + public static IsInCaseInsensitiveWhenPresent of(Collection values) { return new IsInCaseInsensitiveWhenPresent(values); } } diff --git a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInWhenPresent.java b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInWhenPresent.java index c5e4e2006..c4a61001e 100644 --- a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInWhenPresent.java +++ b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsInWhenPresent.java @@ -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. @@ -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 extends IsIn { - protected IsInWhenPresent(List values) { + protected IsInWhenPresent(Collection values) { super(values, s -> s.filter(Objects::nonNull)); } - public static IsInWhenPresent of(List values) { + public static IsInWhenPresent of(Collection values) { return new IsInWhenPresent<>(values); } } diff --git a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotIn.java b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotIn.java index 8e7c5ba94..4dcdc1d54 100644 --- a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotIn.java +++ b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotIn.java @@ -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. @@ -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; @@ -26,11 +26,11 @@ public class IsNotIn extends AbstractListValueCondition { - protected IsNotIn(List values, UnaryOperator> valueStreamOperations) { + protected IsNotIn(Collection values, UnaryOperator> valueStreamOperations) { super(values, valueStreamOperations); } - protected IsNotIn(List values) { + protected IsNotIn(Collection values) { super(values); } @@ -45,7 +45,7 @@ public IsNotIn withValueStreamOperations(UnaryOperator> valueStream return new IsNotIn<>(values, valueStreamOperations); } - public static IsNotIn of(List values) { + public static IsNotIn of(Collection values) { return new IsNotIn<>(values); } } diff --git a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitive.java b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitive.java index 99d39e880..579fed6df 100644 --- a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitive.java +++ b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitive.java @@ -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. @@ -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; @@ -25,11 +25,11 @@ public class IsNotInCaseInsensitive extends AbstractListValueCondition { - protected IsNotInCaseInsensitive(List values) { + protected IsNotInCaseInsensitive(Collection values) { super(values, s -> s.map(StringUtilities::safelyUpperCase)); } - protected IsNotInCaseInsensitive(List values, UnaryOperator> valueStreamOperations) { + protected IsNotInCaseInsensitive(Collection values, UnaryOperator> valueStreamOperations) { super(values, StringUtilities.upperCaseAfter(valueStreamOperations)); } @@ -44,7 +44,7 @@ public IsNotInCaseInsensitive withValueStreamOperations(UnaryOperator values) { + public static IsNotInCaseInsensitive of(Collection values) { return new IsNotInCaseInsensitive(values); } } diff --git a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitiveWhenPresent.java b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitiveWhenPresent.java index ecc04b33b..85fdf3f5f 100644 --- a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitiveWhenPresent.java +++ b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitiveWhenPresent.java @@ -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. @@ -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 IsNotInCaseInsensitiveWhenPresent extends IsNotInCaseInsensitive { - protected IsNotInCaseInsensitiveWhenPresent(List values) { + protected IsNotInCaseInsensitiveWhenPresent(Collection values) { super(values, s -> s.filter(Objects::nonNull)); } - public static IsNotInCaseInsensitiveWhenPresent of(List values) { + public static IsNotInCaseInsensitiveWhenPresent of(Collection values) { return new IsNotInCaseInsensitiveWhenPresent(values); } } diff --git a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInWhenPresent.java b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInWhenPresent.java index dfaa8833e..55bf9fd70 100644 --- a/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInWhenPresent.java +++ b/src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInWhenPresent.java @@ -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. @@ -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 IsNotInWhenPresent extends IsNotIn { - protected IsNotInWhenPresent(List values) { + protected IsNotInWhenPresent(Collection values) { super(values, s -> s.filter(Objects::nonNull)); } - public static IsNotInWhenPresent of(List values) { + public static IsNotInWhenPresent of(Collection values) { return new IsNotInWhenPresent<>(values); } }