generator.server.springboot.custom-jhlite.main.ModuleSlug.mustache Maven / Gradle / Ivy
package {{ packageName }}.shared.slug.domain;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import tech.jhipster.lite.module.domain.resource.JHipsterModuleSlugFactory;
import {{packageName}}.shared.generation.domain.ExcludeFromGeneratedCodeCoverage;
@ExcludeFromGeneratedCodeCoverage
public enum {{ baseName }}ModuleSlug implements JHipsterModuleSlugFactory {
// Add here the slugs of your modules
// e.g.: MY_MODULE("my-module")
;
private static final Map moduleSlugMap = Stream.of(values()).collect(
Collectors.toMap({{ baseName }}ModuleSlug::get, Function.identity())
);
private final String slug;
@SuppressWarnings("java:S1144")
{{ baseName }}ModuleSlug(String slug) {
this.slug = slug;
}
@Override
public String get() {
return slug;
}
public static Optional<{{ baseName }}ModuleSlug> fromString(String slug) {
return Optional.ofNullable(moduleSlugMap.get(slug));
}
}