AnnotationTypeOptionalMemberBuilder.java revision 3233:b5d08bc0d224
1/*
2 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package jdk.javadoc.internal.doclets.toolkit.builders;
27
28import javax.lang.model.element.TypeElement;
29
30import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeOptionalMemberWriter;
31import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeRequiredMemberWriter;
32import jdk.javadoc.internal.doclets.toolkit.Content;
33import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
34
35
36/**
37 * Builds documentation for optional annotation type members.
38 *
39 *  <p><b>This is NOT part of any supported API.
40 *  If you write code that depends on this, you do so at your own risk.
41 *  This code and its internal interfaces are subject to change or
42 *  deletion without notice.</b>
43 *
44 * @author Jamie Ho
45 * @author Bhavesh Patel (Modified)
46 */
47public class AnnotationTypeOptionalMemberBuilder extends AnnotationTypeRequiredMemberBuilder {
48
49    /**
50     * Construct a new AnnotationTypeMemberBuilder.
51     *
52     * @param context  the build context.
53     * @param typeElement the class whose members are being documented.
54     * @param writer the doclet specific writer.
55     */
56    private AnnotationTypeOptionalMemberBuilder(Context context,
57            TypeElement typeElement,
58            AnnotationTypeOptionalMemberWriter writer) {
59        super(context, typeElement, writer,
60                VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL);
61    }
62
63
64    /**
65     * Construct a new AnnotationTypeMemberBuilder.
66     *
67     * @param context  the build context.
68     * @param typeElement the class whose members are being documented.
69     * @param writer the doclet specific writer.
70     */
71    public static AnnotationTypeOptionalMemberBuilder getInstance(
72            Context context, TypeElement typeElement,
73            AnnotationTypeOptionalMemberWriter writer) {
74        return new AnnotationTypeOptionalMemberBuilder(context,
75                typeElement, writer);
76    }
77
78    /**
79     * {@inheritDoc}
80     */
81    @Override
82    public String getName() {
83        return "AnnotationTypeOptionalMemberDetails";
84    }
85
86    /**
87     * Build the annotation type optional member documentation.
88     *
89     * @param node the XML element that specifies which components to document
90     * @param memberDetailsTree the content tree to which the documentation will be added
91     */
92    public void buildAnnotationTypeOptionalMember(XMLNode node, Content memberDetailsTree) {
93        buildAnnotationTypeMember(node, memberDetailsTree);
94    }
95
96    /**
97     * Build the default value for this optional member.
98     *
99     * @param node the XML element that specifies which components to document
100     * @param annotationDocTree the content tree to which the documentation will be added
101     */
102    public void buildDefaultValueInfo(XMLNode node, Content annotationDocTree) {
103        ((AnnotationTypeOptionalMemberWriter) writer).addDefaultValueInfo(currentMember,
104                annotationDocTree);
105    }
106
107    /**
108     * {@inheritDoc}
109     */
110    @Override
111    public AnnotationTypeRequiredMemberWriter getWriter() {
112        return writer;
113    }
114}
115