org.netbeans.modules.java.source 0.80.1 17

org.netbeans.api.java.source
Class TypeUtilities

java.lang.Object
  extended by org.netbeans.api.java.source.TypeUtilities

public final class TypeUtilities
extends Object

Various utilities related to the TypeMirrors.

Since:
0.6
See Also:
Types

Nested Class Summary
static class TypeUtilities.TypeNameOptions
          Options for the getTypeName(javax.lang.model.type.TypeMirror, org.netbeans.api.java.source.TypeUtilities.TypeNameOptions[]) method.
 
Method Summary
 CharSequence getTypeName(TypeMirror type, TypeUtilities.TypeNameOptions... options)
          Get textual representation of the given type.
 boolean isCastable(TypeMirror t1, TypeMirror t2)
          Check if type t1 can be cast to t2.
 TypeMirror substitute(TypeMirror type, List<? extends TypeMirror> from, List<? extends TypeMirror> to)
          Substitute all occurrences of a type in 'from' with the corresponding type in 'to' in 'type'.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isCastable

public boolean isCastable(TypeMirror t1,
                          TypeMirror t2)
Check if type t1 can be cast to t2.

Parameters:
t1 - cast from type
t2 - cast to type
Returns:
true if and only if type t1 can be cast to t2 without a compile time error
Throws:
IllegalArgumentException - if the 't1' is of EXACUTABLE, PACKAGE, NONE, or OTHER kind
Since:
0.6

substitute

public TypeMirror substitute(TypeMirror type,
                             List<? extends TypeMirror> from,
                             List<? extends TypeMirror> to)
Substitute all occurrences of a type in 'from' with the corresponding type in 'to' in 'type'. 'from' and 'to' lists have to be of the same length.

Parameters:
type - in which the types should be substituted
from - types to substitute
to - substitute to types
Returns:
type corresponding to input 'type' with all references to any type from 'from' replaced with a corresponding type from 'to'
Throws:
IllegalArgumentException - if the 'from' and 'to' lists are not of the same length
Since:
0.36

getTypeName

@NonNull
@CheckReturnValue
public CharSequence getTypeName(@NullAllowed
                                                         TypeMirror type,
                                                         @NonNull
                                                         TypeUtilities.TypeNameOptions... options)
Get textual representation of the given type.

Parameters:
type - to print
options - allows to specify various adjustments to the output text
Returns:
textual representation of the given type
Since:
0.62

org.netbeans.modules.java.source 0.80.1 17

Built on December 5 2011.  |  Portions Copyright 1997-2011 Sun Microsystems, Inc. All rights reserved.