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.marshall; 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 ParentProperty @ParentProperty} annotation. 027 * 028 */ 029public class ParentPropertyAnnotation { 030 031 /** 032 * Prevents instantiation. 033 */ 034 private ParentPropertyAnnotation() {} 035 036 /** 037 * Builder class. 038 * 039 * <h5 class='section'>See Also:</h5><ul> 040 * <li class='jm'>{@link MarshallingContext.Builder#annotations(Annotation...)} 041 * </ul> 042 */ 043 public static class Builder extends AnnotationObject.Builder { 044 045 private String[] description = {}; 046 047 /** 048 * Constructor. 049 */ 050 protected Builder() { 051 super(ParentProperty.class); 052 } 053 054 /** 055 * Instantiates a new {@link ParentProperty @ParentProperty} object initialized with this builder. 056 * 057 * @return A new {@link ParentProperty @ParentProperty} object. 058 */ 059 public ParentProperty build() { 060 return new Object(this); 061 } 062 063 /** 064 * Sets the description property on this annotation. 065 * 066 * @param value The new value for this property. 067 * @return This object. 068 */ 069 public Builder description(String...value) { 070 description = value; 071 return this; 072 } 073 074 } 075 076 @SuppressWarnings({ 077 "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods 078 }) 079 private static class Object extends AnnotationObject implements ParentProperty { 080 081 private final String[] description; 082 083 Object(ParentPropertyAnnotation.Builder b) { 084 super(b); 085 this.description = cp(b.description); 086 } 087 088 @Override /* Overridden from annotation */ 089 public String[] description() { 090 return description; 091 } 092 } 093 094 /** Default value */ 095 public static final ParentProperty DEFAULT = create().build(); 096 097 /** 098 * Instantiates a new builder for this class. 099 * 100 * @return A new builder object. 101 */ 102 public static Builder create() { 103 return new Builder(); 104 } 105}