最新の安定バージョンについては、Spring Framework 6.2.6 を使用してください! |
コンストラクター
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)