Актуализация версии библиотеки haiti. Переход на Java 17

This commit is contained in:
Struchkov Mark 2022-12-03 10:17:33 +03:00
parent 90f062e978
commit 251cad2f2e
4 changed files with 28 additions and 29 deletions

View File

@ -6,12 +6,12 @@
<parent>
<groupId>dev.struchkov.haiti</groupId>
<artifactId>haiti</artifactId>
<version>0.0.4</version>
<version>1.4.0</version>
</parent>
<groupId>dev.struchkov.haiti.filter</groupId>
<artifactId>haiti-filter-criteria</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
<name>Haiti Filter Criteria</name>
<description>Fast creation of filtering requests using the Criteria Api wrapper.</description>
@ -28,13 +28,12 @@
</issueManagement>
<properties>
<java.version>11</java.version>
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<haiti.ver>0.0.4</haiti.ver>
<google.auto.service.ver>1.0.1</google.auto.service.ver>
<plugin.maven.compiler.ver>3.9.0</plugin.maven.compiler.ver>

View File

@ -2,6 +2,7 @@ package dev.struchkov.haiti.filter.criteria;
import dev.struchkov.haiti.filter.FilterQuery;
import dev.struchkov.haiti.utils.Inspector;
import java.util.ArrayList;
import java.util.Arrays;
@ -9,8 +10,7 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static dev.struchkov.haiti.utils.Assert.Utils.nullPointer;
import static dev.struchkov.haiti.utils.Assert.isNotNull;
import static dev.struchkov.haiti.utils.Inspector.Utils.nullPointer;
public class CriteriaQuery<T> implements FilterQuery {
@ -36,7 +36,7 @@ public class CriteriaQuery<T> implements FilterQuery {
* @param fieldName Имя поля сущности, которое отвечает за название таблицы.
*/
public CriteriaQuery<T> join(String... fieldName) {
isNotNull(fieldName, nullPointer("fieldName"));
Inspector.isNotNull(fieldName, nullPointer("fieldName"));
joinTables = Arrays.stream(fieldName)
.map(JoinTable::of)
.collect(Collectors.toList());
@ -44,14 +44,14 @@ public class CriteriaQuery<T> implements FilterQuery {
}
public CriteriaQuery<T> join(JoinTable... joinTables) {
isNotNull(joinTables, nullPointer("joinTables"));
Inspector.isNotNull(joinTables, nullPointer("joinTables"));
this.joinTables = Arrays.stream(joinTables).collect(Collectors.toList());
return this;
}
@Override
public <Y extends Comparable<? super Y>> FilterQuery between(String field, Y from, Y to) {
isNotNull(field, nullPointer(FIELD_NAME));
Inspector.isNotNull(field, nullPointer(FIELD_NAME));
if (from != null && to != null) {
containers.add(simpleCriteriaQuery.between(joinTables, field, from, to));
}
@ -60,7 +60,7 @@ public class CriteriaQuery<T> implements FilterQuery {
@Override
public <Y extends Comparable<? super Y>> FilterQuery greaterThan(String field, Y value) {
isNotNull(field, nullPointer(FIELD_NAME));
Inspector.isNotNull(field, nullPointer(FIELD_NAME));
if (value != null) {
containers.add(simpleCriteriaQuery.greaterThan(joinTables, field, value));
}
@ -69,7 +69,7 @@ public class CriteriaQuery<T> implements FilterQuery {
@Override
public <Y extends Comparable<? super Y>> FilterQuery lessThan(String field, Y value) {
isNotNull(field, nullPointer(FIELD_NAME));
Inspector.isNotNull(field, nullPointer(FIELD_NAME));
if (value != null) {
containers.add(simpleCriteriaQuery.lessThan(joinTables, field, value));
}
@ -78,7 +78,7 @@ public class CriteriaQuery<T> implements FilterQuery {
@Override
public FilterQuery matchPhrase(String field, Object value) {
isNotNull(field, nullPointer(FIELD_NAME));
Inspector.isNotNull(field, nullPointer(FIELD_NAME));
if (value != null) {
containers.add(simpleCriteriaQuery.matchPhrase(joinTables, field, value));
}
@ -87,7 +87,7 @@ public class CriteriaQuery<T> implements FilterQuery {
@Override
public <U> FilterQuery matchPhrase(String field, Set<U> values) {
isNotNull(field, nullPointer(FIELD_NAME));
Inspector.isNotNull(field, nullPointer(FIELD_NAME));
if (values != null && !values.isEmpty()) {
containers.addAll(
values.stream()
@ -119,7 +119,7 @@ public class CriteriaQuery<T> implements FilterQuery {
@Override
public FilterQuery like(String field, String value, boolean ignoreCase) {
isNotNull(field, nullPointer(FIELD_NAME));
Inspector.isNotNull(field, nullPointer(FIELD_NAME));
containers.add(
ignoreCase
? simpleCriteriaQuery.likeIgnoreCase(joinTables, field, value)
@ -130,7 +130,7 @@ public class CriteriaQuery<T> implements FilterQuery {
@Override
public FilterQuery checkBoolInt(String field, Boolean flag) {
isNotNull(field, nullPointer(FIELD_NAME));
Inspector.isNotNull(field, nullPointer(FIELD_NAME));
if (flag != null) {
containers.add(
simpleCriteriaQuery.between(joinTables, field, 0, Integer.MAX_VALUE)

View File

@ -1,8 +1,8 @@
package dev.struchkov.haiti.filter.criteria;
import dev.struchkov.haiti.utils.Assert;
import dev.struchkov.haiti.utils.Inspector;
import static dev.struchkov.haiti.utils.Assert.Utils.nullPointer;
import static dev.struchkov.haiti.utils.Inspector.Utils.nullPointer;
/**
* @author upagge 15.04.2021
@ -18,12 +18,12 @@ public class JoinTable {
}
public static JoinTable of(String tableName) {
Assert.isNotNull(tableName, nullPointer("tableName"));
Inspector.isNotNull(tableName, nullPointer("tableName"));
return new JoinTable(tableName, JoinTypeOperation.LEFT);
}
public static JoinTable of(String tableName, JoinTypeOperation joinType) {
Assert.isNotNull(tableName, nullPointer("tableName"));
Inspector.isNotNull(tableName, nullPointer("tableName"));
return new JoinTable(tableName, joinType);
}

View File

@ -1,6 +1,6 @@
package dev.struchkov.haiti.filter.criteria;
import dev.struchkov.haiti.utils.Assert;
import dev.struchkov.haiti.utils.Inspector;
import org.hibernate.query.criteria.internal.path.PluralAttributeJoinSupport;
import javax.persistence.criteria.From;
@ -15,7 +15,7 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static dev.struchkov.haiti.utils.Assert.Utils.nullPointer;
import static dev.struchkov.haiti.utils.Inspector.Utils.nullPointer;
public class SimpleCriteriaQuery<T> {
@ -26,8 +26,8 @@ public class SimpleCriteriaQuery<T> {
private final Map<String, From<Object, Object>> joinMap = new HashMap<>();
public Container<T> matchPhrase(List<JoinTable> joinTables, String field, Object value) {
Assert.isNotNull(field, nullPointer(FIELD));
Assert.isNotNull(value, nullPointer("value"));
Inspector.isNotNull(field, nullPointer(FIELD));
Inspector.isNotNull(value, nullPointer("value"));
final Container<T> container = Container.of(joinTables);
container.setSpecification((root, query, cb) -> cb.equal(getPath(root, container).get(field), value));
@ -46,7 +46,7 @@ public class SimpleCriteriaQuery<T> {
}
public Container<T> exists(List<JoinTable> joinTables, String field) {
Assert.isNotNull(field, nullPointer(FIELD));
Inspector.isNotNull(field, nullPointer(FIELD));
final Container<T> container = Container.of(joinTables);
container.setSpecification((root, query, cb) -> cb.isNotNull(getPath(root, container).get(field)));
@ -54,7 +54,7 @@ public class SimpleCriteriaQuery<T> {
}
public Container<T> likeIgnoreCase(List<JoinTable> joinTables, String field, String value) {
Assert.isNotNull(field, nullPointer(FIELD));
Inspector.isNotNull(field, nullPointer(FIELD));
final Container<T> container = Container.of(joinTables);
container.setSpecification((root, query, cb) -> cb.like(cb.lower(getPath(root, container).get(field)), value));
@ -62,7 +62,7 @@ public class SimpleCriteriaQuery<T> {
}
public Container<T> like(List<JoinTable> joinTables, String field, String value) {
Assert.isNotNull(field, nullPointer(FIELD));
Inspector.isNotNull(field, nullPointer(FIELD));
final Container<T> container = Container.of(joinTables);
container.setSpecification((root, query, cb) -> cb.like(getPath(root, container).get(field), value));
@ -70,7 +70,7 @@ public class SimpleCriteriaQuery<T> {
}
public <Y extends Comparable<? super Y>> Container<T> between(List<JoinTable> joinTables, String field, Y from, Y to) {
Assert.isNotNull(field, nullPointer(FIELD));
Inspector.isNotNull(field, nullPointer(FIELD));
final Container<T> container = Container.of(joinTables);
container.setSpecification((root, query, cb) -> cb.between(getPath(root, container).get(field), from, to));
@ -78,7 +78,7 @@ public class SimpleCriteriaQuery<T> {
}
public <Y extends Comparable<? super Y>> Container<T> greaterThan(List<JoinTable> joinTables, String field, Y value) {
Assert.isNotNull(field, nullPointer(FIELD));
Inspector.isNotNull(field, nullPointer(FIELD));
final Container<T> container = Container.of(joinTables);
container.setSpecification(((root, query, cb) -> cb.greaterThan(getPath(root, container).get(field), value)));
@ -86,7 +86,7 @@ public class SimpleCriteriaQuery<T> {
}
public <Y extends Comparable<? super Y>> Container<T> lessThan(List<JoinTable> joinTables, String field, Y value) {
Assert.isNotNull(field, nullPointer(FIELD));
Inspector.isNotNull(field, nullPointer(FIELD));
final Container<T> container = Container.of(joinTables);
container.setSpecification(((root, query, cb) -> cb.lessThan(getPath(root, container).get(field), value)));