com.innovenso.townplan.dsl.traits.HasRequiredKey.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of innovenso-townplanner-dsl Show documentation
Show all versions of innovenso-townplanner-dsl Show documentation
Domain Specific Language for the Innovenso Townplanner
package com.innovenso.townplan.dsl.traits
import jakarta.validation.constraints.NotBlank
import lombok.NonNull
import org.apache.logging.log4j.util.Strings
trait HasRequiredKey {
private String key
void key(@NonNull String key) {
this.key = key
}
@NotBlank
String getKey() {
if (key != null && Strings.isNotBlank(key)) return key
else return generateDefaultKey()
}
void setKey(String keyToSet) {
this.key = keyToSet
}
abstract List getDefaultKeyComponents()
private String generateDefaultKey() {
getDefaultKeyComponents().collect {it.replaceAll("[^A-Za-z0-9]", "_").toLowerCase() }.join("_")
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy