Programming Groovy dynamic productivity for the java developer phần 2 potx
... miles Miles: 25 Let’s rewrite the code in Groovy: Download GroovyForJavaEyes/GroovyCar .groovy class Car { def miles = 0 final year Car(theYear) { year = theYear } } Car car = new Car (20 08) IMPLEMENTING ... print "$it " } The output from the previous code is as follows: 0 2 4 6 8 1. http:/ /groovy. codehaus.org/Looping JAVABEANS 48 Download GroovyForJavaEyes/GroovyCar...
Ngày tải lên: 12/08/2014, 23:22
... ${car.ampy()}" The output from the previous code is as follows: miles year make Avg. MPY 424 51 20 03 Acura 8490 .2 24031 20 03 Chevy 4806 .2 1 423 3 20 06 Honda 7116.5 424 51 20 03 Acura 8490 .2 Chapter 15 MOPping ... well. CREATING DYNAMIC CLASSES WITH EXPANDO 22 6 extracting the property names. Then you create instances of Expando, one for each line of data in the...
Ngày tải lên: 12/08/2014, 23:22
... it: Download UnitTestingWithGroovy/TestUsingMockFor .groovy //def fileMock = new groovy. mock.interceptor.StubFor (java. io.FileWriter) def fileMock = new groovy. mock.interceptor.MockFor (java. io.FileWriter) You ... of stubs. Then we’ll take a look at the advantage mocks offer by using MockFor. Using StubFor Let’s use Groovy s StubFor to create stubs for the File class: Download U...
Ngày tải lên: 12/08/2014, 23:22
Programming Groovy dynamic productivity for the java developer phần 1 docx
... friendly java. lang.Integer chirping dynamic behavior in Groovy, as you’ll learn later in this book. Programming Groovy Dynamic Productivity for the Java Developer Venkat Subrama niam The P ragmatic ... more performant. To reap the benefit of the platform and to tackle the inher- ent complexities of your applications, you need another tool—one with a dynamic and m...
Ngày tải lên: 12/08/2014, 23:22
Programming Groovy dynamic productivity for the java developer phần 3 ppsx
... Injection and Synthesis, on page 20 2. Between the time the code is compiled and before it is executed, you have the ability to inject missing methods dynamically. 19. Defining an int in Groovy, for example, ... applicable for argument types: () values: {} How’s that? The iterator (for loop) tr eat ed the elements as objects, so there was no error on line number 16 Groovy too...
Ngày tải lên: 12/08/2014, 23:22
Programming Groovy dynamic productivity for the java developer phần 4 doc
... expression you created before to print the quote for these companies as well. So, you iterate over the stocks map—within the closure you have the company as the key and the price as the value. However, ... 5, "moon" ) println text The output from the previous code is as follows: The cow jumped over the fence The cow jumped over the moon The GString (tex...
Ngày tải lên: 12/08/2014, 23:22
Programming Groovy dynamic productivity for the java developer phần 5 docx
... This extension is called the Groovy JDK or the GDK. 1 The relationship between the JDK and the GDK is shown in Figure 8.1, on the following page. The GDK sits on top of the JDK, so wh en you pass ... it * 2 } println doubled The output from the previous code is as follows: [2, 6, 8, 2, 16, 18, 4, 12] You create an empty ArrayList n amed doubled to hold the result....
Ngày tải lên: 12/08/2014, 23:22
Programming Groovy dynamic productivity for the java developer phần 6 pot
... JSR 22 3 with Java 5. It is included in Java 6. JSR 22 3 currently works only wi th Groovy 1.0 and not with Groovy 1.5. JSR 22 3 is an option more suited for other languages on the JVM than for Groovy. ... Using Groovy Classes from Java If the Groovy classes are precompiled, then you can use the .class files or JARs readily in Java. Java sees no difference betwee...
Ngày tải lên: 12/08/2014, 23:22
Programming Groovy dynamic productivity for the java developer phần 7 pot
... thod, as on line number 22 . If the meth od is not found, simply route the r equest to the MetaClass, as on line number 26 . This gives an opportunity for the method to be synthesized dynamically, as you’ll ... implement the before or after advice (or both), implement your before/after logic, and route the call to the actual method at the appropriate time. To route the c...
Ngày tải lên: 12/08/2014, 23:22
Programming Groovy dynamic productivity for the java developer phần 10 pptx
... 190–191 synthesis for specific instances, 22 2 22 3 synthesis using ExpandoMetaClass, 21 9 22 2 synthesis using methodMissing (), 21 4 21 8 techniques, 23 1 23 2 MetaClass, 197 20 1 Method delegation, 22 7 23 1 Method ... synthesis defined, 21 4 ExpandoMetaClass, 21 9 22 2 vs. injection, 20 3 methodMissing (), 21 4 21 8 options for, 23 2 for specific instances, 22 2 22 3 methodMi...
Ngày tải lên: 12/08/2014, 23:22