Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework JHipsterHiddenResourcesProperties #9663

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}