Apex データ型Objectの使い方のサンプル

環境
Apex

概要
Apex がサポートする任意のデータ型。Apex は、プリミティブデータ型 (Integer な
ど)、ユーザ定義カスタムクラス、sObject 汎用型、または sObject 固有の種別 (取引
先など) をサポートします。すべての Apex データ型が Object から継承されます。
Object
基盤となるデータ型に対してより具体的なデータ型を示すオブジェクトをキャス
トできます。

使用例1
Object obj = 123;
// Cast the object to an integer.
Integer i = (Integer)obj;
System.assertEquals(10, i);

使用例2
組織で事前定義されているCftApexClass という名前のカスタム
Apexクラスであるユーザ定義型にオブジェクトをキャストする方法を示します。
Object obj = new CftApexClass();
// Cast the object to the CftApexClass custom type.
CftApexClass mc = (CftApexClass)obj;
// Access a method on the user-defined class.
mc.someClassMethod();

Apex

Posted by arkgame