From 40803049a4c25a04ce1758525b6c9495423c378a Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Sat, 22 Jan 2022 11:21:36 +0300 Subject: [PATCH] delete lombok --- haiti-bom/pom.xml | 21 ++++---- haiti-context/pom.xml | 9 ++-- .../haiti/context/domain/BasicEntity.java | 10 ++-- .../haiti/context/domain/ExistsContainer.java | 37 +++++++++----- .../haiti/context/page/Pagination.java | 2 +- .../struchkov/haiti/context/page/Sheet.java | 6 +-- .../context/page/impl/PaginationImpl.java | 16 +++++- .../haiti/context/page/impl/SheetImpl.java | 49 ++++++++++++++---- .../haiti/context/page/impl/SortImpl.java | 26 +++++++--- .../repository/simple/CrudOperation.java | 16 +++--- .../repository/simple/MultipleOperation.java | 7 ++- .../repository/simple/PagingOperation.java | 3 +- .../context/service/SimpleManagerService.java | 3 +- .../context/service/simple/FilterService.java | 11 ++-- .../service/simple/MultipleService.java | 11 ++-- .../context/service/simple/PagingService.java | 7 ++- .../context/service/simple/SimpleService.java | 18 +++---- haiti-context/src/main/java/module-info.java | 9 ++++ haiti-core/pom.xml | 9 ++-- .../SimpleManagerRepositoryMap.java | 29 +++++++---- .../core/service/AbstractFilterService.java | 26 ++++++---- .../core/service/AbstractMultipleService.java | 27 ++++++---- .../core/service/AbstractPagingService.java | 11 ++-- .../service/AbstractSimpleManagerService.java | 51 +++++++++++-------- .../core/service/AbstractSimpleService.java | 29 ++++++----- .../haiti/core/util/ServiceOperation.java | 27 ++++++---- haiti-core/src/main/java/module-info.java | 5 ++ haiti-exception/pom.xml | 5 ++ .../src/main/java/module-info.java | 3 ++ haiti-filter/pom.xml | 5 -- .../haiti/filter/FilterOperation.java | 9 ++-- .../struchkov/haiti/filter/FilterQuery.java | 16 +++--- .../filter/exception/FilterException.java | 2 +- haiti-filter/src/main/java/module-info.java | 6 +++ haiti-utils/pom.xml | 9 ++-- .../dev/struchkov/haiti/utils/Assert.java | 43 +++++++++++++--- .../dev/struchkov/haiti/utils/Exceptions.java | 15 ++++++ .../struchkov/haiti/utils/ObjectUtils.java | 23 ++++++--- .../dev/struchkov/haiti/utils/Strings.java | 13 +++-- haiti-utils/src/main/java/module-info.java | 6 +++ pom.xml | 25 +++++---- 41 files changed, 417 insertions(+), 238 deletions(-) create mode 100644 haiti-context/src/main/java/module-info.java create mode 100644 haiti-core/src/main/java/module-info.java create mode 100644 haiti-exception/src/main/java/module-info.java create mode 100644 haiti-filter/src/main/java/module-info.java create mode 100644 haiti-utils/src/main/java/dev/struchkov/haiti/utils/Exceptions.java create mode 100644 haiti-utils/src/main/java/module-info.java 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 - 11 - @@ -175,6 +163,15 @@ maven-gpg-plugin ${plugin.maven.gpg.ver} + + org.apache.maven.plugins + maven-compiler-plugin + ${plugin.maven.compiler.ver} + + 11 + 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 getSorts(); + Set 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 converter); + Sheet map(Function 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 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 function) { + public Sheet map(Function function) { return new SheetImpl<>( this.number, this.size, @@ -43,8 +45,8 @@ public class SheetImpl implements Sheet { ); } - public Sheet filter(Predicate predicate) { - final List filterContent = content.stream().filter(predicate).collect(Collectors.toList()); + public Sheet filter(Predicate 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 @@ + + org.apache.maven.plugins + maven-compiler-plugin + org.sonatype.plugins nexus-staging-maven-plugin diff --git a/haiti-exception/src/main/java/module-info.java b/haiti-exception/src/main/java/module-info.java new file mode 100644 index 0000000..2e42231 --- /dev/null +++ b/haiti-exception/src/main/java/module-info.java @@ -0,0 +1,3 @@ +module haiti.exception { + exports dev.struchkov.haiti.context.exception; +} \ No newline at end of file diff --git a/haiti-filter/pom.xml b/haiti-filter/pom.xml index b14c2dc..9b7845c 100644 --- a/haiti-filter/pom.xml +++ b/haiti-filter/pom.xml @@ -27,11 +27,6 @@ - - org.projectlombok - lombok - - dev.struchkov.haiti haiti-context diff --git a/haiti-filter/src/main/java/dev/struchkov/haiti/filter/FilterOperation.java b/haiti-filter/src/main/java/dev/struchkov/haiti/filter/FilterOperation.java index 54a27f9..fe98fca 100644 --- a/haiti-filter/src/main/java/dev/struchkov/haiti/filter/FilterOperation.java +++ b/haiti-filter/src/main/java/dev/struchkov/haiti/filter/FilterOperation.java @@ -1,6 +1,5 @@ package dev.struchkov.haiti.filter; -import lombok.NonNull; import dev.struchkov.haiti.context.page.Pagination; import dev.struchkov.haiti.context.page.Sheet; @@ -8,12 +7,12 @@ import java.util.Optional; public interface FilterOperation { - Sheet findAll(@NonNull Filter filter, @NonNull Pagination pagination); + Sheet findAll(Filter filter, Pagination pagination); - Optional findFirst(@NonNull Filter filter); + Optional findFirst(Filter filter); - boolean exists(@NonNull Filter filter); + boolean exists(Filter filter); - long count(@NonNull Filter filter); + long count(Filter filter); } diff --git a/haiti-filter/src/main/java/dev/struchkov/haiti/filter/FilterQuery.java b/haiti-filter/src/main/java/dev/struchkov/haiti/filter/FilterQuery.java index 67944a5..cb7bddf 100644 --- a/haiti-filter/src/main/java/dev/struchkov/haiti/filter/FilterQuery.java +++ b/haiti-filter/src/main/java/dev/struchkov/haiti/filter/FilterQuery.java @@ -1,7 +1,5 @@ package dev.struchkov.haiti.filter; -import lombok.NonNull; - import java.util.Set; public interface FilterQuery { @@ -13,11 +11,11 @@ public interface FilterQuery { * @param from Начало интервала * @param to Конец интервала */ - > FilterQuery between(@NonNull String field, Y from, Y to); + > FilterQuery between(String field, Y from, Y to); - > FilterQuery greaterThan(@NonNull String field, Y value); + > FilterQuery greaterThan(String field, Y value); - > FilterQuery lessThan(@NonNull String field, Y value); + > FilterQuery lessThan(String field, Y value); /** * Добавляет в запрос проверку по значению поля @@ -25,7 +23,7 @@ public interface FilterQuery { * @param field Название поля * @param value Значение поля для проверки */ - FilterQuery matchPhrase(@NonNull String field, Object value); + FilterQuery matchPhrase(String field, Object value); /** * Добавляет в запрос проверку по нескольким значениям одного поля @@ -33,7 +31,7 @@ public interface FilterQuery { * @param field Название поля * @param value Значения поля */ - FilterQuery matchPhrase(@NonNull String field, Set value); + FilterQuery matchPhrase(String field, Set value); /** * Добавляет в запрос проверку на NULL значение поля @@ -48,7 +46,7 @@ public interface FilterQuery { * @param field Названия поля * @param value Часть искомого значения */ - FilterQuery like(@NonNull String field, String value, boolean ignoreCase); + FilterQuery like(String field, String value, boolean ignoreCase); /** * Добавляет в запрос поиск по флагу, который конвертируется в диапазон @@ -56,7 +54,7 @@ public interface FilterQuery { * @param flag Значение флага * @param field Поле для проверки */ - FilterQuery checkBoolInt(@NonNull String field, Boolean flag); + FilterQuery checkBoolInt(String field, Boolean flag); Q build(); diff --git a/haiti-filter/src/main/java/dev/struchkov/haiti/filter/exception/FilterException.java b/haiti-filter/src/main/java/dev/struchkov/haiti/filter/exception/FilterException.java index f38edf4..6c35025 100644 --- a/haiti-filter/src/main/java/dev/struchkov/haiti/filter/exception/FilterException.java +++ b/haiti-filter/src/main/java/dev/struchkov/haiti/filter/exception/FilterException.java @@ -3,7 +3,7 @@ package dev.struchkov.haiti.filter.exception; import dev.struchkov.haiti.context.exception.BasicException; /** - * // TODO: 09.11.2020 Добавить описание. + * Исключения связанные с работой фильтров. * * @author upagge 09.11.2020 */ diff --git a/haiti-filter/src/main/java/module-info.java b/haiti-filter/src/main/java/module-info.java new file mode 100644 index 0000000..f049a3a --- /dev/null +++ b/haiti-filter/src/main/java/module-info.java @@ -0,0 +1,6 @@ +module haiti.filter { + exports dev.struchkov.haiti.filter; + + requires haiti.exception; + requires haiti.context; +} \ No newline at end of file diff --git a/haiti-utils/pom.xml b/haiti-utils/pom.xml index 5a36f85..d5b76a5 100644 --- a/haiti-utils/pom.xml +++ b/haiti-utils/pom.xml @@ -31,15 +31,14 @@ dev.struchkov.haiti haiti-exception - - - org.projectlombok - lombok - + + org.apache.maven.plugins + maven-compiler-plugin + org.sonatype.plugins nexus-staging-maven-plugin diff --git a/haiti-utils/src/main/java/dev/struchkov/haiti/utils/Assert.java b/haiti-utils/src/main/java/dev/struchkov/haiti/utils/Assert.java index 757ae2f..f382404 100644 --- a/haiti-utils/src/main/java/dev/struchkov/haiti/utils/Assert.java +++ b/haiti-utils/src/main/java/dev/struchkov/haiti/utils/Assert.java @@ -1,21 +1,22 @@ package dev.struchkov.haiti.utils; -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import lombok.experimental.UtilityClass; - import java.util.Arrays; import java.util.Objects; import java.util.function.Supplier; +import static dev.struchkov.haiti.utils.Exceptions.utilityClass; + /** - * // TODO: 06.09.2020 Добавить описание. + * Утилитарный класс для различных проверок. * * @author upagge 06.09.2020 */ -@NoArgsConstructor(access = AccessLevel.PRIVATE) public final class Assert { + public Assert() { + utilityClass(); + } + /** * Проверка на null значение с возвращением исключения, если объект не null. * @@ -46,6 +47,30 @@ public final class Assert { } } + /** + * Проверка на null значение с возвращением исключения, если объект null. + * + * @param object Проверяемый объект + */ + public static void isNotNull(Object object) { + if (object == null) { + throw new NullPointerException("Object cannot be null"); + } + } + + /** + * Проверка на null значение с возвращением исключения, если объект null. + * + * @param objects Проверяемый объект + */ + public static void isNotNull(Object... objects) { + for (Object o : objects) { + if (o == null) { + throw new NullPointerException("Object cannot be null"); + } + } + } + /** * Проверка на true значение с возвращением исключения, если flag не true. * @@ -70,9 +95,13 @@ public final class Assert { } } - @UtilityClass + public static final class Utils { + public Utils() { + utilityClass(); + } + public static Supplier nullPointer(String fieldName) { return () -> new NullPointerException(fieldName + " is marked non-null but is null"); } diff --git a/haiti-utils/src/main/java/dev/struchkov/haiti/utils/Exceptions.java b/haiti-utils/src/main/java/dev/struchkov/haiti/utils/Exceptions.java new file mode 100644 index 0000000..6325de5 --- /dev/null +++ b/haiti-utils/src/main/java/dev/struchkov/haiti/utils/Exceptions.java @@ -0,0 +1,15 @@ +package dev.struchkov.haiti.utils; + +public final class Exceptions { + + public static final IllegalStateException UTILITY_CLASS = new IllegalStateException(Strings.ERR_UTILITY_CLASS); + + private Exceptions() { + utilityClass(); + } + + public static void utilityClass() { + throw Exceptions.UTILITY_CLASS; + } + +} diff --git a/haiti-utils/src/main/java/dev/struchkov/haiti/utils/ObjectUtils.java b/haiti-utils/src/main/java/dev/struchkov/haiti/utils/ObjectUtils.java index dca532e..aa12e69 100644 --- a/haiti-utils/src/main/java/dev/struchkov/haiti/utils/ObjectUtils.java +++ b/haiti-utils/src/main/java/dev/struchkov/haiti/utils/ObjectUtils.java @@ -1,8 +1,6 @@ package dev.struchkov.haiti.utils; import dev.struchkov.haiti.context.exception.ConvertException; -import lombok.NonNull; -import lombok.experimental.UtilityClass; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -14,14 +12,19 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import static dev.struchkov.haiti.utils.Exceptions.utilityClass; + /** - * // TODO: 07.03.2021 Добавить описание. + * Утилитарный класс для работы с классами и объектами. * * @author upagge 07.03.2021 */ -@UtilityClass public class ObjectUtils { + private ObjectUtils() { + utilityClass(); + } + /** *

Позволяет получить значение вложенного в объект поля по названию поля.

*

@@ -33,7 +36,8 @@ public class ObjectUtils { * @param object Объект * @return Значение поля из объекта */ - public static Object getFieldValue(@NonNull Object object, @NonNull String fieldName) { + public static Object getFieldValue(Object object, String fieldName) { + Assert.isNotNull(object, fieldName); int firstNameIndex = fieldName.indexOf("."); String firstName; if (firstNameIndex != -1) { @@ -58,7 +62,8 @@ public class ObjectUtils { throw new ConvertException("Метод у объекта не найден"); } - public static void setFieldValue(@NonNull Object object, @NonNull String fieldName, Object fieldValue) { + public static void setFieldValue(Object object, String fieldName, Object fieldValue) { + Assert.isNotNull(object, fieldName); int firstNameIndex = fieldName.indexOf("."); if (firstNameIndex != -1) { final String[] split = fieldName.split("\\."); @@ -118,7 +123,8 @@ public class ObjectUtils { * @param method Метод * @return true если метод является геттером для fieldName, false в противном случае */ - public static boolean isGetMethod(@NonNull String fieldName, Method method) { + public static boolean isGetMethod(String fieldName, Method method) { + Assert.isNotNull(fieldName); return (method.getName().startsWith("get")) && (method.getName().length() == (fieldName.length() + 3)) && method.getName().toLowerCase().endsWith(fieldName.toLowerCase()); @@ -131,7 +137,8 @@ public class ObjectUtils { * @param method Метод * @return true если метод является сеттером для fieldName, false в противном случае */ - public static boolean isSetMethod(@NonNull String fieldName, Method method) { + public static boolean isSetMethod(String fieldName, Method method) { + Assert.isNotNull(fieldName); return (method.getName().startsWith("set")) && (method.getName().length() == (fieldName.length() + 3)) && method.getName().toLowerCase().endsWith(fieldName.toLowerCase()); diff --git a/haiti-utils/src/main/java/dev/struchkov/haiti/utils/Strings.java b/haiti-utils/src/main/java/dev/struchkov/haiti/utils/Strings.java index af31e5e..f7620c9 100644 --- a/haiti-utils/src/main/java/dev/struchkov/haiti/utils/Strings.java +++ b/haiti-utils/src/main/java/dev/struchkov/haiti/utils/Strings.java @@ -1,15 +1,20 @@ package dev.struchkov.haiti.utils; -import lombok.experimental.UtilityClass; +import static dev.struchkov.haiti.utils.Exceptions.utilityClass; /** - * // TODO: 07.03.2021 Добавить описание. + * Утилитарный класс для работы со строками. * * @author upagge 07.03.2021 */ -@UtilityClass -public class Strings { +public final class Strings { + + private Strings() { + utilityClass(); + } public static final String EMPTY = ""; + public static final String ERR_UTILITY_CLASS = "Нельзя создать объект утилитарного класса"; + public static final String ERR_OPERATION_NOT_SUPPORTED = "Операция не поддерживается"; } diff --git a/haiti-utils/src/main/java/module-info.java b/haiti-utils/src/main/java/module-info.java new file mode 100644 index 0000000..6cd64e6 --- /dev/null +++ b/haiti-utils/src/main/java/module-info.java @@ -0,0 +1,6 @@ +module haiti.utils { + requires haiti.exception; + + exports dev.struchkov.haiti.utils; + +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index a309a68..0302b8e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ dev.struchkov.haiti haiti - ${haiti.ver} + 0.0.3 pom Haiti Framework @@ -24,12 +24,12 @@ + haiti-bom + haiti-exception + haiti-utils haiti-context haiti-core haiti-filter - haiti-bom - haiti-utils - haiti-exception @@ -39,7 +39,6 @@ UTF-8 UTF-8 - 0.0.3 0.0.3 0.0.3 0.0.3 @@ -49,6 +48,7 @@ 0.0.3 0.0.3 + 3.9.0 1.6.8 3.2.1 3.3.1 @@ -120,11 +120,14 @@ +
+ + org.apache.maven.plugins + maven-compiler-plugin + 3.9.0 - - --pinentry-mode - loopback - + ${java.version} + ${java.version}
@@ -134,10 +137,6 @@ org.apache.maven.plugins maven-compiler-plugin - - 11 - 11 -