Created
April 30, 2013 05:56
-
-
Save YukiYoshikawa/5486828 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package trial.yy.guava.client.primitives; | |
| import com.google.common.primitives.Primitives; | |
| import java.util.Set; | |
| /** | |
| * com.google.common.primitives.Primitivesを試すためのサンプル | |
| * User: yy | |
| */ | |
| public class PrimitivesClient { | |
| public static void main(String[] args) { | |
| // Primitives#allPrimitiveTypesで全てのプリミティブ型のクラス(Class)を取得 | |
| System.out.println("### Primitives.allPrimitiveTypes execute"); | |
| Set<Class<?>> primitiveClazzSet = Primitives.allPrimitiveTypes(); | |
| System.out.println("All Primitives class : " + primitiveClazzSet); | |
| // Primitives#allWrapperTypesで全てのプリミティブラッパークラス(プリミティブ型のラッパークラス(Class))を取得 | |
| System.out.println("### Primitives.allPrimitiveTypes execute"); | |
| Set<Class<?>> wrapperClazzSet = Primitives.allWrapperTypes(); | |
| System.out.println("All Wrapper class : " + wrapperClazzSet); | |
| // Primitives.isWrapperTypeでプリミティブラッパークラスかどうかを判定 | |
| System.out.println("### Primitives.isWrapperType execute"); | |
| System.out.println(int.class + " is wrapper class : " + Primitives.isWrapperType(int.class)); | |
| System.out.println(long.class + " is wrapper class : " + Primitives.isWrapperType(long.class)); | |
| System.out.println(double.class + " is wrapper class : " + Primitives.isWrapperType(double.class)); | |
| System.out.println(Integer.class + " is wrapper class : " + Primitives.isWrapperType(Integer.class)); | |
| System.out.println(Long.class + " is wrapper class : " + Primitives.isWrapperType(Long.class)); | |
| System.out.println(Double.class + " is wrapper class : " + Primitives.isWrapperType(Double.class)); | |
| // Stringとかプリミティブ型のラッパークラスと関係ないものを指定するとfalseが返却される | |
| System.out.println(String.class + " is wrapper class : " + Primitives.isWrapperType(String.class)); | |
| // Primitives.unwrapでプリミティブラッパークラスからプリミティブ型のクラスを取得 | |
| System.out.println("### Primitives.unwrap execute"); | |
| System.out.println(Integer.class + " unwrap : " + Primitives.unwrap(Integer.class)); | |
| System.out.println(Short.class + " unwrap : " + Primitives.unwrap(Short.class)); | |
| System.out.println(Boolean.class + " unwrap : " + Primitives.unwrap(Boolean.class)); | |
| // Primitives.wrapプリミティブ型に対応するプリミティブラッパークラスを取得 | |
| System.out.println("### Primitives.wrap execute"); | |
| System.out.println(int.class + " wrap : " + Primitives.wrap(int.class)); | |
| System.out.println(short.class + " wrap : " + Primitives.wrap(short.class)); | |
| System.out.println(boolean.class + " wrap : " + Primitives.wrap(boolean.class)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment