99import java .lang .annotation .RetentionPolicy ;
1010import java .lang .annotation .Target ;
1111
12+ /**
13+ * Configuration interface for N5 serialization naming and parameter annotations.
14+ * <p>
15+ * This interface provides a standardized way to configure serialization names and parameters
16+ * for N5 components such as compression algorithms and codecs. It defines annotations that
17+ * control how classes and their fields are serialized and deserialized for the N5 API.
18+ * <p>
19+ * Classes implementing this interface can use the provided annotations to:
20+ * <ul>
21+ * <li>Define a serialization type name with {@link Name @Name}</li>
22+ * <li>Specify a namespace prefix with {@link Prefix @Prefix}</li>
23+ * <li>Mark fields as serialization parameters with {@link Parameter @Parameter}</li>
24+ * </ul>
25+ *
26+ * @see Name
27+ * @see Prefix
28+ * @see Parameter
29+ */
1230public interface NameConfig extends Serializable {
1331
32+ /**
33+ * Defines a namespace prefix for serialization.
34+ * <p>
35+ * This annotation specifies a prefix that is prepended to the serialization
36+ * type name, creating a namespaced identifier. This is useful for organizing
37+ * related components into logical groups, usually all the components implementing
38+ * a particular interface.
39+ * <p>
40+ * Example usage:
41+ * <pre>{@code
42+ * @Prefix("codec")
43+ * public interface Codec extends NameConfig {
44+ * // ...
45+ * }
46+ * }</pre>
47+ *
48+ * @see Name
49+ */
1450 @ Retention (RetentionPolicy .RUNTIME )
1551 @ Inherited
1652 @ Target (ElementType .TYPE )
1753 @interface Prefix {
1854 String value ();
1955 }
2056
57+ /**
58+ * Specifies the serialization type name for a class.
59+ * <p>
60+ * This annotation defines the string identifier used during serialization and
61+ * deserialization to identify the type. The name should be unique within its
62+ * namespace and is typically a short, descriptive identifier.
63+ * <p>
64+ * Example usage:
65+ * <pre>{@code
66+ * @Name("gzip")
67+ * public class GzipCompression implements Compression {
68+ * // ...
69+ * }
70+ * }</pre>
71+ *
72+ * @see Prefix
73+ */
2174 @ Retention (RetentionPolicy .RUNTIME )
2275 @ Inherited
2376 @ Target (ElementType .TYPE )
@@ -26,14 +79,57 @@ public interface NameConfig extends Serializable {
2679 String value ();
2780 }
2881
82+ /**
83+ * Marks a field as a parameter to be serialized.
84+ * <p>
85+ * This annotation identifies fields that should be included during serialization
86+ * and deserialization. It supports both required and optional parameters.
87+ * <p>
88+ * The {@code value} attribute can be used to specify an alternative name for
89+ * the parameter during serialization. If not specified, the field name is used.
90+ * <p>
91+ * Example usage:
92+ * <pre>{@code
93+ * public class GzipCompression implements Compression {
94+ * @Parameter
95+ * private final int level;
96+ *
97+ * @Parameter(optional = true)
98+ * private final boolean useZlib;
99+ * }
100+ * }</pre>
101+ *
102+ * @see Name
103+ */
29104 @ Retention (RetentionPolicy .RUNTIME )
30105 @ Inherited
31106 @ Target (ElementType .FIELD )
32107 @interface Parameter {
108+ /**
109+ * Alternative name for the parameter during serialization.
110+ * If empty, the field name is used.
111+ *
112+ * @return the parameter name, or empty string for field name
113+ */
33114 String value () default "" ;
115+
116+ /**
117+ * Whether this parameter is optional.
118+ * Optional parameters may be omitted during deserialization.
119+ *
120+ * @return {@code true} if the parameter is optional, {@code false} otherwise
121+ */
34122 boolean optional () default false ;
35123 }
36124
125+ /**
126+ * Returns the serialization type name for this instance.
127+ * <p>
128+ * This method retrieves the value from the {@link Name @Name} annotation
129+ * if present on the class.
130+ *
131+ * @return the type name from the {@code @Name} annotation, or {@code null} if not annotated
132+ */
37133 default String getType () {
38134
39135 final Name type = getClass ().getAnnotation (Name .class );
0 commit comments