Skip to content

Commit

Permalink
Rework JHipsterHiddenResourcesProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
DamnClin committed Apr 28, 2024
1 parent 92ce8b2 commit 8c5167d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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<String> slugs, Collection<JHipsterModuleTag> tags) {
public JHipsterHiddenModules(Collection<String> slugs, Collection<JHipsterModuleTag> tags) {
public class JHipsterHiddenModules {

private final Collection<String> slugs;
private final Collection<JHipsterModuleTag> tags;

public JHipsterHiddenModules(Collection<String> slugs, Collection<String> tags) {
this.slugs = JHipsterCollections.immutable(slugs);
this.tags = JHipsterCollections.immutable(tags);
this.tags = buildTags(tags);
}

private List<JHipsterModuleTag> buildTags(Collection<String> tags) {
return JHipsterCollections.immutable(tags).stream().map(JHipsterModuleTag::new).toList();
}

public Collection<String> slugs() {
return slugs;
}

public Collection<JHipsterModuleTag> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> slugs;
private Collection<JHipsterModuleTag> tags;
private Collection<String> tags;

public void setSlugs(Collection<String> slugs) {
this.slugs = slugs;
}

public void setTags(Collection<String> tags) {
if (tags == null) {
this.tags = null;
} else {
this.tags = tags.stream().map(JHipsterModuleTag::new).toList();
}
this.tags = tags;
}

public Collection<String> getSlugs() {
return slugs;
}

public Collection<JHipsterModuleTag> getTags() {
public Collection<String> getTags() {
return tags;
}
}

0 comments on commit 8c5167d

Please sign in to comment.