Groovy代码示例

一些通用的逻辑可以放到公共库中,提高代码质量

class Test {
  
  private String name
  
  // 实例方法调用得先实例化对象
  // 可以使用Xxx obj = Fx.klass.newInstance('Xxx__c') as Xxx
  String getName() {
    return this.name
  }
  
  void setName(String name) {
    this.name = name
  }

  //静态方法可以直接通过类名.方法名进行调用
  static String action() {
    return "sucesss"
  }

  //debug 时候的入口方法
  static void main(String[] args) {
    String ret = action();
    log.info(ret)
  }
}

2024-08-16
0 0