001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.rest.annotation;
014
015import static java.lang.annotation.ElementType.*;
016import static java.lang.annotation.RetentionPolicy.*;
017
018import java.lang.annotation.*;
019
020import org.apache.juneau.annotation.*;
021
022/**
023 * Utility classes and methods for the {@link RestPostInit @RestPostInit} annotation.
024 *
025 * <h5 class='section'>See Also:</h5><ul>
026 *    <li class='link'><a class="doclink" href="../../../../../index.html#jrs.LifecycleHooks">Lifecycle Hooks</a>
027 * </ul>
028 */
029public class RestPostInitAnnotation {
030
031   //-----------------------------------------------------------------------------------------------------------------
032   // Static
033   //-----------------------------------------------------------------------------------------------------------------
034
035   /** Default value */
036   public static final RestPostInit DEFAULT = create().build();
037
038   /**
039    * Instantiates a new builder for this class.
040    *
041    * @return A new builder object.
042    */
043   public static Builder create() {
044      return new Builder();
045   }
046
047   //-----------------------------------------------------------------------------------------------------------------
048   // Builder
049   //-----------------------------------------------------------------------------------------------------------------
050
051   /**
052    * Builder class.
053    *
054    * <h5 class='section'>See Also:</h5><ul>
055    *    <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#annotations(Annotation...)}
056    * </ul>
057    */
058   public static class Builder extends TargetedAnnotationMBuilder {
059
060      boolean childFirst;
061
062      /**
063       * Constructor.
064       */
065      protected Builder() {
066         super(RestPostInit.class);
067      }
068
069      /**
070       * Instantiates a new {@link RestPostInit @RestPostInit} object initialized with this builder.
071       *
072       * @return A new {@link RestPostInit @RestPostInit} object.
073       */
074      public RestPostInit build() {
075         return new Impl(this);
076      }
077
078      /**
079       * Sets the {@link RestPostInit#childFirst()} property on this annotation.
080       *
081       * @return This object.
082       */
083      public Builder childFirst() {
084         this.childFirst = true;
085         return this;
086      }
087
088      // <FluentSetters>
089
090      @Override /* GENERATED - TargetedAnnotationBuilder */
091      public Builder on(String...values) {
092         super.on(values);
093         return this;
094      }
095
096      @Override /* GENERATED - TargetedAnnotationTMBuilder */
097      public Builder on(java.lang.reflect.Method...value) {
098         super.on(value);
099         return this;
100      }
101
102      // </FluentSetters>
103   }
104
105   //-----------------------------------------------------------------------------------------------------------------
106   // Implementation
107   //-----------------------------------------------------------------------------------------------------------------
108
109   private static class Impl extends TargetedAnnotationImpl implements RestPostInit {
110
111      private final boolean childFirst;
112
113      Impl(Builder b) {
114         super(b);
115         this.childFirst = b.childFirst;
116         postConstruct();
117      }
118
119      @Override /* RestHook */
120      public boolean childFirst() {
121         return childFirst;
122      }
123   }
124
125   //-----------------------------------------------------------------------------------------------------------------
126   // Other
127   //-----------------------------------------------------------------------------------------------------------------
128
129   /**
130    * A collection of {@link RestPostInit @RestPostInit annotations}.
131    */
132   @Documented
133   @Target({METHOD,TYPE})
134   @Retention(RUNTIME)
135   @Inherited
136   public static @interface Array {
137
138      /**
139       * The child annotations.
140       *
141       * @return The annotation value.
142       */
143      RestPostInit[] value();
144   }
145}