【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& ...
随机推荐
- ubuntu nexus 安装
今天公司组织学习使用linux系统搭建nexus maven私服中央仓库,在公司使用centos搭建了一个,回家又用ubuntu搭建一个,主要是为了能熟悉整个流程,现将主要过程总结如下:(PS:楼主是 ...
- JMS简介
任何一个系统从整体上来看,其实质就是由无数个小的服务或事件(我们可以称之为事务单元)有机地组合起来的.对于系统中任何一个比较复杂的功能,都是通过调用各个独立的事务单元以实现统一的协调运作而实现的.现在 ...
- jquery_ajax
一.调用 <script type="text/javascript" src="jquery-1.11.2.min.js"></script ...
- webstorm卡、闪退以及win10中jdk配置
今天 webstorm 突然一直处于 indexing 索引状态,然后就卡死,重装也无法解决. 搜了一下后,有人说使用 64 位客户端打开就ok. 尝试打开 64 位的客户端,但是报错,没有64位 j ...
- gluster 安装配置基本指南
基于网络上的多篇文章,做了一些调整. gluster安装 ### Installing Gluster wget -P /etc/yum.repos.d http://download.gluste ...
- ASP.NET网络硬盘(文件上传,文件下载)
文件上传: 界面: 前台代码: <body style="text-align: center; background-image: url(Images/bg6.bmp);" ...
- 第一次使用并配置Hibernate
1. 环境配置 1.1 hiberante环境配置 hibernate可实现面向对象的数据存储.hibernate的官网:http://hibernate.org/ 官网上选择hibernate OR ...
- EPP3怎么安装SVN(EclipsePHP Studio 3.0)
如果你和我一样,喜欢用eclipse,你想用用他来开发PHP,那么EPP是一个不错的选择(个人觉得,中文版的有点不习惯) 我们一般都用svn来进行版本控制和代码共享,但是用epp3的时候会遇到这么一个 ...
- 在XP系统下搭建maven环境出的问题 Unable to locate the Javac Compiler in: C:\Program Files\Java\jre6\..\lib\tools.jar
Build errors for spider; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute g ...
- ###学习《C++ Primer》- 3
点击查看Evernote原文. #@author: gr #@date: 2014-10-04 #@email: forgerui@gmail.com Part 3: STL泛型算法(第10章) 一. ...