|
4 | 4 | import java.lang.annotation.Retention;
|
5 | 5 | import java.lang.annotation.RetentionPolicy;
|
6 | 6 | import java.lang.annotation.Target;
|
7 |
| -import java.lang.reflect.Field; |
| 7 | +import java.lang.reflect.Method; |
8 | 8 |
|
9 | 9 | /**
|
10 | 10 | * Marks the given Method as the initializing method for a Recipe Builder, indicating it returns a Recipe Builder class.<br>
|
11 | 11 | * A Recipe Builder is a class which follows the Builder design pattern, where each step of the builder returns the builder class,
|
12 | 12 | * allowing chaining of methods to quickly and cleanly create complicated objects which may or may not require some values.
|
13 | 13 | *
|
14 | 14 | * <ul>
|
15 |
| - * <li>{@link #example()} is an array of {@link Example}s In situations where either a single {@link Example} with multiple lines or |
16 |
| - * multiple {@link Example}s could be used, using multiple {@link Example}s is preferable.</li> |
17 |
| - * <li>{@link #requirement()} is a localization key that is autogenerated to be |
| 15 | + * <li>{@link #title()} is a localization key that is autogenerated to be |
18 | 16 | * <code>
|
19 |
| - * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() VirtualizedRegistry#getName()}.{@link Field#getName()} |
| 17 | + * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() {modId}}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() {name}}.{@link Method#getName() {methodName}}.title |
20 | 18 | * </code>
|
| 19 | + * to name the Recipe Builder. |
21 | 20 | * </li>
|
| 21 | + * <li>{@link #description()} is a localization key that is autogenerated to be |
| 22 | + * <code> |
| 23 | + * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() {modId}}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() {name}}.{@link Method#getName() {methodName}}.description |
| 24 | + * </code> |
| 25 | + * to describe the method used to create the Recipe Builder. |
| 26 | + * </li> |
| 27 | + * <li>{@link #method()} either contains nothing if annotated on a method or contains a |
| 28 | + * string that targets the desired method in conjunction with {@link MethodOverride}. |
| 29 | + * To target a method, if only a single method has the given name, excluding |
| 30 | + * bridge, non-public, Object, or methods annotated with {@link com.cleanroommc.groovyscript.api.GroovyBlacklist}, |
| 31 | + * the target may be the method name. |
| 32 | + * Otherwise, the target must be the name and full descriptor of the method.</li> |
| 33 | + * <li>{@link #clazz()} is the class being targeted by the recipe builder. By default this is the return value of the method.</li> |
| 34 | + * <li>{@link #example()} is an array of {@link Example}s In situations where either a single {@link Example} with multiple lines or |
| 35 | + * multiple {@link Example}s could be used, using multiple {@link Example}s is preferable.</li> |
| 36 | + * <li>{@link #override()} allows creating overrides for the {@link Property}, {@link RecipeBuilderMethodDescription}, and {@link RecipeBuilderRegistrationMethod} |
| 37 | + * annotated in the builder using {@link RecipeBuilderOverride}.</li> |
22 | 38 | * <li>{@link #priority()} is an integer that influences the sorting of the {@link RecipeBuilderDescription} relative to other {@link RecipeBuilderDescription}s.</li>
|
23 | 39 | * </ul>
|
24 | 40 | */
|
25 | 41 | @Retention(RetentionPolicy.RUNTIME)
|
26 | 42 | @Target(ElementType.METHOD)
|
27 | 43 | public @interface RecipeBuilderDescription {
|
28 | 44 |
|
| 45 | + /** |
| 46 | + * The localization key for the name of the builder, if different from Recipe Builder. |
| 47 | + * <br> |
| 48 | + * This should be used when there is more than one way to create a Recipe Builder |
| 49 | + * for the given class. |
| 50 | + * <br> |
| 51 | + * Generates the title via minecraft's localization files via |
| 52 | + * <code>{@link net.minecraft.client.resources.I18n#format(String, Object...) I18n.format(description())}</code> |
| 53 | + * <br> |
| 54 | + * If this is empty, will fall back to generating a description based on |
| 55 | + * <code>groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() {modId}}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() {name}}.{@link Method#getName() {methodName}}.title</code>. |
| 56 | + * Then, if that does not have a lang key defined, it will use the global default for recipe builders of |
| 57 | + * <code>groovyscript.wiki.recipe_builder.title</code>. |
| 58 | + * |
| 59 | + * @return localization key for method title |
| 60 | + */ |
| 61 | + String title() default ""; |
| 62 | + |
| 63 | + /** |
| 64 | + * The localization key for a description of the compat. |
| 65 | + * <br> |
| 66 | + * This should always be used when the creation method accepts parameters. |
| 67 | + * In most cases this should be changed so that each parameter is an individual builder method, |
| 68 | + * but in some situations this is not possible, and so must be documented accordingly. |
| 69 | + * <br> |
| 70 | + * When a builder method with one or more parameters does not have a localization key set, |
| 71 | + * if it does not use a lang key, it will log a missing key in the {@code groovy.log} file. |
| 72 | + * <br> |
| 73 | + * Generates a description via minecraft's localization files via |
| 74 | + * <code>{@link net.minecraft.client.resources.I18n#format(String, Object...) I18n.format(description())}</code> |
| 75 | + * <br> |
| 76 | + * If this is empty, will fall back to generating a description based on |
| 77 | + * <code>groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() {modId}}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() {name}}.{@link Method#getName() {methodName}}.description</code>. |
| 78 | + * Then, if that does not have a lang key defined, it will use the global default for recipe builders of |
| 79 | + * <code>groovyscript.wiki.recipe_builder.description</code>. |
| 80 | + * |
| 81 | + * @return localization key for method description |
| 82 | + */ |
| 83 | + String description() default ""; |
| 84 | + |
| 85 | + /** |
| 86 | + * If this {@link RecipeBuilderDescription} annotation is attached to a method, this element is set to the name of the method they are attached to. |
| 87 | + * When annotated on a method directly, this should not be set, as it has no functionality. |
| 88 | + * |
| 89 | + * @return the target method, if not annotated to a method directly. |
| 90 | + * @see MethodOverride |
| 91 | + */ |
| 92 | + String method() default ""; |
| 93 | + |
| 94 | + /** |
| 95 | + * The builder class. By default, this will use the return class of the target method. |
| 96 | + * If this is undesired, specify the real class here. |
| 97 | + * |
| 98 | + * @return the class used by the builder, if different from the return type of the target method |
| 99 | + */ |
| 100 | + Class<?> clazz() default void.class; |
| 101 | + |
29 | 102 | /**
|
30 | 103 | * An array of examples, which will then be formatted and generated for both the wiki and the text script files.
|
31 | 104 | *
|
|
40 | 113 | *
|
41 | 114 | * @return array of requirements unique to the recipe builder being accessed via this method
|
42 | 115 | * @see Property
|
| 116 | + * @deprecated use {@link #override()} and {@link RecipeBuilderOverride#requirement()} |
43 | 117 | */
|
| 118 | + @Deprecated |
44 | 119 | Property[] requirement() default {};
|
45 | 120 |
|
| 121 | + /** |
| 122 | + * Allows overriding the {@link Property}, {@link RecipeBuilderMethodDescription}, and {@link RecipeBuilderRegistrationMethod} annotations |
| 123 | + * for the builder class. |
| 124 | + * This should only be used in situations where custom data that does not apply to the class normally |
| 125 | + * is used. |
| 126 | + * |
| 127 | + * @return overrides for the Recipe Builder annotations |
| 128 | + * @see Property |
| 129 | + * @see RecipeBuilderMethodDescription |
| 130 | + * @see RecipeBuilderRegistrationMethod |
| 131 | + */ |
| 132 | + RecipeBuilderOverride override() default @RecipeBuilderOverride; |
| 133 | + |
46 | 134 | /**
|
47 | 135 | * Priority of the method, relative to other Recipe Builder methods in the same class.
|
48 | 136 | * Priorities sort entries such that lowest is first, with ties being broken via alphabetical sorting of the method name.
|
|
0 commit comments