【Groovy】入门布道ppt
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的更多相关文章
- Groovy入门教程
Groovy入门教程 kmyhy@126.com 2009-5-13 一.groovy是什么 简单地说,Groovy 是下一代的java语言,跟java一样,它也运行在 JVM 中. 作为跑在JVM ...
- GROOVY入门
refer to 精通Groovy(IBM)https://www.ibm.com/developerworks/cn/education/java/j-groovy/j-groovy.html re ...
- AngularJS入门基础PPT(附下载链接)
学习了Angularjs有段时间,自己写了一个PPT,个人认为总结的非常全面,对于入门基础够了. 大致模块有:Angularjs简单介绍,Angularjs特性,hello world,Control ...
- Groovy入门经典 随书重点
1 数值和表达式 1.1数值 整数是Integer类的实例 有小数部分的数值是BigDecimal类的实例 不同于java,没有基础数据类型 一切皆对象的概念重于java 1.2表达式 两个整数的除法 ...
- Groovy入门(2-2)Groovy的eclipse插件安装
1.安装eclipse插件 启动eclipse,点击help -> Install New Software... 在弹出的窗口中点击:Add... Groovy插件的地址:http://dis ...
- 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 ...
- HBase入门教程ppt
HBase – Hadoop Database,是一个高可靠性.高性能.面向列.可伸缩的分布式存储系统,利用HBase技术可在廉价PC Server上搭建起大规模结构化存储集群.HBase利用Hado ...
- 强化学习基础算法入门 【PPT】
该部分内容来自于定期的小组讨论,源于师弟的汇报. ==============================================
- groovy入门 第05章 基本输入输出
基本输入输出 5.1基本输出 print XXX //同一行输出 println XXX //换行输出 输出字符串: def message ="My name is Michael& ...
随机推荐
- Asp.Net 之 调用远程Web_Service
一.添加web service引用 1.右键 Web 项目 → “添加服务引用”: 2.右键已有的 App_WebReferences 文件夹 → “添加服务引用”: 二.引用远程web servic ...
- CentOS7 service/chkconfig replace commands
对比表,以 apache / httpd 为例 任务 旧指令 新指令 使某服务自动启动 chkconfig --level 3 httpd on systemctl enable httpd.serv ...
- 想做一个整合开源安全代码扫描工具的代码安全分析平台 - Android方向调研
想做一个整合开源安全代码扫描工具的代码安全分析平台 - Android方向调研 http://blog.csdn.net/testing_is_believing/article/details/22 ...
- myeclipse连接数据库遇到的几个问题
1:无效的SQL URL: //将获取的参数插入数据库 Connection conn=null; PreparedStatement stat=null; ...
- Floyd判圈算法(判断是否有环)
介意转吗博主~~http://blog.csdn.net/thestoryofsnow/article/details/6822576,我知道不介意啦~ 问题:如何检测一个链表是否有环,如果有,那么如 ...
- nodejs 微信中使用file组件上传图片在某些机型上点击无反应
看下下面的代码: <form action="/" class="file_upload" method="post" enctype ...
- [记录]java.math.biginteger cannot be cast to java.lang.long
可以直接使用BigInteger类型进行接收, BigInteger id = (BigInteger)QueryRunner(conn,"SELECT LAST_INSERT_ID&quo ...
- [MSDN]使用 REST 处理文件夹和文件
msdn: http://msdn.microsoft.com/zh-cn/library/dn292553.aspx 了解如何使用 SharePoint 2013 REST 界面对文件夹和文件执行基 ...
- JAXB - Annotations, Annotation for Classes: XmlType
This annotation adds information that would be available from a schema type, but isn't implied by a ...
- MySQL - 启停服务
Windows 环境 命令行方式 启动 MySQL 服务: net start mysql停止 MySQL 服务: net stop mysql 注:需要以管理员身份启动 cmd 后再执行上述命令. ...