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.server;
018
019import static org.apache.juneau.commons.utils.Shorts.*;
020
021import java.lang.annotation.*;
022
023import org.apache.juneau.commons.*;
024
025/**
026 * Utility classes and methods for the {@link RestPostInit @RestPostInit} annotation.
027 *
028 * <h5 class='section'>See Also:</h5><ul>
029 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/LifecycleHooks">Lifecycle Hooks</a>
030 * </ul>
031 */
032public class RestPostInitAnnotation {
033
034   /**
035    * Private constructor to prevent instantiation.
036    */
037   private RestPostInitAnnotation() {
038      // Utility class - prevent instantiation
039   }
040
041   /**
042    * Builder class.
043    *
044    * <h5 class='section'>See Also:</h5><ul>
045    *    <li class='jm'>{@link org.apache.juneau.marshall.MarshallingContext.Builder#annotations(Annotation...)}
046    * </ul>
047    */
048   public static class Builder extends AnnotationObject.Builder {
049
050      private String[] description = {};
051      private boolean childFirst;
052
053      /**
054       * Constructor.
055       */
056      protected Builder() {
057         super(RestPostInit.class);
058      }
059
060      /**
061       * Instantiates a new {@link RestPostInit @RestPostInit} object initialized with this builder.
062       *
063       * @return A new {@link RestPostInit @RestPostInit} object.
064       */
065      public RestPostInit build() {
066         return new Object(this);
067      }
068
069      /**
070       * Sets the description property on this annotation.
071       *
072       * @param value The new value for this property.
073       * @return This object.
074       */
075      public Builder description(String...value) {
076         description = value;
077         return this;
078      }
079
080      /**
081       * Sets the {@link RestPostInit#childFirst()} property on this annotation.
082       *
083       * @return This object.
084       */
085      public Builder childFirst() {
086         this.childFirst = true;
087         return this;
088      }
089
090   }
091
092   @SuppressWarnings({
093      "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
094   })
095   private static class Object extends AnnotationObject implements RestPostInit {
096
097      private final String[] description;
098      private final boolean childFirst;
099
100      Object(RestPostInitAnnotation.Builder b) {
101         super(b);
102         description = cp(b.description);
103         childFirst = b.childFirst;
104      }
105
106      @Override /* Overridden from RestHook */
107      public boolean childFirst() {
108         return childFirst;
109      }
110
111      @Override /* Overridden from annotation */
112      public String[] description() {
113         return description;
114      }
115   }
116
117   /** Default value */
118   public static final RestPostInit DEFAULT = create().build();
119
120   /**
121    * Instantiates a new builder for this class.
122    *
123    * @return A new builder object.
124    */
125   public static Builder create() {
126      return new Builder();
127   }
128}