script.groovy 720 B

1234567891011121314151617181920212223242526272829
  1. import cn.hutool.core.collection.ListUtil
  2. import cn.hutool.core.date.DateUtil
  3. import java.util.function.Consumer
  4. import java.util.function.Function
  5. import java.util.stream.Collectors
  6. def date = DateUtil.parse("2022-10-17 13:31:43")
  7. defaultContext.setData("demoDate", date)
  8. List<String> list = ListUtil.toList("a", "b", "c")
  9. List<String> resultList = list.stream().map(s -> "hello," + s).collect(Collectors.toList())
  10. defaultContext.setData("resultList", resultList)
  11. class Student {
  12. int studentID
  13. String studentName
  14. }
  15. Student student = new Student()
  16. student.studentID = 100301
  17. student.studentName = "张三"
  18. defaultContext.setData("student", student)
  19. def a = 3
  20. def b = 2
  21. defaultContext.setData("s1", a * b)