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.*; 021 022import java.lang.annotation.*; 023 024import org.apache.juneau.annotation.*; 025 026/** 027 * Utility classes and methods for the {@link RestPostInit @RestPostInit} annotation. 028 * 029 * <h5 class='section'>See Also:</h5><ul> 030 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/LifecycleHooks">Lifecycle Hooks</a> 031 * </ul> 032 */ 033public class RestPostInitAnnotation { 034 035 //----------------------------------------------------------------------------------------------------------------- 036 // Static 037 //----------------------------------------------------------------------------------------------------------------- 038 039 /** Default value */ 040 public static final RestPostInit DEFAULT = create().build(); 041 042 /** 043 * Instantiates a new builder for this class. 044 * 045 * @return A new builder object. 046 */ 047 public static Builder create() { 048 return new Builder(); 049 } 050 051 //----------------------------------------------------------------------------------------------------------------- 052 // Builder 053 //----------------------------------------------------------------------------------------------------------------- 054 055 /** 056 * Builder class. 057 * 058 * <h5 class='section'>See Also:</h5><ul> 059 * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#annotations(Annotation...)} 060 * </ul> 061 */ 062 public static class Builder extends TargetedAnnotationMBuilder<Builder> { 063 064 boolean childFirst; 065 066 /** 067 * Constructor. 068 */ 069 protected Builder() { 070 super(RestPostInit.class); 071 } 072 073 /** 074 * Instantiates a new {@link RestPostInit @RestPostInit} object initialized with this builder. 075 * 076 * @return A new {@link RestPostInit @RestPostInit} object. 077 */ 078 public RestPostInit build() { 079 return new Impl(this); 080 } 081 082 /** 083 * Sets the {@link RestPostInit#childFirst()} property on this annotation. 084 * 085 * @return This object. 086 */ 087 public Builder childFirst() { 088 this.childFirst = true; 089 return this; 090 } 091 092 } 093 094 //----------------------------------------------------------------------------------------------------------------- 095 // Implementation 096 //----------------------------------------------------------------------------------------------------------------- 097 098 private static class Impl extends TargetedAnnotationImpl implements RestPostInit { 099 100 private final boolean childFirst; 101 102 Impl(Builder b) { 103 super(b); 104 this.childFirst = b.childFirst; 105 postConstruct(); 106 } 107 108 @Override /* RestHook */ 109 public boolean childFirst() { 110 return childFirst; 111 } 112 } 113 114 //----------------------------------------------------------------------------------------------------------------- 115 // Other 116 //----------------------------------------------------------------------------------------------------------------- 117 118 /** 119 * A collection of {@link RestPostInit @RestPostInit annotations}. 120 */ 121 @Documented 122 @Target({METHOD,TYPE}) 123 @Retention(RUNTIME) 124 @Inherited 125 public static @interface Array { 126 127 /** 128 * The child annotations. 129 * 130 * @return The annotation value. 131 */ 132 RestPostInit[] value(); 133 } 134}