You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have in my code base the following code for autoboxing support; maybe it can be added to TypeReference or wherever it may be appropriate. It seems like a nice addition when dealing with type signatures.
/** * @brief * Perform unboxing i.e. apply the following mapping * <ul> * <li>java.lang.Boolean -> boolean</li> * <li>java.lang.Byte -> byte</li> * <li>java.lang.Character -> char</li> * <li>java.lang.Double -> double</li> * <li>java.lang.Float -> float</li> * <li>java.lang.Integer -> int</li> * <li>java.lang.Long -> long</li> * <li>java.lang.Short -> short</li> * </ul> * if @a t refers to one of the types on the left-hand side, * otherwise simply return @a t. * @param t * The type reference. * @return * The type reference to the unboxed type or @a t. */publicstaticTypeReferenceunbox(TypeReferencet) {
if (t == TypeReference.JavaLangBoolean) {
returnTypeReference.Boolean;
} elseif (t == TypeReference.JavaLangByte) {
returnTypeReference.Byte;
} elseif (t == TypeReference.JavaLangCharacter) {
returnTypeReference.Char;
} elseif (t == TypeReference.JavaLangDouble) {
returnTypeReference.Double;
} elseif (t == TypeReference.JavaLangFloat) {
returnTypeReference.Float;
} elseif (t == TypeReference.JavaLangInteger) {
returnTypeReference.Int;
} elseif (t == TypeReference.JavaLangLong) {
returnTypeReference.Long;
} elseif (t == TypeReference.JavaLangShort) {
returnTypeReference.Short;
} else {
returnt;
}
}
/** * @brief * Perform boxing i.e. apply the following mapping * <ul> * <li>boolean -> java.lang.Boolean</li> * <li>byte -> java.lang.Byte</li> * <li>char -> java.lang.Character</li> * <li>double -> java.lang.Double</li> * <li>float -> java.lang.Float</li> * <li>int -> java.lang.Integer</li> * <li>long -> java.lang.Long</li> * <li>short -> java.lang.Short</li> * <ul> * if @a t refers to one of the types on the left-hand side, * otherwise simply return @a t. * @param t * The type reference. * @return * The type reference to the boxed type or @a t. */publicstaticTypeReferencebox(TypeReferencet) {
if (t == TypeReference.Boolean) {
returnTypeReference.JavaLangBoolean;
} elseif (t == TypeReference.Byte) {
returnTypeReference.JavaLangByte;
} elseif (t == TypeReference.Char) {
returnTypeReference.JavaLangCharacter;
} elseif (t == TypeReference.Double) {
returnTypeReference.JavaLangDouble;
} elseif (t == TypeReference.Float) {
returnTypeReference.JavaLangFloat;
} elseif (t == TypeReference.Int) {
returnTypeReference.JavaLangInteger;
} elseif (t == TypeReference.Long) {
returnTypeReference.JavaLangLong;
} elseif (t == TypeReference.Short) {
returnTypeReference.JavaLangShort;
} else {
returnt;
}
}
The text was updated successfully, but these errors were encountered:
I have in my code base the following code for autoboxing support; maybe it can be added to TypeReference or wherever it may be appropriate. It seems like a nice addition when dealing with type signatures.
The text was updated successfully, but these errors were encountered: