Groovy @Vetoable 的用法

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

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"