refactoring for implicit creation of dependend hosting-assets #108
@ -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());
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user