7

幫助,Scala中的嵌套註釋列表

我該如何在Scala中執行下列操作?

import org.hibernate.validator.constraints.ScriptAssert 

@ScriptAssert.List({ 
    @ScriptAssert(script = "...", lang = "javascript"), 
    @ScriptAssert(script = "...", lang = "javascript")}) 

回答

7

正確的語法如下(Array(...)爲陣列,new Nested(..)用於嵌套註解):

import org.hibernate.validator.constraints.ScriptAssert 

@ScriptAssert.List(Array(
    new ScriptAssert(script = "...", lang = "javascript"), 
    new ScriptAssert(script = "...", lang = "javascript"))) 
class Test 
+0

它不會工作,由於已知錯誤。 – 2010-09-30 07:18:21

+0

你試過了嗎?使用Scala 2.8,這對我很有用。我剛剛在我的初步答案中得到了錯誤的語法,但現在它已被糾正。 – 2010-10-02 09:42:50

+0

我沒有嘗試過(針對scala 2.8和hibernate驗證器),它不起作用。你試過了嗎? – 2010-10-02 12:23:42