1 19 20 package org.netbeans.modules.j2ee.ejbcore.api.methodcontroller; 21 22 import org.netbeans.modules.j2ee.common.method.MethodModel; 23 24 28 public abstract class MethodType { 29 30 public enum Kind {BUSINESS, SELECT, CREATE, FINDER, HOME} 31 32 private final MethodModel methodHandle; 33 34 public MethodType(MethodModel methodHandle) { 35 this.methodHandle = methodHandle; 36 } 37 38 public abstract void accept(MethodTypeVisitor visitor); 39 40 public abstract Kind getKind(); 41 42 public final MethodModel getMethodElement() { 43 return methodHandle; 44 } 45 46 public interface MethodTypeVisitor { 47 void visit(BusinessMethodType bmt); 48 void visit(CreateMethodType cmt); 49 void visit(HomeMethodType hmt); 50 void visit(FinderMethodType fmt); 51 } 52 53 public static class BusinessMethodType extends MethodType { 54 public BusinessMethodType(MethodModel methodHandle) { 55 super(methodHandle); 56 } 57 58 public void accept(MethodTypeVisitor visitor) { 59 visitor.visit(this); 60 } 61 62 public Kind getKind() { 63 return Kind.BUSINESS; 64 } 65 } 66 67 public static class SelectMethodType extends MethodType { 68 public SelectMethodType(MethodModel methodHandle) { 69 super(methodHandle); 70 } 71 72 public void accept(MethodTypeVisitor visitor) { 73 assert false:"select methods are not intended to be visited"; 74 } 75 76 public Kind getKind() { 77 return Kind.SELECT; 78 } 79 } 80 81 public static class CreateMethodType extends MethodType { 82 public CreateMethodType(MethodModel methodHandle) { 83 super(methodHandle); 84 } 85 86 public void accept(MethodTypeVisitor visitor) { 87 visitor.visit(this); 88 } 89 90 public Kind getKind() { 91 return Kind.CREATE; 92 } 93 } 94 95 public static class HomeMethodType extends MethodType { 96 public HomeMethodType(MethodModel methodHandle) { 97 super(methodHandle); 98 } 99 100 public void accept(MethodTypeVisitor visitor) { 101 visitor.visit(this); 102 } 103 104 public Kind getKind() { 105 return Kind.HOME; 106 } 107 } 108 109 public static class FinderMethodType extends MethodType { 110 public FinderMethodType(MethodModel methodHandle) { 111 super(methodHandle); 112 } 113 114 public void accept(MethodTypeVisitor visitor) { 115 visitor.visit(this); 116 } 117 118 public Kind getKind() { 119 return Kind.FINDER; 120 } 121 } 122 } 123 | Popular Tags |