[construct] Make construct annotation repeatable

This commit is contained in:
2025-10-26 20:18:55 +01:00
parent 6885f7f9a9
commit 579f4d1f45
2 changed files with 18 additions and 4 deletions

View File

@@ -1,15 +1,13 @@
package de.siphalor.tweed5.construct.api; package de.siphalor.tweed5.construct.api;
import java.lang.annotation.ElementType; import java.lang.annotation.*;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** /**
* Indicates a method or constructor that should be used for construction using {@link TweedConstructFactory}. * Indicates a method or constructor that should be used for construction using {@link TweedConstructFactory}.
* <p> * <p>
* There must only be a single annotation for a certain target class on any constructor or static method of a class. * There must only be a single annotation for a certain target class on any constructor or static method of a class.
*/ */
@Repeatable(TweedConstructs.class)
@Target({ElementType.CONSTRUCTOR, ElementType.METHOD}) @Target({ElementType.CONSTRUCTOR, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface TweedConstruct { public @interface TweedConstruct {

View File

@@ -0,0 +1,16 @@
package de.siphalor.tweed5.construct.api;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Allows declaring multiple {@link TweedConstruct} annotations on a single element.
* @see TweedConstruct
*/
@Target({ElementType.CONSTRUCTOR, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface TweedConstructs {
TweedConstruct[] value();
}