~ubuntu-branches/ubuntu/quantal/netbeans/quantal

« back to all changes in this revision

Viewing changes to j2ee/ejbcore/src/org/netbeans/modules/j2ee/ejbcore/api/methodcontroller/MethodType.java

  • Committer: Bazaar Package Importer
  • Author(s): Marek Slama
  • Date: 2008-01-29 14:11:22 UTC
  • Revision ID: james.westby@ubuntu.com-20080129141122-fnzjbo11ntghxfu7
Tags: upstream-6.0.1
ImportĀ upstreamĀ versionĀ 6.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
3
 *
 
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
 
5
 *
 
6
 * The contents of this file are subject to the terms of either the GNU
 
7
 * General Public License Version 2 only ("GPL") or the Common
 
8
 * Development and Distribution License("CDDL") (collectively, the
 
9
 * "License"). You may not use this file except in compliance with the
 
10
 * License. You can obtain a copy of the License at
 
11
 * http://www.netbeans.org/cddl-gplv2.html
 
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
 
13
 * specific language governing permissions and limitations under the
 
14
 * License.  When distributing the software, include this License Header
 
15
 * Notice in each file and include the License file at
 
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
 
17
 * particular file as subject to the "Classpath" exception as provided
 
18
 * by Sun in the GPL Version 2 section of the License file that
 
19
 * accompanied this code. If applicable, add the following below the
 
20
 * License Header, with the fields enclosed by brackets [] replaced by
 
21
 * your own identifying information:
 
22
 * "Portions Copyrighted [year] [name of copyright owner]"
 
23
 *
 
24
 * Contributor(s):
 
25
 *
 
26
 * The Original Software is NetBeans. The Initial Developer of the Original
 
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
 
28
 * Microsystems, Inc. All Rights Reserved.
 
29
 *
 
30
 * If you wish your version of this file to be governed by only the CDDL
 
31
 * or only the GPL Version 2, indicate your decision by adding
 
32
 * "[Contributor] elects to include this software in this distribution
 
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
 
34
 * single choice of license, a recipient has the option to distribute
 
35
 * your version of this file under either the CDDL, the GPL Version 2 or
 
36
 * to extend the choice of license to its licensees as provided above.
 
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
 
38
 * Version 2 license, then the option applies only if the new code is
 
39
 * made subject to such option by the copyright holder.
 
40
 */
 
41
 
 
42
package org.netbeans.modules.j2ee.ejbcore.api.methodcontroller;
 
43
 
 
44
import org.netbeans.modules.j2ee.common.method.MethodModel;
 
45
 
 
46
/**
 
47
 * Provide simple instance of the visitor pattern to use for code generation.
 
48
 * @author Chris Webster
 
49
 */
 
50
public abstract class MethodType {
 
51
 
 
52
    public enum Kind {BUSINESS, SELECT, CREATE, FINDER, HOME}
 
53
    
 
54
    private final MethodModel methodHandle;
 
55
    
 
56
    public MethodType(MethodModel methodHandle) {
 
57
        this.methodHandle = methodHandle;
 
58
    }
 
59
    
 
60
    public abstract void accept(MethodTypeVisitor visitor);
 
61
    
 
62
    public abstract Kind getKind();
 
63
    
 
64
    public final MethodModel getMethodElement() {
 
65
        return methodHandle;
 
66
    }
 
67
    
 
68
    public interface MethodTypeVisitor {
 
69
        void visit(BusinessMethodType bmt);
 
70
        void visit(CreateMethodType cmt);
 
71
        void visit(HomeMethodType hmt);
 
72
        void visit(FinderMethodType fmt);
 
73
    }
 
74
    
 
75
    public static class BusinessMethodType extends MethodType {
 
76
        public BusinessMethodType(MethodModel methodHandle) {
 
77
            super(methodHandle);
 
78
        }
 
79
        
 
80
        public void accept(MethodTypeVisitor visitor) {
 
81
            visitor.visit(this);
 
82
        }
 
83
        
 
84
        public Kind getKind() {
 
85
            return Kind.BUSINESS;
 
86
        }
 
87
    }
 
88
    
 
89
    public static class SelectMethodType extends MethodType {
 
90
        public SelectMethodType(MethodModel methodHandle) {
 
91
            super(methodHandle);
 
92
        }
 
93
        
 
94
        public void accept(MethodTypeVisitor visitor) {
 
95
            assert false:"select methods are not intended to be visited";
 
96
        }
 
97
        
 
98
        public Kind getKind() {
 
99
            return Kind.SELECT;
 
100
        }
 
101
    }
 
102
    
 
103
    public static class CreateMethodType extends MethodType {
 
104
        public CreateMethodType(MethodModel methodHandle) {
 
105
            super(methodHandle);
 
106
        }
 
107
        
 
108
        public void accept(MethodTypeVisitor visitor) {
 
109
            visitor.visit(this);
 
110
        }
 
111
 
 
112
        public Kind getKind() {
 
113
            return Kind.CREATE;
 
114
        }
 
115
    }
 
116
    
 
117
    public static class HomeMethodType extends MethodType {
 
118
        public HomeMethodType(MethodModel methodHandle) {
 
119
            super(methodHandle);
 
120
        }
 
121
        
 
122
        public void accept(MethodTypeVisitor visitor) {
 
123
            visitor.visit(this);
 
124
        }
 
125
 
 
126
        public Kind getKind() {
 
127
            return Kind.HOME;
 
128
        }
 
129
    }
 
130
    
 
131
    public static class FinderMethodType extends MethodType {
 
132
        public FinderMethodType(MethodModel methodHandle) {
 
133
            super(methodHandle);
 
134
        }
 
135
        
 
136
        public void accept(MethodTypeVisitor visitor) {
 
137
            visitor.visit(this);
 
138
        }
 
139
        
 
140
        public Kind getKind() {
 
141
            return Kind.FINDER;
 
142
        }
 
143
    }
 
144
}