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