diff --git a/haiti-bom/pom.xml b/haiti-bom/pom.xml
index c15e7d6..54b50bf 100644
--- a/haiti-bom/pom.xml
+++ b/haiti-bom/pom.xml
@@ -46,7 +46,6 @@
2.2
7.16.3
- 1.18.22
1.7.33
1.6.8
@@ -94,12 +93,6 @@
${haiti.utils.ver}
-
- org.projectlombok
- lombok
- ${lombok.ver}
-
-
org.elasticsearch
elasticsearch
@@ -145,11 +138,6 @@
org.apache.maven.plugins
maven-compiler-plugin
- ${plugin.maven.compiler.ver}
-
-
- 11
-
@@ -175,6 +163,15 @@
maven-gpg-plugin
${plugin.maven.gpg.ver}
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${plugin.maven.compiler.ver}
+
+
+ 11
+
+
diff --git a/haiti-context/pom.xml b/haiti-context/pom.xml
index 85a392c..1c62f17 100644
--- a/haiti-context/pom.xml
+++ b/haiti-context/pom.xml
@@ -31,15 +31,18 @@
dev.struchkov.haiti
haiti-exception
-
- org.projectlombok
- lombok
+ dev.struchkov.haiti
+ haiti-utils
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
org.sonatype.plugins
nexus-staging-maven-plugin
diff --git a/haiti-context/src/main/java/dev/struchkov/haiti/context/domain/BasicEntity.java b/haiti-context/src/main/java/dev/struchkov/haiti/context/domain/BasicEntity.java
index 8ed9dde..d239269 100644
--- a/haiti-context/src/main/java/dev/struchkov/haiti/context/domain/BasicEntity.java
+++ b/haiti-context/src/main/java/dev/struchkov/haiti/context/domain/BasicEntity.java
@@ -1,16 +1,14 @@
package dev.struchkov.haiti.context.domain;
-import lombok.NonNull;
-
/**
- * // TODO: 14.01.2021 Добавить описание.
+ * Базовая класс для сущностей.
*
* @author upagge 14.01.2021
*/
-public interface BasicEntity {
+public interface BasicEntity {
- K getId();
+ Key getId();
- void setId(@NonNull K id);
+ void setId(Key id);
}
diff --git a/haiti-context/src/main/java/dev/struchkov/haiti/context/domain/ExistsContainer.java b/haiti-context/src/main/java/dev/struchkov/haiti/context/domain/ExistsContainer.java
index 5d95cbf..16c000c 100644
--- a/haiti-context/src/main/java/dev/struchkov/haiti/context/domain/ExistsContainer.java
+++ b/haiti-context/src/main/java/dev/struchkov/haiti/context/domain/ExistsContainer.java
@@ -1,11 +1,7 @@
package dev.struchkov.haiti.context.domain;
-import lombok.AccessLevel;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.NonNull;
+import dev.struchkov.haiti.utils.Assert;
-import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
@@ -14,20 +10,37 @@ import java.util.Collections;
*
* @author upagge 11.01.2021
*/
-@Getter
-@AllArgsConstructor(access = AccessLevel.PROTECTED)
-public class ExistsContainer implements Serializable {
+public class ExistsContainer {
- protected final Collection container;
+ protected final Collection container;
protected final boolean allFound;
- protected final Collection idNoFound;
+ protected final Collection idNoFound;
- public static ExistsContainer allFind(@NonNull Collection container) {
+ protected ExistsContainer(Collection container, boolean allFound, Collection idNoFound) {
+ this.container = container;
+ this.allFound = allFound;
+ this.idNoFound = idNoFound;
+ }
+
+ public static ExistsContainer allFind(Collection container) {
+ Assert.isNotNull(container);
return new ExistsContainer<>(container, true, Collections.emptyList());
}
- public static ExistsContainer notAllFind(@NonNull Collection container, @NonNull Collection idNoFound) {
+ public static ExistsContainer notAllFind(Collection container, Collection idNoFound) {
+ Assert.isNotNull(container, idNoFound);
return new ExistsContainer<>(container, false, idNoFound);
}
+ public Collection getContainer() {
+ return container;
+ }
+
+ public boolean isAllFound() {
+ return allFound;
+ }
+
+ public Collection getIdNoFound() {
+ return idNoFound;
+ }
}
diff --git a/haiti-context/src/main/java/dev/struchkov/haiti/context/page/Pagination.java b/haiti-context/src/main/java/dev/struchkov/haiti/context/page/Pagination.java
index 6f13866..d6be34a 100644
--- a/haiti-context/src/main/java/dev/struchkov/haiti/context/page/Pagination.java
+++ b/haiti-context/src/main/java/dev/struchkov/haiti/context/page/Pagination.java
@@ -8,6 +8,6 @@ public interface Pagination {
Integer getSize();
- Set extends Sort> getSorts();
+ Set extends Sort> getSorts();
}
diff --git a/haiti-context/src/main/java/dev/struchkov/haiti/context/page/Sheet.java b/haiti-context/src/main/java/dev/struchkov/haiti/context/page/Sheet.java
index e0cbd72..af12211 100644
--- a/haiti-context/src/main/java/dev/struchkov/haiti/context/page/Sheet.java
+++ b/haiti-context/src/main/java/dev/struchkov/haiti/context/page/Sheet.java
@@ -3,7 +3,7 @@ package dev.struchkov.haiti.context.page;
import java.util.List;
import java.util.function.Function;
-public interface Sheet {
+public interface Sheet {
int getNumber();
@@ -13,10 +13,10 @@ public interface Sheet {
int getTotalPage();
- List getContent();
+ List getContent();
boolean hasContent();
- Sheet map(Function super T, ? extends U> converter);
+ Sheet map(Function super Entity, ? extends NewEntity> converter);
}
diff --git a/haiti-context/src/main/java/dev/struchkov/haiti/context/page/impl/PaginationImpl.java b/haiti-context/src/main/java/dev/struchkov/haiti/context/page/impl/PaginationImpl.java
index c858a9d..ce3a7ab 100644
--- a/haiti-context/src/main/java/dev/struchkov/haiti/context/page/impl/PaginationImpl.java
+++ b/haiti-context/src/main/java/dev/struchkov/haiti/context/page/impl/PaginationImpl.java
@@ -2,11 +2,9 @@ package dev.struchkov.haiti.context.page.impl;
import dev.struchkov.haiti.context.page.Pagination;
import dev.struchkov.haiti.context.page.Sort;
-import lombok.Getter;
import java.util.Set;
-@Getter
public class PaginationImpl implements Pagination {
private final Integer page;
@@ -32,4 +30,18 @@ public class PaginationImpl implements Pagination {
return new PaginationImpl(page, size, sorts);
}
+ @Override
+ public Integer getPage() {
+ return page;
+ }
+
+ @Override
+ public Integer getSize() {
+ return size;
+ }
+
+ @Override
+ public Set extends Sort> getSorts() {
+ return sorts;
+ }
}
diff --git a/haiti-context/src/main/java/dev/struchkov/haiti/context/page/impl/SheetImpl.java b/haiti-context/src/main/java/dev/struchkov/haiti/context/page/impl/SheetImpl.java
index 2544cb3..d2c9d18 100644
--- a/haiti-context/src/main/java/dev/struchkov/haiti/context/page/impl/SheetImpl.java
+++ b/haiti-context/src/main/java/dev/struchkov/haiti/context/page/impl/SheetImpl.java
@@ -1,9 +1,6 @@
package dev.struchkov.haiti.context.page.impl;
import dev.struchkov.haiti.context.page.Sheet;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter;
import java.util.Collections;
import java.util.List;
@@ -11,19 +8,24 @@ import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
-@Getter
-@Builder
-@AllArgsConstructor
-public class SheetImpl implements Sheet {
+public class SheetImpl implements Sheet {
private final int number;
private final int size;
private final long totalElement;
private final int totalPage;
- private final List content;
+ private final List content;
+
+ public SheetImpl(int number, int size, long totalElement, int totalPage, List content) {
+ this.number = number;
+ this.size = size;
+ this.totalElement = totalElement;
+ this.totalPage = totalPage;
+ this.content = content;
+ }
@Override
- public Sheet map(Function super T, ? extends U> function) {
+ public Sheet map(Function super Entity, ? extends U> function) {
return new SheetImpl<>(
this.number,
this.size,
@@ -43,8 +45,8 @@ public class SheetImpl implements Sheet {
);
}
- public Sheet filter(Predicate super T> predicate) {
- final List filterContent = content.stream().filter(predicate).collect(Collectors.toList());
+ public Sheet filter(Predicate super Entity> predicate) {
+ final List filterContent = content.stream().filter(predicate).collect(Collectors.toList());
return new SheetImpl<>(
this.number,
this.size,
@@ -58,4 +60,29 @@ public class SheetImpl implements Sheet {
return content != null && !content.isEmpty();
}
+ @Override
+ public int getNumber() {
+ return number;
+ }
+
+ @Override
+ public int getSize() {
+ return size;
+ }
+
+ @Override
+ public long getTotalElement() {
+ return totalElement;
+ }
+
+ @Override
+ public int getTotalPage() {
+ return totalPage;
+ }
+
+ @Override
+ public List getContent() {
+ return content;
+ }
+
}
diff --git a/haiti-context/src/main/java/dev/struchkov/haiti/context/page/impl/SortImpl.java b/haiti-context/src/main/java/dev/struchkov/haiti/context/page/impl/SortImpl.java
index 29c0ead..5de80df 100644
--- a/haiti-context/src/main/java/dev/struchkov/haiti/context/page/impl/SortImpl.java
+++ b/haiti-context/src/main/java/dev/struchkov/haiti/context/page/impl/SortImpl.java
@@ -2,20 +2,32 @@ package dev.struchkov.haiti.context.page.impl;
import dev.struchkov.haiti.context.enums.TypeSort;
import dev.struchkov.haiti.context.page.Sort;
-import lombok.AccessLevel;
-import lombok.Getter;
-import lombok.NonNull;
-import lombok.RequiredArgsConstructor;
-@Getter
-@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
+import static dev.struchkov.haiti.utils.Assert.isNotNull;
+
public class SortImpl implements Sort {
private final TypeSort type;
private final String field;
- public static Sort of(@NonNull TypeSort type, String field) {
+ private SortImpl(TypeSort type, String field) {
+ this.type = type;
+ this.field = field;
+ }
+
+ public static Sort of(TypeSort type, String field) {
+ isNotNull(type);
return new SortImpl(type, field);
}
+ @Override
+ public TypeSort getType() {
+ return type;
+ }
+
+ @Override
+ public String getField() {
+ return field;
+ }
+
}
diff --git a/haiti-context/src/main/java/dev/struchkov/haiti/context/repository/simple/CrudOperation.java b/haiti-context/src/main/java/dev/struchkov/haiti/context/repository/simple/CrudOperation.java
index ced2806..a6e5e4c 100644
--- a/haiti-context/src/main/java/dev/struchkov/haiti/context/repository/simple/CrudOperation.java
+++ b/haiti-context/src/main/java/dev/struchkov/haiti/context/repository/simple/CrudOperation.java
@@ -1,17 +1,15 @@
package dev.struchkov.haiti.context.repository.simple;
-import lombok.NonNull;
-
import java.util.Optional;
/**
* Контракт для реализации объекта, который будет взаимодействовать с хранилищем данных.
*
- * @param Класс сущности
- * @param Класс идентификатора
+ * @param Класс сущности
+ * @param Класс идентификатора
* @author upagge
*/
-public interface CrudOperation {
+public interface CrudOperation {
/**
* Сохраняет сущность в базу данных. Не проверяет на наличие в хранилище.
@@ -20,12 +18,12 @@ public interface CrudOperation {
* @param entity Сущность для сохранения
* @return Сохраненная сущность
*/
- T save(@NonNull T entity);
+ Entity save(Entity entity);
- Optional findById(@NonNull K primaryKey);
+ Optional findById(Key id);
- boolean existsById(@NonNull K primaryKey);
+ boolean existsById(Key id);
- void deleteById(@NonNull K primaryKey);
+ void deleteById(Key id);
}
diff --git a/haiti-context/src/main/java/dev/struchkov/haiti/context/repository/simple/MultipleOperation.java b/haiti-context/src/main/java/dev/struchkov/haiti/context/repository/simple/MultipleOperation.java
index 137e01e..09bda10 100644
--- a/haiti-context/src/main/java/dev/struchkov/haiti/context/repository/simple/MultipleOperation.java
+++ b/haiti-context/src/main/java/dev/struchkov/haiti/context/repository/simple/MultipleOperation.java
@@ -1,6 +1,5 @@
package dev.struchkov.haiti.context.repository.simple;
-import lombok.NonNull;
import dev.struchkov.haiti.context.domain.BasicEntity;
import java.util.Collection;
@@ -8,10 +7,10 @@ import java.util.List;
public interface MultipleOperation, K> {
- List saveAll(@NonNull Collection entities);
+ List saveAll(Collection entities);
- void deleteAllById(@NonNull Collection primaryKeys);
+ void deleteAllById(Collection primaryKeys);
- List findAllById(@NonNull Collection ids);
+ List findAllById(Collection ids);
}
diff --git a/haiti-context/src/main/java/dev/struchkov/haiti/context/repository/simple/PagingOperation.java b/haiti-context/src/main/java/dev/struchkov/haiti/context/repository/simple/PagingOperation.java
index 7e32492..f9a6c27 100644
--- a/haiti-context/src/main/java/dev/struchkov/haiti/context/repository/simple/PagingOperation.java
+++ b/haiti-context/src/main/java/dev/struchkov/haiti/context/repository/simple/PagingOperation.java
@@ -1,11 +1,10 @@
package dev.struchkov.haiti.context.repository.simple;
-import lombok.NonNull;
import dev.struchkov.haiti.context.page.Pagination;
import dev.struchkov.haiti.context.page.Sheet;
public interface PagingOperation {
- Sheet findAll(@NonNull Pagination pagination);
+ Sheet findAll(Pagination pagination);
}
diff --git a/haiti-context/src/main/java/dev/struchkov/haiti/context/service/SimpleManagerService.java b/haiti-context/src/main/java/dev/struchkov/haiti/context/service/SimpleManagerService.java
index b1eba11..c802917 100644
--- a/haiti-context/src/main/java/dev/struchkov/haiti/context/service/SimpleManagerService.java
+++ b/haiti-context/src/main/java/dev/struchkov/haiti/context/service/SimpleManagerService.java
@@ -5,6 +5,7 @@ import dev.struchkov.haiti.context.service.simple.MultipleService;
import dev.struchkov.haiti.context.service.simple.PagingService;
import dev.struchkov.haiti.context.service.simple.SimpleService;
-public interface SimpleManagerService, K> extends SimpleService, MultipleService, PagingService {
+public interface SimpleManagerService, Key>
+ extends SimpleService, MultipleService, PagingService {
}
diff --git a/haiti-context/src/main/java/dev/struchkov/haiti/context/service/simple/FilterService.java b/haiti-context/src/main/java/dev/struchkov/haiti/context/service/simple/FilterService.java
index 9ff7f4f..b2e02cb 100644
--- a/haiti-context/src/main/java/dev/struchkov/haiti/context/service/simple/FilterService.java
+++ b/haiti-context/src/main/java/dev/struchkov/haiti/context/service/simple/FilterService.java
@@ -1,12 +1,11 @@
package dev.struchkov.haiti.context.service.simple;
-import lombok.NonNull;
import dev.struchkov.haiti.context.page.Pagination;
import dev.struchkov.haiti.context.page.Sheet;
import java.util.Optional;
-public interface FilterService {
+public interface FilterService {
/**
* Получить все элементы по заданному фильтру.
@@ -14,27 +13,27 @@ public interface FilterService {
* @param filter Фильтр
* @param pagination Пагинация
*/
- Sheet getAll(@NonNull F filter, @NonNull Pagination pagination);
+ Sheet getAll(Filter filter, Pagination pagination);
/**
* Возвращает первый найденный объект по фильтру.
*
* @param filter Объект фильтра
*/
- Optional getFirst(@NonNull F filter);
+ Optional getFirst(Filter filter);
/**
* Проверка на наличие хотя бы одной сущности, которая удовлетворяет определенному набору параметров.
*
* @param filter Набор параметров
*/
- boolean exists(@NonNull F filter);
+ boolean exists(Filter filter);
/**
* Получить количество сущностей, которые удовлетворяют определенному набору параметров.
*
* @param filter Набор параметров
*/
- long count(@NonNull F filter);
+ long count(Filter filter);
}
diff --git a/haiti-context/src/main/java/dev/struchkov/haiti/context/service/simple/MultipleService.java b/haiti-context/src/main/java/dev/struchkov/haiti/context/service/simple/MultipleService.java
index f63ac3d..d28c61e 100644
--- a/haiti-context/src/main/java/dev/struchkov/haiti/context/service/simple/MultipleService.java
+++ b/haiti-context/src/main/java/dev/struchkov/haiti/context/service/simple/MultipleService.java
@@ -2,19 +2,18 @@ package dev.struchkov.haiti.context.service.simple;
import dev.struchkov.haiti.context.domain.BasicEntity;
import dev.struchkov.haiti.context.domain.ExistsContainer;
-import lombok.NonNull;
import java.util.Collection;
import java.util.List;
-public interface MultipleService, K> {
+public interface MultipleService, Key> {
- List createAll(@NonNull Collection entities);
+ List createAll(Collection entities);
- List updateAll(@NonNull Collection entities);
+ List updateAll(Collection entities);
- void deleteAllById(@NonNull Collection ids);
+ void deleteAllById(Collection ids);
- ExistsContainer existsById(@NonNull Collection ids);
+ ExistsContainer existsById(Collection ids);
}
diff --git a/haiti-context/src/main/java/dev/struchkov/haiti/context/service/simple/PagingService.java b/haiti-context/src/main/java/dev/struchkov/haiti/context/service/simple/PagingService.java
index 5f8596b..bb84006 100644
--- a/haiti-context/src/main/java/dev/struchkov/haiti/context/service/simple/PagingService.java
+++ b/haiti-context/src/main/java/dev/struchkov/haiti/context/service/simple/PagingService.java
@@ -1,17 +1,16 @@
package dev.struchkov.haiti.context.service.simple;
-import lombok.NonNull;
import dev.struchkov.haiti.context.page.Pagination;
import dev.struchkov.haiti.context.page.Sheet;
/**
* Расширение базового контракта сервисов с добавлением пагинации.
*
- * @param Сущность сервиса.
+ * @param Сущность сервиса.
* @author upagge 26.05.20
*/
-public interface PagingService {
+public interface PagingService {
- Sheet getAll(@NonNull Pagination pagination);
+ Sheet getAll(Pagination pagination);
}
diff --git a/haiti-context/src/main/java/dev/struchkov/haiti/context/service/simple/SimpleService.java b/haiti-context/src/main/java/dev/struchkov/haiti/context/service/simple/SimpleService.java
index 2f869f1..573c442 100644
--- a/haiti-context/src/main/java/dev/struchkov/haiti/context/service/simple/SimpleService.java
+++ b/haiti-context/src/main/java/dev/struchkov/haiti/context/service/simple/SimpleService.java
@@ -1,26 +1,24 @@
package dev.struchkov.haiti.context.service.simple;
-import lombok.NonNull;
-
import java.util.Optional;
/**
* Базовый контракт для сервисов.
*
- * @param Сущность сервиса.
+ * @param Сущность сервиса.
*/
-public interface SimpleService {
+public interface SimpleService {
- T create(@NonNull T entity);
+ Entity create(Entity entity);
- T update(@NonNull T entity);
+ Entity update(Entity entity);
- Optional getById(@NonNull K primaryKey);
+ Optional getById(Key id);
- T getByIdOrThrow(@NonNull K primaryKey);
+ Entity getByIdOrThrow(Key id);
- boolean existsById(@NonNull K primaryKey);
+ boolean existsById(Key id);
- void deleteById(@NonNull K primaryKey);
+ void deleteById(Key id);
}
diff --git a/haiti-context/src/main/java/module-info.java b/haiti-context/src/main/java/module-info.java
new file mode 100644
index 0000000..f9b2d37
--- /dev/null
+++ b/haiti-context/src/main/java/module-info.java
@@ -0,0 +1,9 @@
+module haiti.context {
+ exports dev.struchkov.haiti.context.service.simple;
+ exports dev.struchkov.haiti.context.repository.simple;
+ exports dev.struchkov.haiti.context.repository;
+ exports dev.struchkov.haiti.context.domain;
+ exports dev.struchkov.haiti.context.service;
+ exports dev.struchkov.haiti.context.page;
+ requires transitive haiti.utils;
+}
\ No newline at end of file
diff --git a/haiti-core/pom.xml b/haiti-core/pom.xml
index 7caaf65..ab4d6ec 100644
--- a/haiti-core/pom.xml
+++ b/haiti-core/pom.xml
@@ -32,11 +32,6 @@
haiti-context
-
- org.projectlombok
- lombok
-
-
dev.struchkov.haiti
haiti-filter
@@ -45,6 +40,10 @@
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
org.sonatype.plugins
nexus-staging-maven-plugin
diff --git a/haiti-core/src/main/java/dev/struchkov/haiti/core/repository/SimpleManagerRepositoryMap.java b/haiti-core/src/main/java/dev/struchkov/haiti/core/repository/SimpleManagerRepositoryMap.java
index 688a046..9be5879 100644
--- a/haiti-core/src/main/java/dev/struchkov/haiti/core/repository/SimpleManagerRepositoryMap.java
+++ b/haiti-core/src/main/java/dev/struchkov/haiti/core/repository/SimpleManagerRepositoryMap.java
@@ -4,7 +4,7 @@ import dev.struchkov.haiti.context.domain.BasicEntity;
import dev.struchkov.haiti.context.page.Pagination;
import dev.struchkov.haiti.context.page.Sheet;
import dev.struchkov.haiti.context.repository.SimpleManagerRepository;
-import lombok.NonNull;
+import dev.struchkov.haiti.utils.Assert;
import java.util.Collection;
import java.util.HashMap;
@@ -13,13 +13,16 @@ import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
+import static dev.struchkov.haiti.utils.Strings.ERR_OPERATION_NOT_SUPPORTED;
+
public class SimpleManagerRepositoryMap> implements SimpleManagerRepository {
protected final Map map = new HashMap<>();
protected long key = 0;
@Override
- public T save(@NonNull T accessTarget) {
+ public T save(T accessTarget) {
+ Assert.isNotNull(accessTarget);
accessTarget.setId(key);
map.put(key, accessTarget);
key++;
@@ -27,42 +30,48 @@ public class SimpleManagerRepositoryMap> implements
}
@Override
- public Optional findById(@NonNull Long id) {
+ public Optional findById(Long id) {
+ Assert.isNotNull(id);
return Optional.ofNullable(map.get(id));
}
@Override
- public boolean existsById(@NonNull Long id) {
+ public boolean existsById(Long id) {
+ Assert.isNotNull(id);
return map.containsKey(id);
}
@Override
- public void deleteById(@NonNull Long id) {
+ public void deleteById(Long id) {
+ Assert.isNotNull(id);
map.remove(id);
}
@Override
- public List saveAll(@NonNull Collection accessTargets) {
+ public List saveAll(Collection accessTargets) {
+ Assert.isNotNull(accessTargets);
return accessTargets.stream()
.map(this::save)
.collect(Collectors.toList());
}
@Override
- public void deleteAllById(@NonNull Collection accessTargets) {
+ public void deleteAllById(Collection accessTargets) {
+ Assert.isNotNull(accessTargets);
accessTargets.forEach(map::remove);
}
@Override
- public List findAllById(@NonNull Collection ids) {
+ public List findAllById(Collection ids) {
+ Assert.isNotNull(ids);
return ids.stream()
.map(map::get)
.collect(Collectors.toList());
}
@Override
- public Sheet findAll(@NonNull Pagination pagination) {
- return null;
+ public Sheet findAll(Pagination pagination) {
+ throw new IllegalStateException(ERR_OPERATION_NOT_SUPPORTED);
}
}
diff --git a/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractFilterService.java b/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractFilterService.java
index b21d58c..e64c30b 100644
--- a/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractFilterService.java
+++ b/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractFilterService.java
@@ -5,36 +5,42 @@ import dev.struchkov.haiti.context.page.Sheet;
import dev.struchkov.haiti.context.service.simple.FilterService;
import dev.struchkov.haiti.filter.Filter;
import dev.struchkov.haiti.filter.FilterOperation;
-import lombok.NonNull;
-import lombok.RequiredArgsConstructor;
+import dev.struchkov.haiti.utils.Assert;
import java.util.Optional;
-@RequiredArgsConstructor
-public abstract class AbstractFilterService implements FilterService {
+public abstract class AbstractFilterService implements FilterService {
- protected final FilterOperation filterOperation;
+ protected final FilterOperation filterOperation;
+
+ protected AbstractFilterService(FilterOperation filterOperation) {
+ this.filterOperation = filterOperation;
+ }
@Override
- public Sheet getAll(@NonNull F filter, Pagination pagination) {
+ public Sheet getAll(F filter, Pagination pagination) {
+ Assert.isNotNull(filter);
return filterOperation.findAll(createFilter(filter), pagination);
}
@Override
- public Optional getFirst(@NonNull F filter) {
+ public Optional getFirst(F filter) {
+ Assert.isNotNull(filter);
return filterOperation.findFirst(createFilter(filter));
}
@Override
- public boolean exists(@NonNull F filter) {
+ public boolean exists(F filter) {
+ Assert.isNotNull(filter);
return filterOperation.exists(createFilter(filter));
}
@Override
- public long count(@NonNull F filter) {
+ public long count(F filter) {
+ Assert.isNotNull(filter);
return filterOperation.count(createFilter(filter));
}
- protected abstract Filter createFilter(@NonNull F filter);
+ protected abstract Filter createFilter(F filter);
}
diff --git a/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractMultipleService.java b/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractMultipleService.java
index 5c4e14c..432253f 100644
--- a/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractMultipleService.java
+++ b/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractMultipleService.java
@@ -6,36 +6,43 @@ import dev.struchkov.haiti.context.repository.simple.MultipleOperation;
import dev.struchkov.haiti.context.service.simple.MultipleService;
import dev.struchkov.haiti.context.service.simple.SimpleService;
import dev.struchkov.haiti.core.util.ServiceOperation;
-import lombok.NonNull;
-import lombok.RequiredArgsConstructor;
+import dev.struchkov.haiti.utils.Assert;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
-@RequiredArgsConstructor
-public abstract class AbstractMultipleService, K> implements MultipleService {
+public abstract class AbstractMultipleService, Key> implements MultipleService {
- private final SimpleService simpleService;
- private final MultipleOperation multipleOperation;
+ private final SimpleService simpleService;
+ private final MultipleOperation multipleOperation;
+
+ protected AbstractMultipleService(SimpleService simpleService, MultipleOperation multipleOperation) {
+ this.simpleService = simpleService;
+ this.multipleOperation = multipleOperation;
+ }
@Override
- public void deleteAllById(@NonNull Collection ids) {
+ public void deleteAllById(Collection ids) {
+ Assert.isNotNull(ids);
multipleOperation.deleteAllById(ids);
}
@Override
- public List createAll(@NonNull Collection entities) {
+ public List createAll(Collection entities) {
+ Assert.isNotNull(entities);
return entities.stream().map(simpleService::create).collect(Collectors.toList());
}
@Override
- public List updateAll(@NonNull Collection entities) {
+ public List updateAll(Collection entities) {
+ Assert.isNotNull(entities);
return entities.stream().map(simpleService::update).collect(Collectors.toList());
}
@Override
- public ExistsContainer existsById(@NonNull Collection ids) {
+ public ExistsContainer existsById(Collection ids) {
+ Assert.isNotNull(ids);
return ServiceOperation.existsContainerById(multipleOperation, ids);
}
diff --git a/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractPagingService.java b/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractPagingService.java
index 644da40..effb254 100644
--- a/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractPagingService.java
+++ b/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractPagingService.java
@@ -4,16 +4,19 @@ import dev.struchkov.haiti.context.page.Pagination;
import dev.struchkov.haiti.context.page.Sheet;
import dev.struchkov.haiti.context.repository.simple.PagingOperation;
import dev.struchkov.haiti.context.service.simple.PagingService;
-import lombok.NonNull;
-import lombok.RequiredArgsConstructor;
+import dev.struchkov.haiti.utils.Assert;
-@RequiredArgsConstructor
public abstract class AbstractPagingService implements PagingService {
private final PagingOperation pagingOperation;
+ protected AbstractPagingService(PagingOperation pagingOperation) {
+ this.pagingOperation = pagingOperation;
+ }
+
@Override
- public Sheet getAll(@NonNull Pagination pagination) {
+ public Sheet getAll(Pagination pagination) {
+ Assert.isNotNull(pagination);
return pagingOperation.findAll(pagination);
}
diff --git a/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractSimpleManagerService.java b/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractSimpleManagerService.java
index d757711..d021844 100644
--- a/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractSimpleManagerService.java
+++ b/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractSimpleManagerService.java
@@ -8,61 +8,72 @@ import dev.struchkov.haiti.context.page.Sheet;
import dev.struchkov.haiti.context.repository.SimpleManagerRepository;
import dev.struchkov.haiti.context.service.SimpleManagerService;
import dev.struchkov.haiti.core.util.ServiceOperation;
-import lombok.NonNull;
-import lombok.RequiredArgsConstructor;
+import dev.struchkov.haiti.utils.Assert;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
-@RequiredArgsConstructor
-public abstract class AbstractSimpleManagerService, K> implements SimpleManagerService {
+public abstract class AbstractSimpleManagerService, Key> implements SimpleManagerService {
- protected final SimpleManagerRepository repository;
+ protected final SimpleManagerRepository repository;
- @Override
- public void deleteAllById(@NonNull Collection primaryKeys) {
- ServiceOperation.deleteAllById(repository, primaryKeys);
+ protected AbstractSimpleManagerService(SimpleManagerRepository repository) {
+ this.repository = repository;
}
@Override
- public Sheet getAll(@NonNull Pagination pagination) {
+ public void deleteAllById(Collection ids) {
+ Assert.isNotNull(ids);
+ ServiceOperation.deleteAllById(repository, ids);
+ }
+
+ @Override
+ public Sheet getAll(Pagination pagination) {
+ Assert.isNotNull(pagination);
return ServiceOperation.getAll(repository, pagination);
}
@Override
- public Optional getById(@NonNull K primaryKey) {
- return ServiceOperation.getById(repository, primaryKey);
+ public Optional getById(Key id) {
+ Assert.isNotNull(id);
+ return ServiceOperation.getById(repository, id);
}
@Override
- public T getByIdOrThrow(@NonNull K primaryKey) {
- return getById(primaryKey).orElseThrow(NotFoundException.supplier("Объект не найден. Идентификатор: ", primaryKey));
+ public Entity getByIdOrThrow(Key id) {
+ Assert.isNotNull(id);
+ return getById(id).orElseThrow(NotFoundException.supplier("Объект не найден. Идентификатор: ", id));
}
@Override
- public boolean existsById(@NonNull K primaryKey) {
- return ServiceOperation.existsById(repository, primaryKey);
+ public boolean existsById(Key id) {
+ Assert.isNotNull(id);
+ return ServiceOperation.existsById(repository, id);
}
@Override
- public void deleteById(@NonNull K primaryKey) {
- ServiceOperation.deleteById(repository, primaryKey);
+ public void deleteById(Key id) {
+ Assert.isNotNull(id);
+ ServiceOperation.deleteById(repository, id);
}
@Override
- public List createAll(@NonNull Collection entities) {
+ public List createAll(Collection entities) {
+ Assert.isNotNull(entities);
return entities.stream().map(this::create).collect(Collectors.toList());
}
@Override
- public List updateAll(@NonNull Collection entities) {
+ public List updateAll(Collection entities) {
+ Assert.isNotNull(entities);
return entities.stream().map(this::update).collect(Collectors.toList());
}
@Override
- public ExistsContainer existsById(@NonNull Collection ids) {
+ public ExistsContainer existsById(Collection ids) {
+ Assert.isNotNull(ids);
return ServiceOperation.existsContainerById(repository, ids);
}
diff --git a/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractSimpleService.java b/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractSimpleService.java
index 98117d9..5e3ae56 100644
--- a/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractSimpleService.java
+++ b/haiti-core/src/main/java/dev/struchkov/haiti/core/service/AbstractSimpleService.java
@@ -3,29 +3,34 @@ package dev.struchkov.haiti.core.service;
import dev.struchkov.haiti.context.repository.simple.CrudOperation;
import dev.struchkov.haiti.context.service.simple.SimpleService;
import dev.struchkov.haiti.core.util.ServiceOperation;
-import lombok.NonNull;
-import lombok.RequiredArgsConstructor;
+import dev.struchkov.haiti.utils.Assert;
import java.util.Optional;
-@RequiredArgsConstructor
-public abstract class AbstractSimpleService implements SimpleService {
+public abstract class AbstractSimpleService implements SimpleService {
- private final CrudOperation crudOperation;
+ private final CrudOperation crudOperation;
- @Override
- public Optional getById(@NonNull K primaryKey) {
- return ServiceOperation.getById(crudOperation, primaryKey);
+ protected AbstractSimpleService(CrudOperation crudOperation) {
+ this.crudOperation = crudOperation;
}
@Override
- public boolean existsById(@NonNull K primaryKey) {
- return ServiceOperation.existsById(crudOperation, primaryKey);
+ public Optional getById(Key id) {
+ Assert.isNotNull(id);
+ return ServiceOperation.getById(crudOperation, id);
}
@Override
- public void deleteById(@NonNull K primaryKey) {
- ServiceOperation.deleteById(crudOperation, primaryKey);
+ public boolean existsById(Key id) {
+ Assert.isNotNull(id);
+ return ServiceOperation.existsById(crudOperation, id);
+ }
+
+ @Override
+ public void deleteById(Key id) {
+ Assert.isNotNull(id);
+ ServiceOperation.deleteById(crudOperation, id);
}
}
diff --git a/haiti-core/src/main/java/dev/struchkov/haiti/core/util/ServiceOperation.java b/haiti-core/src/main/java/dev/struchkov/haiti/core/util/ServiceOperation.java
index 2050e10..8392c47 100644
--- a/haiti-core/src/main/java/dev/struchkov/haiti/core/util/ServiceOperation.java
+++ b/haiti-core/src/main/java/dev/struchkov/haiti/core/util/ServiceOperation.java
@@ -7,7 +7,6 @@ import dev.struchkov.haiti.context.page.Sheet;
import dev.struchkov.haiti.context.repository.simple.CrudOperation;
import dev.struchkov.haiti.context.repository.simple.MultipleOperation;
import dev.struchkov.haiti.context.repository.simple.PagingOperation;
-import lombok.experimental.UtilityClass;
import java.util.Collection;
import java.util.List;
@@ -15,27 +14,32 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
-@UtilityClass
+import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
+
public final class ServiceOperation {
- public static , K> void deleteAllById(MultipleOperation repository, Collection primaryKeys) {
- repository.deleteAllById(primaryKeys);
+ private ServiceOperation() {
+ utilityClass();
}
- public static Sheet getAll(PagingOperation repository, Pagination pagination) {
+ public static , Key> void deleteAllById(MultipleOperation repository, Collection ids) {
+ repository.deleteAllById(ids);
+ }
+
+ public static Sheet getAll(PagingOperation repository, Pagination pagination) {
return repository.findAll(pagination);
}
- public static Optional getById(CrudOperation repository, K primaryKey) {
- return repository.findById(primaryKey);
+ public static Optional getById(CrudOperation repository, Key id) {
+ return repository.findById(id);
}
- public static boolean existsById(CrudOperation repository, K primaryKey) {
- return repository.existsById(primaryKey);
+ public static boolean existsById(CrudOperation repository, Key id) {
+ return repository.existsById(id);
}
- public static void deleteById(CrudOperation repository, K primaryKey) {
- repository.deleteById(primaryKey);
+ public static void deleteById(CrudOperation repository, Key id) {
+ repository.deleteById(id);
}
public static > ExistsContainer existsContainerById(MultipleOperation multipleOperation, Collection ids) {
@@ -52,4 +56,5 @@ public final class ServiceOperation {
return ExistsContainer.notAllFind(existsEntity, noExistsId);
}
}
+
}
diff --git a/haiti-core/src/main/java/module-info.java b/haiti-core/src/main/java/module-info.java
new file mode 100644
index 0000000..a60e1b5
--- /dev/null
+++ b/haiti-core/src/main/java/module-info.java
@@ -0,0 +1,5 @@
+module haiti.core {
+ requires haiti.context;
+ requires haiti.exception;
+ requires haiti.filter;
+}
\ No newline at end of file
diff --git a/haiti-exception/pom.xml b/haiti-exception/pom.xml
index f0a1919..408f1a0 100644
--- a/haiti-exception/pom.xml
+++ b/haiti-exception/pom.xml
@@ -18,6 +18,7 @@
false
+
11
${java.version}
${java.version}
@@ -27,6 +28,10 @@
+