refactoring for implicit creation of dependend hosting-assets #108

Merged
hsh-michaelhoennig merged 22 commits from refactoring-for-implicit-creation-of-dependend-hosting-assets into master 2024-09-26 10:51:30 +02:00
2 changed files with 7 additions and 4 deletions
Showing only changes of commit 0f72950336 - Show all commits

View File

@ -9,7 +9,9 @@ import java.lang.annotation.Target;
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface DisplayAs { public @interface DisplayAs {
class DisplayName { class DisplayName {
public static String of(final Class<?> clazz) { public static String of(final Class<?> clazz) {
final var displayNameAnnot = getDisplayNameAnnotation(clazz); final var displayNameAnnot = getDisplayNameAnnotation(clazz);
return displayNameAnnot != null ? displayNameAnnot.value() : clazz.getSimpleName(); return displayNameAnnot != null ? displayNameAnnot.value() : clazz.getSimpleName();
@ -20,6 +22,9 @@ public @interface DisplayAs {
} }
private static DisplayAs getDisplayNameAnnotation(final Class<?> clazz) { private static DisplayAs getDisplayNameAnnotation(final Class<?> clazz) {
if (clazz == null) {
return null;
}
final var annot = clazz.getAnnotation(DisplayAs.class); final var annot = clazz.getAnnotation(DisplayAs.class);
return annot != null ? annot : getDisplayNameAnnotation(clazz.getSuperclass()); return annot != null ? annot : getDisplayNameAnnotation(clazz.getSuperclass());
} }

View File

@ -1,7 +1,5 @@
package net.hostsharing.hsadminng.persistence; package net.hostsharing.hsadminng.persistence;
import lombok.experimental.UtilityClass;
import net.hostsharing.hsadminng.errors.DisplayAs;
import net.hostsharing.hsadminng.errors.DisplayAs.DisplayName; import net.hostsharing.hsadminng.errors.DisplayAs.DisplayName;
import net.hostsharing.hsadminng.rbac.object.BaseEntity; import net.hostsharing.hsadminng.rbac.object.BaseEntity;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;