|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
public interface TypeConversions
型の関係や変換に関する処理を行う。
Java Language Specification 3nd. Section 4 and Section 5.
| メソッドの概要 | ||
|---|---|---|
CtType<?> |
binaryNumericPromotion(CtType<?> leftType,
CtType<?> rightType)
二項の数値格上げを行う。 |
|
TypeConversions |
borrow()
このツールを借りる。 |
|
|
boxing(CtType<T> type)
この型にボクシング変換を適用した型を返す。 |
|
CtType<?> |
capture(CtType<?> type,
CtType<?> context)
a -> bの取得変換(捕捉変換)が可能である場合にのみtrueを返す。 |
|
boolean |
contains(CtType<?> a,
CtType<?> b)
b <= aが成り立つ場合にのみtrueを返す。 |
|
CtType<?> |
erasure(CtType<?> type)
この型のイレイジャを返す。 |
|
CtType<?> |
greatestLowerBound(Collection<? extends CtType<?>> bounds)
指定された境界の最大の下界を返す。 |
|
CtDeclaredType<?> |
invocation(CtDeclaredType<?> source,
CtDeclaredType<?> superType)
superTypeと同じ宣言を持つsourceのスーパータイプのうち、型を消去していない状態のものを返す。 |
|
boolean |
isAssignmentConvertable(CtType<?> a,
CtType<?> b)
a -> bの代入変換が可能である場合にのみtrueを返す。 |
|
boolean |
isBoxingConvertable(CtType<?> a,
CtType<?> b)
a -> bのボクシング変換が可能である場合にのみtrueを返す。 |
|
boolean |
isCaptureConvertable(CtType<?> a,
CtType<?> b)
a -> bの取得変換(捕捉変換)が可能である場合にのみtrueを返す。 |
|
boolean |
isIdentityConvertable(CtType<?> a,
CtType<?> b)
a = bの恒等変換が可能である場合にのみtrueを返す。 |
|
boolean |
isNarrowingPrimitiveConvertable(CtType<?> a,
CtType<?> b)
a -> bのプリミティブ型ナローイング変換が可能である場合にのみtrueを返す。 |
|
boolean |
isRaw(CtType<?> type)
この型が未加工型、または非総称化型である場合にのみ trueを返す。 |
|
boolean |
isReifiable(CtType<?> type)
この型が具象化可能型である場合にのみ trueを返す。 |
|
boolean |
isStringConvertable(CtType<?> type)
type -> java.lang.Stringの文字列変換が可能である場合にのみtrueを返す。 |
|
boolean |
isSubtype(CtType<?> a,
CtType<?> b)
a < bが成り立つ場合にのみtrueを返す。 |
|
boolean |
isUnboxingConvertable(CtType<?> a,
CtType<?> b)
a -> bのアンボクシング変換が可能である場合にのみtrueを返す。 |
|
boolean |
isUncheckedConvertable(CtType<?> a,
CtType<?> b)
a -> bの未チェック変換が可能である場合にのみtrueを返す。 |
|
boolean |
isWideningAndNarrowingPrimitiveConvertable(CtType<?> a,
CtType<?> b)
a -> bのプリミティブ型ナローイング変換とワイドニング変換を組み合わせた変換が可能である場合にのみtrueを返す。 |
|
boolean |
isWideningPrimitiveConvertable(CtType<?> a,
CtType<?> b)
a -> bのプリミティブ型ワイドニング変換が可能である場合にのみtrueを返す。 |
|
boolean |
isWideningReferenceConvertable(CtType<?> a,
CtType<?> b)
a -> bの参照型ワイドニング変換が可能である場合にのみtrueを返す。 |
|
CtType<?> |
leastUpperBound(Collection<? extends CtType<?>> bounds)
指定された境界の最小の上界を返す。 |
|
CtDeclaredType<?> |
raw(CtDeclaredType<?> type)
この型の未加工型を返す。 |
|
CtType<?> |
unaryNumericPromotion(CtType<?> type)
単項の数値格上げを行う。 |
|
|
unboxing(CtType<T> type)
この型にアンボクシング変換を適用した型を返す。 |
|
| メソッドの詳細 |
|---|
boolean contains(CtType<?> a,
CtType<?> b)
b <= aが成り立つ場合にのみtrueを返す。
T <: S => ? extends T <= ? extends S S <: T => ? super T <= ? super S T <= T T <= ? extends T T <= ? super T 4.5.1.1 Type Argument Containment and Equivalence.
a - 包括するべき型b - 包括されるべき型
a <= bが成り立つ場合にのみtrueboolean isReifiable(CtType<?> type)
trueを返す。
G<?, ...,?> isRaw(CtType)) 4.7 Reifiable Types
type - 対象の型
trueboolean isRaw(CtType<?> type)
trueを返す。
4.8 Raw Types
type - 対象の型
true
boolean isSubtype(CtType<?> a,
CtType<?> b)
a < bが成り立つ場合にのみtrueを返す。
直接のサブタイプは次のように定義される。
4.10.1 Subtyping among Primitive Types double >1 float float >1 long long >1 int int >1 char int >1 short short >1 byte 4.10.2 Subtyping among Class and Interface Types C.superClass >1 C C.superInterfaces[i] >1 C java.lang.Object >1 I (Iはインターフェース, I.superInterfaces.empty)G >1 G<...> i=1..nにおけるTiが型である場合のC<T1, ..., Tn>について: C<F1, ..., Fn> >1 D<U1, ..., Uk>,
theta = [F1:= T1, ..., Fn:= Tn] =>
C<T1, ..., Tn> >1 D<U1theta , ..., Uktheta>
C<S1, ..., Sn> >1 C<T1, ..., Tn>,
i=1..nに対して Ti <= Si
Ri: C<R1, ..., Rn> (i=1..n),
C<X1, ..., Xn> = capture-of C<R1, ..., Rn>,
S >1 C<X1, ..., Xn> =>
S >1 C<R1, ..., Rn>
4.9 Intersection Types Ti >1 Ti& ... & Tn (i=1..n) 4.4 Type Variables java.lang.Object >1 <T> B >1 <T extends B> T >1 lower-bound-of T null type X| X is reference-type, X <> null >1 <null> 4.10.3 Subtyping among Array Types S >1 T <=> S[] >1 T[] (S, Tは参照型)java.lang.Object >1 java.lang.Object[] java.lang.Cloneable >1 java.lang.Object[] java.io.Serializable >1 java.lang.Object[] java.lang.Object >1 p[] (pは任意のプリミティブ型) java.lang.Cloneable >1 p[] (pは任意のプリミティブ型) java.io.Serializable >1 p[] (pは任意のプリミティブ型) 4.10 Subtyping.
a - サブタイプb - 親タイプ
a < bが成り立つ場合にのみtrue
boolean isIdentityConvertable(CtType<?> a,
CtType<?> b)
a = bの恒等変換が可能である場合にのみtrueを返す。
つまり、aとbが完全に同じ型である場合にのみtrueを返す。
5.1.1 Identity Conversions.
a - 変換する型b - 変換先の型
true
boolean isWideningPrimitiveConvertable(CtType<?> a,
CtType<?> b)
a -> bのプリミティブ型ワイドニング変換が可能である場合にのみtrueを返す。
次の19種類に限られる。
byte -> short, int, long, float, or double short -> int, long, float, or double char -> int, long, float, or double int -> long, float, or double long -> float, or double float -> double 5.1.2 Widening Primitive Conversions.
a - 変換する型b - 変換先の型
true
boolean isNarrowingPrimitiveConvertable(CtType<?> a,
CtType<?> b)
a -> bのプリミティブ型ナローイング変換が可能である場合にのみtrueを返す。
次の22種類に限られる。
short -> byte or char char -> byte or short int -> byte, short, or char long -> byte, short, char, or int float -> byte, short, char, int, or long double -> byte, short, char, int, long, or float 5.1.3 Narrowing Primitive Conversions.
a - 変換する型b - 変換先の型
true
boolean isWideningAndNarrowingPrimitiveConvertable(CtType<?> a,
CtType<?> b)
a -> bのプリミティブ型ナローイング変換とワイドニング変換を組み合わせた変換が可能である場合にのみtrueを返す。
次のものに限られる。
byte -> char byte -(widening)> int -(narrowing)> char という過程で行われる。
5.1.4 Widening and Narrowing Primitive Conversions.
a - 変換する型b - 変換先の型
true
boolean isWideningReferenceConvertable(CtType<?> a,
CtType<?> b)
a -> bの参照型ワイドニング変換が可能である場合にのみtrueを返す。
bがaのサブタイプ(isSubtype(CtType, CtType))であれば変換可能である。
5.1.5 Widening Reference Conversions.
a - 変換する型b - 変換先の型
true
boolean isBoxingConvertable(CtType<?> a,
CtType<?> b)
a -> bのボクシング変換が可能である場合にのみtrueを返す。
boolean -> java.lang.Boolean byte -> java.lang.Byte char -> java.lang.Character short -> java.lang.Short int -> java.lang.Integer long -> java.lang.Long float -> java.lang.Float double -> java.lang.Double 5.1.7 Boxing Conversions.
a - 変換する型b - 変換先の型
true
boolean isUnboxingConvertable(CtType<?> a,
CtType<?> b)
a -> bのアンボクシング変換が可能である場合にのみtrueを返す。
java.lang.Boolean -> boolean java.lang.Byte -> byte java.lang.Character -> char java.lang.Short -> short java.lang.Integer -> int java.lang.Long -> long java.lang.Float -> float java.lang.Double -> double 5.1.8 Unboxing Conversions.
a - 変換する型b - 変換先の型
true
boolean isUncheckedConvertable(CtType<?> a,
CtType<?> b)
a -> bの未チェック変換が可能である場合にのみtrueを返す。
G -> G<T1, ..., Tn> 5.1.9 Unchecked Conversions.
a - 変換する型b - 変換先の型
true
boolean isCaptureConvertable(CtType<?> a,
CtType<?> b)
a -> bの取得変換(捕捉変換)が可能である場合にのみtrueを返す。
5.1.10 Capture Conversions.
a - 変換する型b - 変換先の型
trueboolean isStringConvertable(CtType<?> type)
type -> java.lang.Stringの文字列変換が可能である場合にのみtrueを返す。
T <> java.lang.String => T -> java.lang.String
5.1.11 String Conversions
type - 変換する型
true
boolean isAssignmentConvertable(CtType<?> a,
CtType<?> b)
a -> bの代入変換が可能である場合にのみtrueを返す。
次の変換を利用できる。
isIdentityConvertable(CtType, CtType) isWideningPrimitiveConvertable(CtType, CtType) isWideningReferenceConvertable(CtType, CtType) isBoxingConvertable(CtType, CtType) isUnboxingConvertable(CtType, CtType) 5.2 Assignment Conversion.
a - 変換する型b - 変換先の型
trueCtType<?> erasure(CtType<?> type)
G<T1, ..., Tn> -> |G| T.C -> |T|.C T[] -> |T|[] T extends P1 & ... & Pn -> |P1| (leftmost one) _ -> _ 4.6 Type Erasure.
type - 対象の型
CtDeclaredType<?> raw(CtDeclaredType<?> type)
G<T1, ..., Tn> -> G 4.8 Raw Types
type - 対象の型
<T> CtClass<T> boxing(CtType<T> type)
5.1.7 Boxing Conversions.
T - 型type - 対象の型
null<T> CtType<T> unboxing(CtType<T> type)
5.1.8 Unboxing Conversions.
T - 型type - 対象の型
null
CtType<?> capture(CtType<?> type,
CtType<?> context)
a -> bの取得変換(捕捉変換)が可能である場合にのみtrueを返す。
5.1.10 Capture Conversions.
type - 変換する型context - 変換時の型コンテキスト
CtType<?> unaryNumericPromotion(CtType<?> type)
byte -> int short -> int char -> int int -> int long -> long float -> float double -> double CtNewArray.getDimensions() CtArrayAccess.getIndex() CtUnary with UnaryOperator.PLUS CtUnary with UnaryOperator.MINUS CtUnary with UnaryOperator.COMPLEMENT CtInfix.getLeftOperand() with shift operation CtInfix.getRightOperand() with shift operation 5.6.1 Unary Numeric Promotion.
type - 対象の型
null
CtType<?> binaryNumericPromotion(CtType<?> leftType,
CtType<?> rightType)
(double, _) -> (double, double) (float, _) -> (float, float) (long, _) -> (long, long) (_, _) -> (int, int) InfixOperator.PLUS (文字列連結以外) InfixOperator.MINUS InfixOperator.TIMES InfixOperator.DIVIDE InfixOperator.REMAINDER InfixOperator.LESS InfixOperator.LESS_EQUALS InfixOperator.GREATER InfixOperator.GREATER_EQUALS InfixOperator.EQUALS (数値比較) InfixOperator.NOT_EQUALS (数値比較) InfixOperator.AND (boolean以外) InfixOperator.OR (boolean以外) InfixOperator.XOR (boolean以外) CtConditional (一部の状況) 5.6.2 Binary Numeric Promotion.
leftType - 対象の左演算数が持つ型rightType - 対象の右演算数が持つ型
null
CtDeclaredType<?> invocation(CtDeclaredType<?> source,
CtDeclaredType<?> superType)
superTypeと同じ宣言を持つsourceのスーパータイプのうち、型を消去していない状態のものを返す。
|superType<U1theta, ..., Uktheta>| :> |source<V1, ..., Vn>|} (型を消去しているスーパータイプ),
source<V1, ..., Vn>[V1:= X1, ...,Vn:= Xn]
である場合:
superType<U1, ..., Uk>,
theta = replacement of [V1:= X1, ...,Vn:= Xn]
となるようなパラメータ化されたsuperTypeを返す。
そうでない場合: nullを返す。
source - 基点となる型superType - イレイジャが|source|のスーパータイプとなる型
nullCtType<?> leastUpperBound(Collection<? extends CtType<?>> bounds)
bounds - 境界のリスト
CtType<?> greatestLowerBound(Collection<? extends CtType<?>> bounds)
bounds - 境界のリスト
TypeConversions borrow()
Tool の記述:
Tool 内の borrow
|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||