Groovy

Outline
• Hello world
• Smooth Java integration
• Flat learning curve
• Powerful features

跟 Java ⽆无缝集成
• 呃, 实际上还是有⼀一点差别的, 看这⾥里http://www.groovy-lang.org/differences.html
• 实际项⺫⽬目展⽰示

平滑的学习曲线
• Style guide  http://www.groovy-lang.org/style-guide.html 
• Design patterns http://www.groovy-lang.org/design-patterns.html

反射
import org.springframework.util.ReflectionUtils;
Method[] methods = ReflectionUtils.getAllDeclaredMethods(interfaceClazz);
Method method = null;
for (Method m : methods) {
if (methodName.equals(m.getName())) {
method = m;
break;
}
}
if (method != null) {
if (params != null && !"null".equals(params)) {
Type[] paramTypes = method.getGenericParameterTypes();
val = ReflectionUtils.invokeMethod(method, service, deserialize(params,
paramTypes).toArray());
} else {
val = ReflectionUtils.invokeMethod(method, service);
}
} else{
throw new MethodNotFoundException();
}
—————————————————————————————————————————————————————————————————————————————————————————————————————
Type[] paramTypes = interfaceClazz.methods.find{
it.name == methodName
}.getGenericParameterTypes()
val = service."$methodName"(* deserialize(params,paramTypes))

闭包
• 调薪

其他
• 构造函数
• ?.操作符(空指针异常)
• *.操作符
• 魔幻数组(+,-,去重,连接)
• with ⽅方法
• @Category与@Mixin
• 综合(获取购物⻋车中所有总价⼤大于7000的商品名称)

class Cart{
• List cartItems
• }
• class CartItem{
• Product product
• int amount
• }
• class Product{
• String name
• int price
• }
• new Cart(
• cartItems:[
• new CartItem(product:new Product(name:"aa",price:4000),amount:2),
• new CartItem(product:new Product(name:"bb",price:3000),amount:20)
• ]
• ).cartItems.grep{
• it.product.price * it.amount > 7000
• }.product?.name

动静皆宜
• @CompileStatic
• @Grab

【Groovy】入门布道ppt的更多相关文章

  1. Groovy入门教程

    Groovy入门教程 kmyhy@126.com  2009-5-13 一.groovy是什么 简单地说,Groovy 是下一代的java语言,跟java一样,它也运行在 JVM 中. 作为跑在JVM ...

  2. GROOVY入门

    refer to 精通Groovy(IBM)https://www.ibm.com/developerworks/cn/education/java/j-groovy/j-groovy.html re ...

  3. AngularJS入门基础PPT(附下载链接)

    学习了Angularjs有段时间,自己写了一个PPT,个人认为总结的非常全面,对于入门基础够了. 大致模块有:Angularjs简单介绍,Angularjs特性,hello world,Control ...

  4. Groovy入门经典 随书重点

    1 数值和表达式 1.1数值 整数是Integer类的实例 有小数部分的数值是BigDecimal类的实例 不同于java,没有基础数据类型 一切皆对象的概念重于java 1.2表达式 两个整数的除法 ...

  5. Groovy入门(2-2)Groovy的eclipse插件安装

    1.安装eclipse插件 启动eclipse,点击help -> Install New Software... 在弹出的窗口中点击:Add... Groovy插件的地址:http://dis ...

  6. groovy入门(2-1)Groovy的Maven插件安装:Plugin execution not covered by lifecycle configuration

    参考链接:http://www.cnblogs.com/rightmin/p/4945797.html 1.引入groovy的jar包 2.引入groovy编译插件 3.遇到问题 Plugin exe ...

  7. HBase入门教程ppt

    HBase – Hadoop Database,是一个高可靠性.高性能.面向列.可伸缩的分布式存储系统,利用HBase技术可在廉价PC Server上搭建起大规模结构化存储集群.HBase利用Hado ...

  8. 强化学习基础算法入门 【PPT】

    该部分内容来自于定期的小组讨论,源于师弟的汇报. ==============================================

  9. groovy入门 第05章 基本输入输出

    基本输入输出 5.1基本输出 print XXX    //同一行输出 println XXX //换行输出 输出字符串: def message ="My name is Michael& ...

随机推荐

  1. Languages

    Languages A language class exists inside the system/Core folder, this class have 2 methods: load - L ...

  2. win7如何共享文件 图文教你设置win7文件共享

    点评:win7文件共享已成为网友们之间的热议,接下来为大家分享下如何共享文件,首先开启guest账户( 开始菜单 → 运行 → services.msc → 双击 server 服务项 ,设置启动类型 ...

  3. 谈谈项目中遇到的各种iOS7适配问题

    由于我的项目要适配到iOS7.1, 而现在已经是9时代了,在实际工作中我也是遇到了各种奇葩的坑,所以我想尽快把遇到的iOS7适配问题和解决方案分享出来,以后这些东西可能就用处不大了. 1.字体问题 i ...

  4. javascript中new Date浏览器兼容性处理

    看下面的代码 <script type="text/javascript"> var dt1 = new Date('2016-3-4 11:06:12'); aler ...

  5. HTTPS协议学习总结

    目录 一:什么是HTTPS协议?二:客户端与服务端如何建立HTTPS协议连接?三:证书.加密协议.信息摘要.签名算法概念解释与关系梳理四:低版本操作系统作为客户端发送HTTPS失败分析五:参考资料   ...

  6. postgresql cast转换类型

    代码 CAST(aa as NUMERIC)

  7. ACM——搜索(一)

    南邮OJ——1108 搜索(一) 时间限制(普通/Java):3500MS/10500MS          运行内存限制:65536KByte总提交:1023            测试通过:367 ...

  8. ThreadLocal 设计模式浅谈

    部分代码:ThreadLocal中 的get方法, 获得的是当前线程相关的对象 /** * Returns the value in the current thread's copy of this ...

  9. RDLC打印或导出Word的 分页设置 页边距和页面大小

    RDLC 导出Word的时候发现,Word的尺寸和页边距有问题,查了MSDN看到这样一段话 Page Sizing When the report is rendered, the Word page ...

  10. 【JAVA】浅谈java枚举类

    一.什么情况下使用枚举类? 有的时候一个类的对象是有限且固定的,这种情况下我们使用枚举类就比较方便? 二.为什么不用静态常量来替代枚举类呢? public static final int SEASO ...