Groovy @Vetoable 的用法

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import java.beans.*
import groovy.beans.Vetoable
 
class Trumpetist {
    @Vetoable String name
}
 
def me = new Trumpetist()
me.vetoableChange = { PropertyChangeEvent pce ->
    if (pce.newValue.contains('z'))
        throw new PropertyVetoException("The letter 'z' is not allowed in name", pce)
}
 
me.name = "asd"
me.name = "z"