From 1e03ab7d4353676e5ec1ac93fba90e6d509c5dc5 Mon Sep 17 00:00:00 2001 From: Colin DAMON Date: Sat, 27 Apr 2024 20:25:05 +0200 Subject: [PATCH] Rework JHipsterHiddenResourcesProperties --- .../resource/JHipsterHiddenModules.java | 47 +++++++++++++++++-- .../JHipsterHiddenResourcesProperties.java | 11 ++--- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/src/main/java/tech/jhipster/lite/module/domain/resource/JHipsterHiddenModules.java b/src/main/java/tech/jhipster/lite/module/domain/resource/JHipsterHiddenModules.java index f3fdacf42a8..bf1911e84f5 100644 --- a/src/main/java/tech/jhipster/lite/module/domain/resource/JHipsterHiddenModules.java +++ b/src/main/java/tech/jhipster/lite/module/domain/resource/JHipsterHiddenModules.java @@ -1,11 +1,52 @@ package tech.jhipster.lite.module.domain.resource; import java.util.Collection; +import java.util.List; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; import tech.jhipster.lite.shared.collection.domain.JHipsterCollections; +import tech.jhipster.lite.shared.generation.domain.ExcludeFromGeneratedCodeCoverage; -public record JHipsterHiddenModules(Collection slugs, Collection tags) { - public JHipsterHiddenModules(Collection slugs, Collection tags) { +public class JHipsterHiddenModules { + + private final Collection slugs; + private final Collection tags; + + public JHipsterHiddenModules(Collection slugs, Collection tags) { this.slugs = JHipsterCollections.immutable(slugs); - this.tags = JHipsterCollections.immutable(tags); + this.tags = buildTags(tags); + } + + private List buildTags(Collection tags) { + return JHipsterCollections.immutable(tags).stream().map(JHipsterModuleTag::new).toList(); + } + + public Collection slugs() { + return slugs; + } + + public Collection tags() { + return tags; + } + + @Override + @ExcludeFromGeneratedCodeCoverage + public int hashCode() { + return new HashCodeBuilder().append(slugs).append(tags).hashCode(); + } + + @Override + @ExcludeFromGeneratedCodeCoverage + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj == null || getClass() != obj.getClass()) { + return false; + } + + JHipsterHiddenModules other = (JHipsterHiddenModules) obj; + return new EqualsBuilder().append(slugs, other.slugs).append(tags, other.tags).isEquals(); } } diff --git a/src/main/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterHiddenResourcesProperties.java b/src/main/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterHiddenResourcesProperties.java index 11e528cdbeb..e7357a69582 100644 --- a/src/main/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterHiddenResourcesProperties.java +++ b/src/main/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterHiddenResourcesProperties.java @@ -2,31 +2,26 @@ import java.util.Collection; import org.springframework.boot.context.properties.ConfigurationProperties; -import tech.jhipster.lite.module.domain.resource.JHipsterModuleTag; @ConfigurationProperties("jhlite-hidden-resources") class JHipsterHiddenResourcesProperties { private Collection slugs; - private Collection tags; + private Collection tags; public void setSlugs(Collection slugs) { this.slugs = slugs; } public void setTags(Collection tags) { - if (tags == null) { - this.tags = null; - } else { - this.tags = tags.stream().map(JHipsterModuleTag::new).toList(); - } + this.tags = tags; } public Collection getSlugs() { return slugs; } - public Collection getTags() { + public Collection getTags() { return tags; } }