EnumOutline.java revision 524:dcaa586ab756
1271294Sngie/*
2271294Sngie * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3271294Sngie * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4271294Sngie *
5271294Sngie * This code is free software; you can redistribute it and/or modify it
6271294Sngie * under the terms of the GNU General Public License version 2 only, as
7271294Sngie * published by the Free Software Foundation.  Oracle designates this
8271294Sngie * particular file as subject to the "Classpath" exception as provided
9271294Sngie * by Oracle in the LICENSE file that accompanied this code.
10271294Sngie *
11271294Sngie * This code is distributed in the hope that it will be useful, but WITHOUT
12271294Sngie * 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 com.sun.tools.internal.xjc.outline;
27
28import java.util.ArrayList;
29import java.util.List;
30
31import com.sun.codemodel.internal.JDefinedClass;
32import com.sun.tools.internal.xjc.model.CEnumLeafInfo;
33import com.sun.istack.internal.NotNull;
34
35/**
36 * Outline object that provides per-{@link CEnumLeafInfo} information
37 * for filling in methods/fields for a bean.
38 *
39 * This object can be obtained from {@link Outline}
40 *
41 * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
42 */
43public abstract class EnumOutline {
44
45    /**
46     * This {@link EnumOutline} holds information about this {@link CEnumLeafInfo}.
47     */
48    public final CEnumLeafInfo target;
49
50    /**
51     * The generated enum class.
52     */
53    public final JDefinedClass clazz;
54
55    /**
56     * Constants.
57     */
58    public final List<EnumConstantOutline> constants = new ArrayList<EnumConstantOutline>();
59
60    /**
61     * {@link PackageOutline} that contains this class.
62     */
63    public @NotNull
64    PackageOutline _package() {
65        return parent().getPackageContext(clazz._package());
66    }
67
68    /**
69     * A {@link Outline} that encloses all the class outlines.
70     */
71    public abstract @NotNull Outline parent();
72
73    protected EnumOutline(CEnumLeafInfo target, JDefinedClass clazz) {
74        this.target = target;
75        this.clazz = clazz;
76    }
77}
78