FormulaInstance クラス
数式インスタンスを評価するメソッドが含まれます。
名前空間
例
1global class MotorYacht {
2 global Integer lengthInYards;
3 global Integer numOfGuestCabins;
4 global String name;
5 global Account owner;
6}
7
8MotorYacht aBoat = new MotorYacht();
9aBoat.lengthInYards = 52;
10aBoat.numOfGuestCabins = 4;
11aBoat.name = 'RV Foo';
12FormulaEval.FormulaInstance isItSuper = FormulaEval.FormulaBuilder.builder()
13 .withReturnType(FormulaEval.FormulaReturnType.STRING)
14 .withType(MotorYacht.class)
15 .withFormula('IF(lengthInYards < 100, "Not Super", "Super")')
16 .build();
17isItSuper.evaluate(aBoat); //=> "Not Super"
18
19aBoat.owner = new Account(Name='Acme Watercraft', Site='New York');
20FormulaEval.FormulaInstance ownerDetails = FormulaEval.FormulaBuilder.builder()
21 .withReturnType(FormulaEval.FormulaReturnType.STRING)
22 .withType(MotorYacht.class)
23 .withFormula('owner.Name & " (" & owner.Site & ")"')
24 .build();
25ownerDetails.evaluate(aBoat); //=> "Acme Watercraft (New York)"
26