SlideShare una empresa de Scribd logo
1 de 37
JGGUG
Grails/Groovy         3




   NTT


          2009/9/25
NTT

                        Gr

               Grails

            JavaWorld Groovy                               (2004)

            Twitter: uehaj




Slide# 2   JGGUG        Grails/Groovy   3   / 2009.09.25
Groovy




           Groovy
                                    Java




                                                         (Groovy Web Console)
     3
Slide#   JGGUG      Grails/Groovy     3   / 2009.09.25
(                 )
                                   (               ,      )




                            (                 )
                            (                       )

Slide# 4   JGGUG   Grails/Groovy       3   / 2009.09.25
Groovy
               X Y                   Z
               Z(Y(X))   …                        ←
               X.Y().Z() …                             →

                  :          Groovy
           × println(each(sort(grep({it%2=0},[1,3,2]))))
           ○   [1,3,2].grep{it%2==0}.sort().each{println it}




Slide# 5        JGGUG    Grails/Groovy   3   / 2009.09.25
each/reverseEach/                           collect
            eachWithIndex/                              find/findAll
                                                        grep/max/min
            reverse/push/pop/join                       any/every


                                                        contains/in/groupBy
                                                        flatten/intersect/disjoint
            each/keySet/entrySet/
            values                                      combinations/
                                                        transpose




Slide# 6   JGGUG     Grails/Groovy   3   / 2009.09.25
:
                                                          ArrayList
              println([1,2,3].class)
             =>java.util.ArrayList
           as                                             :

              [1,2,3] as Set                   // Set

              [1,2,3] as LinkedList        // LinkedList

              [1,2,3].asImmutable()       //

Slide# 7    JGGUG      Grails/Groovy   3   / 2009.09.25
:

                                             LinkedHashMap
            println([a:1,b:2,c:3].getClass())
            =>java.util.LinkedHashMap



            Map m = [a:1, b:2, c:3]
            assert m.get(’a’) == 1   //
            assert m[’a’] == 1       //
            assert m.a == 1          //


Slide# 8   JGGUG    Grails/Groovy   3   / 2009.09.25
map.get(key)
                   map.put(key,             Java
                           value)


                   map[’a’]
                   map[key]
                        
                     
                   map.a
                   map.”$key”               GString



