KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > apt > model > NoTypeImpl


1 /*******************************************************************************
2  * Copyright (c) 2007 BEA Systems, Inc.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * wharley@bea.com - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.internal.compiler.apt.model;
13
14 import javax.lang.model.type.NoType;
15 import javax.lang.model.type.NullType;
16 import javax.lang.model.type.TypeKind;
17 import javax.lang.model.type.TypeVisitor;
18
19 /**
20  * An implementation of NoType, which is used to represent certain psuedo-types.
21  * @see NoType.
22  */

23 public class NoTypeImpl implements NoType, NullType
24 {
25     private final TypeKind _kind;
26     
27     public static final NoType NO_TYPE_NONE = new NoTypeImpl(TypeKind.NONE);
28     public static final NoType NO_TYPE_VOID = new NoTypeImpl(TypeKind.VOID);
29     public static final NoType NO_TYPE_PACKAGE = new NoTypeImpl(TypeKind.PACKAGE);
30     public static final NullType NULL_TYPE = new NoTypeImpl(TypeKind.NULL);
31     
32     private NoTypeImpl(TypeKind kind) {
33         _kind = kind;
34     }
35
36     @Override JavaDoc
37     public <R, P> R accept(TypeVisitor<R, P> v, P p)
38     {
39         switch(this.getKind())
40         {
41             case NULL :
42                 return v.visitNull(this, p);
43             default:
44                 return v.visitNoType(this, p);
45         }
46     }
47
48     @Override JavaDoc
49     public TypeKind getKind()
50     {
51         return _kind;
52     }
53     
54     public String JavaDoc toString()
55     {
56         switch (_kind) {
57         default:
58         case NONE:
59             return "<none>"; //$NON-NLS-1$
60
case NULL:
61             return "null"; //$NON-NLS-1$
62
case VOID:
63             return "void"; //$NON-NLS-1$
64
case PACKAGE:
65             return "package"; //$NON-NLS-1$
66
}
67     }
68
69 }
70
Popular Tags