コンストラクター
new 演算子を使用してコンストラクターを呼び出すことができます。java.lang パッケージ内にあるもの (Integer、Float、String など) を除くすべての型に対して、完全修飾クラス名を使用する必要があります。可変引数もサポートされています。
次の例は、new 演算子を使用してコンストラクターを呼び出す方法を示しています。
Java
Kotlin
Inventor einstein = parser.parseExpression(
"new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')")
.getValue(Inventor.class);
// create new Inventor instance within the add() method of List
parser.parseExpression(
"Members.add(new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German'))")
.getValue(societyContext);val einstein = parser.parseExpression(
"new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')")
.getValue(Inventor::class.java)
// create new Inventor instance within the add() method of List
parser.parseExpression(
"Members.add(new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German'))")
.getValue(societyContext)