001/*
002 * ============================================================================
003 *  Copyright © 2002-2023 by Thomas Thrien.
004 *  All Rights Reserved.
005 * ============================================================================
006 *  Licensed to the public under the agreements of the GNU Lesser General Public
007 *  License, version 3.0 (the "License"). You may obtain a copy of the License at
008 *
009 *       http://www.gnu.org/licenses/lgpl.html
010 *
011 *  Unless required by applicable law or agreed to in writing, software
012 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
013 *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
014 *  License for the specific language governing permissions and limitations
015 *  under the License.
016 */
017
018package org.tquadrat.foundation.ap;
019
020import static org.apiguardian.api.API.Status.STABLE;
021import static org.tquadrat.foundation.lang.Objects.requireNonNullArgument;
022
023import java.io.Serial;
024import java.lang.annotation.Annotation;
025
026import org.apiguardian.api.API;
027import org.tquadrat.foundation.annotation.ClassVersion;
028
029/**
030 *  Signals an incorrect use of an annotations.
031 *
032 *  @extauthor Thomas Thrien - thomas.thrien@tquadrat.org
033 *  @version $Id: IllegalAnnotationError.java 1061 2023-09-25 16:32:43Z tquadrat $
034 *  @since 0.1.0
035 *
036 *  @UMLGraph.link
037 */
038@SuppressWarnings( "ClassWithTooManyConstructors" )
039@ClassVersion( sourceVersion = "$Id: IllegalAnnotationError.java 1061 2023-09-25 16:32:43Z tquadrat $" )
040@API( status = STABLE, since = "0.1.0" )
041public final class IllegalAnnotationError extends AnnotationProcessingError
042{
043        /*------------------------*\
044    ====** Static Initialisations **===========================================
045        \*------------------------*/
046    /**
047     *  The serial version UID for objects of this class: {@value}.
048     */
049    @Serial
050    private static final long serialVersionUID = 2397757838147693218L;
051
052        /*--------------*\
053    ====** Constructors **=====================================================
054        \*--------------*/
055    /**
056     *  Creates a new {@code IllegalAnnotationError} instance.
057     *
058     *  @param  message The message for the error.
059     */
060    public IllegalAnnotationError( final String message ) { super( requireNonNullArgument( message, "message" ) ); }
061
062    /**
063     *  Creates a new {@code IllegalAnnotationError} instance.
064     *
065     *  @param  <A> The type of the illegal annotation.
066     *  @param  annotation  The invalid annotation.
067     */
068    public <A extends Annotation> IllegalAnnotationError( final A annotation )
069    {
070        this( requireNonNullArgument( annotation, "annotation" ).getClass() );
071    }   //  IllegalAnnotationError()
072
073    /**
074     *  Creates a new {@code IllegalAnnotationError} instance.
075     *
076     *  @param  annotationClass The class of the invalid annotation.
077     */
078    public IllegalAnnotationError( final Class<? extends Annotation> annotationClass )
079    {
080        this( "Annotation '%s' is illegal".formatted( requireNonNullArgument( annotationClass, "annotationClass" ).getName() ) );
081    }   //  IllegalAnnotationError()
082
083    /**
084     *  Creates a new {@code IllegalAnnotationError} instance.
085     *
086     *  @param  <A> The type of the illegal annotation.
087     *  @param  message The message for the error.
088     *  @param  annotation  The invalid annotation.
089     */
090    public <A extends Annotation> IllegalAnnotationError( final String message, final A annotation )
091    {
092        this( message, requireNonNullArgument( annotation, "annotation" ).getClass() );
093    }   //  IllegalAnnotationError()
094
095    /**
096     *  Creates a new {@code IllegalAnnotationError} instance.
097     *
098     *  @param  message The message for the error.
099     *  @param  annotationClass The class of the invalid annotation.
100     */
101    public IllegalAnnotationError( final String message, final Class<? extends Annotation> annotationClass )
102    {
103        this( "Annotation '%s' is illegal: %s".formatted( requireNonNullArgument( annotationClass, "annotationClass" ).getName(), requireNonNullArgument( message, "message" ) ) );
104    }   //  IllegalAnnotationError()
105
106    /**
107     *  Creates a new {@code IllegalAnnotationError} instance.
108     *
109     *  @param  message The message for the error.
110     *  @param  cause   The root exception for this error.
111     */
112    public IllegalAnnotationError( final String message, final Throwable cause ) { super( requireNonNullArgument( message, "message" ), cause ); }
113}
114//  class IllegalAnnotationError
115
116/*
117 *  End of File
118 */