001/*
002 * ============================================================================
003 * Copyright © 2015 Square, Inc.
004 * Copyright for the modifications © 2018-2024 by Thomas Thrien.
005 * ============================================================================
006 *
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 *
011 * http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019
020package org.tquadrat.foundation.javacomposer;
021
022import static org.apiguardian.api.API.Status.STABLE;
023
024import javax.lang.model.element.Modifier;
025import java.util.Set;
026
027import org.apiguardian.api.API;
028import org.tquadrat.foundation.annotation.ClassVersion;
029import org.tquadrat.foundation.javacomposer.internal.FieldSpecImpl;
030
031/**
032 *  The specification for a generated field declaration.
033 *
034 *  @author Square,Inc.
035 *  @modified   Thomas Thrien - thomas.thrien@tquadrat.org
036 *  @version $Id: FieldSpec.java 1085 2024-01-05 16:23:28Z tquadrat $
037 *  @since 0.0.5
038 *
039 *  @UMLGraph.link
040 */
041@ClassVersion( sourceVersion = "$Id: FieldSpec.java 1085 2024-01-05 16:23:28Z tquadrat $" )
042@API( status = STABLE, since = "0.0.5" )
043public sealed interface FieldSpec
044    permits FieldSpecImpl
045{
046        /*---------------*\
047    ====** Inner Classes **====================================================
048        \*---------------*/
049    /**
050     *  The specification of a builder for an instance of an implementation for
051     *  {@link FieldSpec}
052     *
053     *  @author Square,Inc.
054     *  @modified   Thomas Thrien - thomas.thrien@tquadrat.org
055     *  @version $Id: FieldSpec.java 1085 2024-01-05 16:23:28Z tquadrat $
056     *  @since 0.0.5
057     *
058     *  @UMLGraph.link
059     */
060    @SuppressWarnings( "InnerClassOfInterface" )
061    @ClassVersion( sourceVersion = "$Id: FieldSpec.java 1085 2024-01-05 16:23:28Z tquadrat $" )
062    @API( status = STABLE, since = "0.0.5" )
063    public static sealed interface Builder
064        permits FieldSpecImpl.BuilderImpl
065    {
066            /*---------*\
067        ====** Methods **======================================================
068            \*---------*/
069        /**
070         *  Adds an annotation for the field.
071         *
072         *  @param  annotationSpec  The annotation.
073         *  @return This {@code Builder} instance.
074         */
075        public Builder addAnnotation( final AnnotationSpec annotationSpec );
076
077        /**
078         *  Adds an annotation for the field.
079         *
080         *  @param  annotation  The annotation.
081         *  @return This {@code Builder} instance.
082         */
083        public Builder addAnnotation( final Class<?> annotation );
084
085        /**
086         *  Adds an annotation for the field.
087         *
088         *  @param  annotation  The annotation.
089         *  @return This {@code Builder} instance.
090         */
091        public Builder addAnnotation( final ClassName annotation );
092
093        /**
094         *  Adds annotations for the field.
095         *
096         *  @param  annotationSpecs The annotations.
097         *  @return This {@code Builder} instance.
098         */
099        public Builder addAnnotations( final Iterable<AnnotationSpec> annotationSpecs );
100
101        /**
102         *  Adds a Javadoc comment for the field.
103         *
104         *  @param  block   The comment block.
105         *  @return This {@code Builder} instance.
106         */
107        public Builder addJavadoc( final CodeBlock block );
108
109        /**
110         *  Adds a Javadoc comment for the field.
111         *
112         *  @param  format  The format.
113         *  @param  args    The arguments.
114         *  @return This {@code Builder} instance.
115         */
116        public Builder addJavadoc( final String format, final Object... args );
117
118        /**
119         *  Adds modifiers for the field.
120         *
121         *  @param  modifiers   The modifiers.
122         *  @return This {@code Builder} instance.
123         */
124        public Builder addModifiers( final Modifier... modifiers );
125
126        /**
127         *  Builds a new
128         *  {@link FieldSpec}
129         *  instance from the added components.
130         *
131         *  @return The {@code FieldSpec} instance.
132         */
133        public FieldSpec build();
134
135        /**
136         *  Sets the initializer for the field.
137         *
138         *  @param  codeBlock   The code that initialises the field.
139         *  @return This {@code Builder} instance.
140         */
141        public Builder initializer( final CodeBlock codeBlock );
142
143        /**
144         *  Sets the initializer for the field.
145         *
146         *  @param  format  The format.
147         *  @param  args    The arguments.
148         *  @return This {@code Builder} instance.
149         */
150        public Builder initializer( final String format, final Object... args );
151    }
152    //  interface Builder
153
154        /*---------*\
155    ====** Methods **==========================================================
156        \*---------*/
157    /**
158     *  {@inheritDoc}
159     */
160    @Override
161    public boolean equals( final Object o );
162
163    /**
164     *  {@inheritDoc}
165     */
166    @Override
167    public int hashCode();
168
169    /**
170     *  Checks whether the given modifier was applied to this field.
171     *
172     *  @param  modifier    The modifier.
173     *  @return {@code true} if the given modifier has been applied to this
174     *      field.
175     */
176    public boolean hasModifier( final Modifier modifier );
177
178    /**
179     *  Returns the modifiers for this field.
180     *
181     *  @return The modifiers.
182     */
183    public Set<Modifier> modifiers();
184
185
186    /**
187     *  Returns the name for this field.
188     *
189     *  @return The name.
190     */
191    public String name();
192
193    /**
194     *  Returns a builder that is already initialised with the components that
195     *  built this field.
196     *
197     *  @return The builder.
198     */
199    public Builder toBuilder();
200
201    /**
202     *  {@inheritDoc}
203     */
204    @Override
205    public String toString();
206
207    /**
208     *  Returns the type of the field.
209     *
210     *  @return The type.
211     */
212    public TypeName type();
213}
214//  interface FieldSpec
215
216/*
217 *  End of File
218 */