Slide# 9   JGGUG     Grails/Groovy   3   / 2009.09.25
,     ,
              class City                    cities


            class City {
              def name;
              def country;
              long population;
            }
            cities = [
              new City("   ","            ",35676000),
             new City("                   ","                  ",19040000),
             new City("                    =                   ","
               :
Slide# 10    JGGUG        Grails/Groovy     3   / 2009.09.25
(                  )


                                     /


                ≒ Java

                     Closure
                println {->}.class
                ==> groovy.lang.Closure

Slide# 11   JGGUG    Grails/Groovy       3   / 2009.09.25
{-> ..}

                                                           (   )
                {-> println ”ABC” }
                ==>
                                      .call()
                {->println ”ABC” }.call()

                ==> ABC

Slide# 12   JGGUG     Grails/Groovy    3   / 2009.09.25
:
             Script.groovy result = 1
                          10.times {
                            result *= 2
                          }
                          assert result == 1024
 Script
  result = 1
  10.times {
    result *= 2
  }
  assert result ==




Slide# 13   JGGUG      Grails/Groovy   3   / 2009.09.25
:
             Script.groovy result = 1
                          10.times {
                            result *= 2
                          }
                          assert result == 1024
 Script
  result = 1
  10.times {                      Integer(10)
    result *= 2
  }
  assert result ==




Slide# 13   JGGUG      Grails/Groovy    3   / 2009.09.25
:
             Script.groovy result = 1
                          10.times {
                            result *= 2
                          }
                          assert result == 1024
 Script                                                    Integer         (10)
  result = 1
  10.times {                      Integer(10)              def
    result *= 2                                            times(Closure c){
  }                                                          c.call() 10
  assert result ==                                         }




Slide# 13   JGGUG      Grails/Groovy    3   / 2009.09.25
:
             Script.groovy result = 1
                          10.times {
                            result *= 2
                          }
                          assert result == 1024
 Script                                                    Integer         (10)
  result = 1
  10.times {                      Integer(10)              def
    result *= 2                                            times(Closure c){
  }                                                          c.call() 10
  assert result ==                                         }




Slide# 13   JGGUG      Grails/Groovy    3   / 2009.09.25
:
             Script.groovy result = 1
                          10.times {
                            result *= 2
                          }
                          assert result == 1024
 Script                                                      Integer         (10)
  result = 1
  10.times {                      Integer(10)                def
    result *= 2                                              times(Closure c){
  }                                                            c.call() 10
  assert result ==                                           }



                                {
                                       result *= 2
                                }

Slide# 13   JGGUG      Grails/Groovy      3   / 2009.09.25
:
             Script.groovy result = 1
                          10.times {
                            result *= 2
                          }
                          assert result == 1024
 Script                                                       Integer         (10)
  result = 1
  10.times {                      Integer(10)                 def
    result *= 2                                               times(Closure c){
  }                                                             c.call() 10
  assert result ==                       Integer#times        }



                                {
                                       result *= 2
                                }

Slide# 13   JGGUG      Grails/Groovy       3   / 2009.09.25
:
             Script.groovy result = 1
                          10.times {
                            result *= 2
                          }
                          assert result == 1024
 Script                                                       Integer         (10)
  result = 1
  10.times {                      Integer(10)                 def
    result *= 2                                               times(Closure c){
  }                                                             c.call() 10
  assert result ==                       Integer#times        }



                                {                                   (call)
                                       result *= 2
                                }

Slide# 13   JGGUG      Grails/Groovy       3   / 2009.09.25
:
             Script.groovy result = 1
                          10.times {
                            result *= 2
                          }
                          assert result == 1024
 Script                                                       Integer         (10)
  result = 1
  10.times {                      Integer(10)                 def
    result *= 2                                               times(Closure c){
  }                                                             c.call() 10
  assert result ==                       Integer#times        }



                                {                                   (call)
                                                                     (call)
                                       result *= 2
                                }

Slide# 13   JGGUG      Grails/Groovy       3   / 2009.09.25
:
             Script.groovy result = 1
                          10.times {
                            result *= 2
                          }
                          assert result == 1024
 Script                                                       Integer          (10)
  result = 1
  10.times {                      Integer(10)                 def
    result *= 2                                               times(Closure c){
  }                                                             c.call() 10
  assert result ==                       Integer#times        }



                                {                                   (call)
                                                                     (call)
                                       result *= 2                    (call)
                                }

Slide# 13   JGGUG      Grails/Groovy       3   / 2009.09.25
:
             Script.groovy result = 1
                          10.times {
                            result *= 2                           (result)
                          }
                          assert result == 1024
 Script                                                       Integer          (10)
  result = 1
  10.times {                      Integer(10)                 def
    result *= 2                                               times(Closure c){
  }                                                             c.call() 10
  assert result ==                       Integer#times        }



                                {                                   (call)
                                                                     (call)
                                       result *= 2                    (call)
                                }

Slide# 13   JGGUG      Grails/Groovy       3   / 2009.09.25
:
    import javax.swing.*
    import java.awt.event.*

    f = new JFrame(size:[200, 100])
    title = "hello"
    b = new JButton(title)
    b.addActionListener({println title} as ActionListener)
    f.contentPane.add(b)

    f.show()

                           as
            1                                                  implements
                                                                  key,
                value
Slide# 14       JGGUG   Grails/Groovy   3       / 2009.09.25
ExpandoMetaClass
                    (                   )




                                                                    DSL


                :

Slide# 15   JGGUG       Grails/Groovy   3   / 2009.09.25
?




Slide# 16   JGGUG   Grails/Groovy   3   / 2009.09.25
?




Slide# 16   JGGUG   Grails/Groovy   3   / 2009.09.25
:                ==~ =~
                 String.replaceAll(  )
             :/     /


                                 ( )                      GString   $

      ”ABCDE”
       ’ABCDE’
       /ABCDE/

Slide# 17   JGGUG       Grails/Groovy   3   / 2009.09.25
:
            String#replaceAll(String, Closure)
     "abcDefGhi".replaceAll(/([a-z])([A-Z])/) {fullMatch, g1, g2->
       g1 + '_' + g2.toLowerCase()
     }
     ==> "abc_def_ghi"




                Java String#replaceAll(String, String) OK($1,$2   )


Slide# 18      JGGUG       Grails/Groovy   3   / 2009.09.25
final




                      :



Slide# 19   JGGUG          Grails/Groovy   3   / 2009.09.25
: java.lang.String
                                         final


                    String

                    String




Slide# 20   JGGUG        Grails/Groovy    3   / 2009.09.25
tr                   (                                    )
                  String#tr()
     String.metaClass.tr = {from,to ->
       def result = delegate
       from.eachWithIndex{it,idx->
         result = result.replaceAll(it, to.getAt(idx))
       }
       result
     }

     println "abcdef               123".tr("abc              ","xyz       ")
     //==> "xyzdef             123"




Slide# 21        JGGUG    Grails/Groovy   3   / 2009.09.25
:
                          java.lang.String




Slide# 22   JGGUG   Grails/Groovy   3   / 2009.09.25
'ls'.metaClass.exec = { new File(".").eachFile{println it} }
       'pwd'.metaClass.exec = { println new File(".").absolutePath }
       'env'.metaClass.exec = {
         System.getenv().each{k,v->println "$k=$v" }
       }

       System.in.eachLine {
         it.intern().exec()
       }



                                                             →
                     : String#intern()

Slide# 23    JGGUG        Grails/Groovy   3   / 2009.09.25
Groovy                                  (              1)
                    groovyc
                                                      Groovy



                    groovyc jad(                                  )
                     groovyc             jad               Java

                             Groovy 1.6.x



Slide# 24   JGGUG        Grails/Groovy     3   / 2009.09.25
Groovy                               (      2)
               GDK
                DGM      DefaultGroovyMethods.java(
                DefaultGroovyStaticMethods)


                <GROOVY_SRC>/src/main/org/codehaus/groovy/
                runtime/DefaultGroovyMethods.java
               Groovy

                ant -Dskiptests=true

                GROOVY_HOME
                <GROOVY_SRC>/target/install


Slide# 25   JGGUG       Grails/Groovy   3   / 2009.09.25
Groovy                              (             )
                    Grape(Groovy 1.6-,)
                                   Jar                      (
                     )
                     import      @Grab(‘group:mod:ver’)             (1.7)
               Power Assert(1.7beta1-)
             assert
                a=5; assert a+Math.max(a+1, 5)+2==12
                ==>
                Assertion failed:
                assert a+Math.max(a+1, 5)+2==12
                       ||     |   ||     | |
                       |11    6   |6     | false
                       5          5      13
                
 at Script1.run(Script1.groovy:2)

Slide# 26   JGGUG        Grails/Groovy   3   / 2009.09.25
Groovy




                DB       (GroovySql)
                                      (SimpleTemplate)
                                              XML          (XmlSlurper,
                XmlParser)


Slide# 27   JGGUG     Grails/Groovy     3   / 2009.09.25

Más contenido relacionado

Similar a Jggug Nagoya 20090925 Groovy

Groovy to infinity and beyond - GR8Conf Europe 2010 - Guillaume Laforge
Groovy to infinity and beyond - GR8Conf Europe 2010 - Guillaume LaforgeGroovy to infinity and beyond - GR8Conf Europe 2010 - Guillaume Laforge
Groovy to infinity and beyond - GR8Conf Europe 2010 - Guillaume Laforge
Guillaume Laforge
 
Groovy Api Tutorial
Groovy Api  TutorialGroovy Api  Tutorial
Groovy Api Tutorial
guligala
 

Similar a Jggug Nagoya 20090925 Groovy (20)

Groovy to infinity and beyond - GR8Conf Europe 2010 - Guillaume Laforge
Groovy to infinity and beyond - GR8Conf Europe 2010 - Guillaume LaforgeGroovy to infinity and beyond - GR8Conf Europe 2010 - Guillaume Laforge
Groovy to infinity and beyond - GR8Conf Europe 2010 - Guillaume Laforge
 
Groovy
GroovyGroovy
Groovy
 
G*なクラウド 雲のかなたに ショートバージョン
G*なクラウド 雲のかなたに ショートバージョンG*なクラウド 雲のかなたに ショートバージョン
G*なクラウド 雲のかなたに ショートバージョン
 
Groovy and Grails talk
Groovy and Grails talkGroovy and Grails talk
Groovy and Grails talk
 
Introduction to Grails
Introduction to Grails Introduction to Grails
Introduction to Grails
 
Groovy.pptx
Groovy.pptxGroovy.pptx
Groovy.pptx
 
G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~
 
Groovy Api Tutorial
Groovy Api  TutorialGroovy Api  Tutorial
Groovy Api Tutorial
 
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionGradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 version
 
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume LaforgeGR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
 
An Introduction to Groovy for Java Developers
An Introduction to Groovy for Java DevelopersAn Introduction to Groovy for Java Developers
An Introduction to Groovy for Java Developers
 
Groovy as a scripting language
Groovy as a scripting languageGroovy as a scripting language
Groovy as a scripting language
 
Groovy
GroovyGroovy
Groovy
 
Apache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystemApache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystem
 
OpenLogic
OpenLogicOpenLogic
OpenLogic
 
Startup groovysession1
Startup groovysession1Startup groovysession1
Startup groovysession1
 
LISA QooxdooTutorial Slides
LISA QooxdooTutorial SlidesLISA QooxdooTutorial Slides
LISA QooxdooTutorial Slides
 
Groovy: to Infinity and Beyond -- JavaOne 2010 -- Guillaume Laforge
Groovy: to Infinity and Beyond -- JavaOne 2010 -- Guillaume LaforgeGroovy: to Infinity and Beyond -- JavaOne 2010 -- Guillaume Laforge
Groovy: to Infinity and Beyond -- JavaOne 2010 -- Guillaume Laforge
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
 

Más de Uehara Junji

Groovy kisobenkyoukai20130309
Groovy kisobenkyoukai20130309Groovy kisobenkyoukai20130309
Groovy kisobenkyoukai20130309
Uehara Junji
 
Java One 2012 Tokyo JVM Lang. BOF(Groovy)
Java One 2012 Tokyo JVM Lang. BOF(Groovy)Java One 2012 Tokyo JVM Lang. BOF(Groovy)
Java One 2012 Tokyo JVM Lang. BOF(Groovy)
Uehara Junji
 
Easy Going Groovy(Groovyを気軽に使いこなそう)
Easy Going Groovy(Groovyを気軽に使いこなそう)Easy Going Groovy(Groovyを気軽に使いこなそう)
Easy Going Groovy(Groovyを気軽に使いこなそう)
Uehara Junji
 

Más de Uehara Junji (20)

Groovy Bootcamp 2015 by JGGUG
Groovy Bootcamp 2015 by JGGUGGroovy Bootcamp 2015 by JGGUG
Groovy Bootcamp 2015 by JGGUG
 
Groovy Shell Scripting 2015
Groovy Shell Scripting 2015Groovy Shell Scripting 2015
Groovy Shell Scripting 2015
 
Shibuya JVM Groovy 20150418
Shibuya JVM Groovy 20150418Shibuya JVM Groovy 20150418
Shibuya JVM Groovy 20150418
 
Introduce Groovy 2.3 trait
Introduce Groovy 2.3 trait Introduce Groovy 2.3 trait
Introduce Groovy 2.3 trait
 
Indy(Invokedynamic) and Bytecode DSL and Brainf*ck
Indy(Invokedynamic) and Bytecode DSL and Brainf*ckIndy(Invokedynamic) and Bytecode DSL and Brainf*ck
Indy(Invokedynamic) and Bytecode DSL and Brainf*ck
 
enterprise grails challenge, 2013 Summer
enterprise grails challenge, 2013 Summerenterprise grails challenge, 2013 Summer
enterprise grails challenge, 2013 Summer
 
New features of Groovy 2.0 and 2.1
New features of Groovy 2.0 and 2.1New features of Groovy 2.0 and 2.1
New features of Groovy 2.0 and 2.1
 
Groovy kisobenkyoukai20130309
Groovy kisobenkyoukai20130309Groovy kisobenkyoukai20130309
Groovy kisobenkyoukai20130309
 
Read Groovy Compile process(Groovy Benkyoukai 2013)
Read Groovy Compile process(Groovy Benkyoukai 2013)Read Groovy Compile process(Groovy Benkyoukai 2013)
Read Groovy Compile process(Groovy Benkyoukai 2013)
 
groovy 2.1.0 20130118
groovy 2.1.0 20130118groovy 2.1.0 20130118
groovy 2.1.0 20130118
 
G* Workshop in fukuoka 20120901
G* Workshop in fukuoka 20120901G* Workshop in fukuoka 20120901
G* Workshop in fukuoka 20120901
 
JJUG CCC 2012 Real World Groovy/Grails
JJUG CCC 2012 Real World Groovy/GrailsJJUG CCC 2012 Real World Groovy/Grails
JJUG CCC 2012 Real World Groovy/Grails
 
Java One 2012 Tokyo JVM Lang. BOF(Groovy)
Java One 2012 Tokyo JVM Lang. BOF(Groovy)Java One 2012 Tokyo JVM Lang. BOF(Groovy)
Java One 2012 Tokyo JVM Lang. BOF(Groovy)
 
Java x Groovy: improve your java development life
Java x Groovy: improve your java development lifeJava x Groovy: improve your java development life
Java x Groovy: improve your java development life
 
Groovy 1.8の新機能について
Groovy 1.8の新機能についてGroovy 1.8の新機能について
Groovy 1.8の新機能について
 
Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...
Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...
Let's go Developer 2011 sendai Let's go Java Developer (Programming Language ...
 
Easy Going Groovy 2nd season on DevLOVE
Easy Going Groovy 2nd season on DevLOVEEasy Going Groovy 2nd season on DevLOVE
Easy Going Groovy 2nd season on DevLOVE
 
Easy Going Groovy(Groovyを気軽に使いこなそう)
Easy Going Groovy(Groovyを気軽に使いこなそう)Easy Going Groovy(Groovyを気軽に使いこなそう)
Easy Going Groovy(Groovyを気軽に使いこなそう)
 
GroovyServ concept, how to use and outline.
GroovyServ concept, how to use and outline.GroovyServ concept, how to use and outline.
GroovyServ concept, how to use and outline.
 
Clojure
ClojureClojure
Clojure
 

Último

Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 

Último (20)

Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 

Jggug Nagoya 20090925 Groovy

  • 1. JGGUG Grails/Groovy 3 NTT 2009/9/25
  • 2. NTT Gr Grails JavaWorld Groovy (2004) Twitter: uehaj Slide# 2 JGGUG Grails/Groovy 3 / 2009.09.25
  • 3. Groovy Groovy Java (Groovy Web Console) 3 Slide# JGGUG Grails/Groovy 3 / 2009.09.25
  • 4. ( ) ( , ) ( ) ( ) Slide# 4 JGGUG Grails/Groovy 3 / 2009.09.25
  • 5. Groovy X Y Z Z(Y(X)) … ← X.Y().Z() … → : Groovy × println(each(sort(grep({it%2=0},[1,3,2])))) ○ [1,3,2].grep{it%2==0}.sort().each{println it} Slide# 5 JGGUG Grails/Groovy 3 / 2009.09.25
  • 6. each/reverseEach/ collect eachWithIndex/ find/findAll grep/max/min reverse/push/pop/join any/every contains/in/groupBy flatten/intersect/disjoint each/keySet/entrySet/ values combinations/ transpose Slide# 6 JGGUG Grails/Groovy 3 / 2009.09.25
  • 7. : ArrayList  println([1,2,3].class) =>java.util.ArrayList as :  [1,2,3] as Set                   // Set  [1,2,3] as LinkedList        // LinkedList  [1,2,3].asImmutable()       // Slide# 7 JGGUG Grails/Groovy 3 / 2009.09.25
  • 8. : LinkedHashMap println([a:1,b:2,c:3].getClass()) =>java.util.LinkedHashMap Map m = [a:1, b:2, c:3]  assert m.get(’a’) == 1   //  assert m[’a’] == 1       //  assert m.a == 1          // Slide# 8 JGGUG Grails/Groovy 3 / 2009.09.25
  • 9. map.get(key) map.put(key, Java value) map[’a’] map[key]          map.a map.”$key” GString Slide# 9 JGGUG Grails/Groovy 3 / 2009.09.25
  • 10. , , class City cities class City { def name; def country; long population; } cities = [ new City(" "," ",35676000), new City(" "," ",19040000), new City(" = "," : Slide# 10 JGGUG Grails/Groovy 3 / 2009.09.25
  • 11. ( ) / ≒ Java Closure println {->}.class ==> groovy.lang.Closure Slide# 11 JGGUG Grails/Groovy 3 / 2009.09.25
  • 12. {-> ..} ( ) {-> println ”ABC” } ==> .call() {->println ”ABC” }.call() ==> ABC Slide# 12 JGGUG Grails/Groovy 3 / 2009.09.25
  • 13. : Script.groovy result = 1 10.times {   result *= 2 } assert result == 1024 Script result = 1 10.times { result *= 2 } assert result == Slide# 13 JGGUG Grails/Groovy 3 / 2009.09.25
  • 14. : Script.groovy result = 1 10.times {   result *= 2 } assert result == 1024 Script result = 1 10.times { Integer(10) result *= 2 } assert result == Slide# 13 JGGUG Grails/Groovy 3 / 2009.09.25
  • 15. : Script.groovy result = 1 10.times {   result *= 2 } assert result == 1024 Script Integer (10) result = 1 10.times { Integer(10) def result *= 2 times(Closure c){ } c.call() 10 assert result == } Slide# 13 JGGUG Grails/Groovy 3 / 2009.09.25
  • 16. : Script.groovy result = 1 10.times {   result *= 2 } assert result == 1024 Script Integer (10) result = 1 10.times { Integer(10) def result *= 2 times(Closure c){ } c.call() 10 assert result == } Slide# 13 JGGUG Grails/Groovy 3 / 2009.09.25
  • 17. : Script.groovy result = 1 10.times {   result *= 2 } assert result == 1024 Script Integer (10) result = 1 10.times { Integer(10) def result *= 2 times(Closure c){ } c.call() 10 assert result == } { result *= 2 } Slide# 13 JGGUG Grails/Groovy 3 / 2009.09.25
  • 18. : Script.groovy result = 1 10.times {   result *= 2 } assert result == 1024 Script Integer (10) result = 1 10.times { Integer(10) def result *= 2 times(Closure c){ } c.call() 10 assert result == Integer#times } { result *= 2 } Slide# 13 JGGUG Grails/Groovy 3 / 2009.09.25
  • 19. : Script.groovy result = 1 10.times {   result *= 2 } assert result == 1024 Script Integer (10) result = 1 10.times { Integer(10) def result *= 2 times(Closure c){ } c.call() 10 assert result == Integer#times } { (call) result *= 2 } Slide# 13 JGGUG Grails/Groovy 3 / 2009.09.25
  • 20. : Script.groovy result = 1 10.times {   result *= 2 } assert result == 1024 Script Integer (10) result = 1 10.times { Integer(10) def result *= 2 times(Closure c){ } c.call() 10 assert result == Integer#times } { (call) (call) result *= 2 } Slide# 13 JGGUG Grails/Groovy 3 / 2009.09.25
  • 21. : Script.groovy result = 1 10.times {   result *= 2 } assert result == 1024 Script Integer (10) result = 1 10.times { Integer(10) def result *= 2 times(Closure c){ } c.call() 10 assert result == Integer#times } { (call) (call) result *= 2 (call) } Slide# 13 JGGUG Grails/Groovy 3 / 2009.09.25
  • 22. : Script.groovy result = 1 10.times {   result *= 2 (result) } assert result == 1024 Script Integer (10) result = 1 10.times { Integer(10) def result *= 2 times(Closure c){ } c.call() 10 assert result == Integer#times } { (call) (call) result *= 2 (call) } Slide# 13 JGGUG Grails/Groovy 3 / 2009.09.25
  • 23. : import javax.swing.* import java.awt.event.* f = new JFrame(size:[200, 100]) title = "hello" b = new JButton(title) b.addActionListener({println title} as ActionListener) f.contentPane.add(b) f.show() as 1 implements key, value Slide# 14 JGGUG Grails/Groovy 3 / 2009.09.25
  • 24. ExpandoMetaClass ( ) DSL : Slide# 15 JGGUG Grails/Groovy 3 / 2009.09.25
  • 25. ? Slide# 16 JGGUG Grails/Groovy 3 / 2009.09.25
  • 26. ? Slide# 16 JGGUG Grails/Groovy 3 / 2009.09.25
  • 27. : ==~ =~ String.replaceAll( ) :/ / ( ) GString $ ”ABCDE” ’ABCDE’ /ABCDE/ Slide# 17 JGGUG Grails/Groovy 3 / 2009.09.25
  • 28. : String#replaceAll(String, Closure) "abcDefGhi".replaceAll(/([a-z])([A-Z])/) {fullMatch, g1, g2-> g1 + '_' + g2.toLowerCase() } ==> "abc_def_ghi" Java String#replaceAll(String, String) OK($1,$2 ) Slide# 18 JGGUG Grails/Groovy 3 / 2009.09.25
  • 29. final : Slide# 19 JGGUG Grails/Groovy 3 / 2009.09.25
  • 30. : java.lang.String final String String Slide# 20 JGGUG Grails/Groovy 3 / 2009.09.25
  • 31. tr ( ) String#tr() String.metaClass.tr = {from,to ->   def result = delegate   from.eachWithIndex{it,idx->     result = result.replaceAll(it, to.getAt(idx))   }   result } println "abcdef 123".tr("abc ","xyz ") //==> "xyzdef 123" Slide# 21 JGGUG Grails/Groovy 3 / 2009.09.25
  • 32. : java.lang.String Slide# 22 JGGUG Grails/Groovy 3 / 2009.09.25
  • 33. 'ls'.metaClass.exec = { new File(".").eachFile{println it} } 'pwd'.metaClass.exec = { println new File(".").absolutePath } 'env'.metaClass.exec = { System.getenv().each{k,v->println "$k=$v" } } System.in.eachLine {   it.intern().exec() } → : String#intern() Slide# 23 JGGUG Grails/Groovy 3 / 2009.09.25
  • 34. Groovy ( 1) groovyc Groovy groovyc jad( ) groovyc jad Java Groovy 1.6.x Slide# 24 JGGUG Grails/Groovy 3 / 2009.09.25
  • 35. Groovy ( 2) GDK DGM DefaultGroovyMethods.java( DefaultGroovyStaticMethods) <GROOVY_SRC>/src/main/org/codehaus/groovy/ runtime/DefaultGroovyMethods.java Groovy ant -Dskiptests=true GROOVY_HOME <GROOVY_SRC>/target/install Slide# 25 JGGUG Grails/Groovy 3 / 2009.09.25
  • 36. Groovy ( ) Grape(Groovy 1.6-,) Jar ( ) import @Grab(‘group:mod:ver’) (1.7) Power Assert(1.7beta1-) assert a=5; assert a+Math.max(a+1, 5)+2==12 ==> Assertion failed: assert a+Math.max(a+1, 5)+2==12 || | || | | |11 6 |6 | false 5 5 13 at Script1.run(Script1.groovy:2) Slide# 26 JGGUG Grails/Groovy 3 / 2009.09.25
  • 37. Groovy DB (GroovySql) (SimpleTemplate) XML (XmlSlurper, XmlParser) Slide# 27 JGGUG Grails/Groovy 3 / 2009.09.25