你好Groovy的專家分配頂部的變量,找到一個集合中的值,並使用Groovy
我使用下面的命令來獲取所有的ODI Dataservers。
def PSchema=DServer.getPhysicalSchemas();
當我打印PSchema
變量時,我得到以下值。
[oracle.odi.domain.topology.OdiPhysicalSchema ABC.X1, oracle.odi.domain.topology.OdiPhysicalSchema ABC.X2]
我想實現我在這裏會路過X1
或運行期間X2
...
然後我想驗證與PSchema
結果,並打印該值以下值:
oracle.odi.domain.topology.OdiPhysicalSchema ABC.X2
我嘗試使用以下選項:
def PSchema44 = PSchema11.findIndexValues { it =~ /(X1)/ }
def pl=PSchema11.collect{if(it.contains ('X1)){return it}}
我嘗試了LO OP檢查是否值越來越正確打印..result是好的:
for (item in PSchema11)
{
println item
}
收集的正確語法應該是'def pl = PSchema11.collect {it.contains('X1')}' 你試過嗎? – OsaSoft
收到以下錯誤** groovy.lang.MissingMethodException:沒有方法的簽名:oracle.odi.domain.topology.OdiPhysicalSchema.contains()適用於參數類型:(java.lang.String)values:[X1] 可能的解決方案:toString(),toString(),toString(),notify()** – Ananda
查看文檔,看起來像'getPhysicalSchemas()'返回 IPhysicalSchemas的一個不可修改的集合 您究竟想要達到什麼目的?如果我理解正確,您在運行時傳遞X1或X2,並且想從getPhysicalSchemas()'返回的集合中選擇傳遞的值? – OsaSoft