KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.internal.compiler.apt.model;
13
14 import javax.lang.model.type.TypeKind;
15 import javax.lang.model.type.TypeMirror;
16 import javax.lang.model.type.TypeVisitor;
17 import javax.lang.model.type.WildcardType;
18
19 import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
20 import org.eclipse.jdt.internal.compiler.ast.Wildcard;
21 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
22 import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding;
23
24 /**
25  * Implementation of the WildcardType
26  */

27 public class WildcardTypeImpl extends TypeMirrorImpl implements WildcardType {
28     
29     public WildcardTypeImpl(BaseProcessingEnvImpl env, WildcardBinding binding) {
30         super(env, binding);
31     }
32
33     /* (non-Javadoc)
34      * @see javax.lang.model.type.WildcardType#getExtendsBound()
35      */

36     @Override JavaDoc
37     public TypeMirror getExtendsBound() {
38         WildcardBinding wildcardBinding = (WildcardBinding) this._binding;
39         if (wildcardBinding.boundKind != Wildcard.EXTENDS) return null;
40         TypeBinding bound = wildcardBinding.bound;
41         if (bound == null) return null;
42         return _env.getFactory().newTypeMirror(bound);
43     }
44
45     /* (non-Javadoc)
46      * @see javax.lang.model.type.TypeMirror#getKind()
47      */

48     @Override JavaDoc
49     public TypeKind getKind() {
50         return TypeKind.WILDCARD;
51     }
52     /* (non-Javadoc)
53      * @see javax.lang.model.type.WildcardType#getSuperBound()
54      */

55     @Override JavaDoc
56     public TypeMirror getSuperBound() {
57         WildcardBinding wildcardBinding = (WildcardBinding) this._binding;
58         if (wildcardBinding.boundKind != Wildcard.SUPER) return null;
59         TypeBinding bound = wildcardBinding.bound;
60         if (bound == null) return null;
61         return _env.getFactory().newTypeMirror(bound);
62     }
63     
64     @Override JavaDoc
65     public <R, P> R accept(TypeVisitor<R, P> v, P p) {
66         return v.visitWildcard(this, p);
67     }
68 }
69
Popular Tags