Advertisement
Advertisement

More Related Content

Advertisement
Advertisement

GroovyConsole2

  1. GroovyConsole @kiy0taka
  2. ( ) id:kiy0taka @kiy0taka Grails/Groovy Jenkins jQuery jQueryUI Terminal TEPCO MongoDB
  3. GroovyConsole http://www.slideshare.net/kiy0taka/groovyconsole GroovyConsole http://d.hatena.ne.jp/uehaj/20110701/1309532411
  4. EqualsAndHashCode? Groovy 1.8 AST 1 AST AST( ) PowerAsser @EqualsAndHashCode equals() hashCode()
  5. class Person { String name int age } def p1 = new Person(name:'Kiyotaka Oku', age:31) def p2 = new Person(name:'Kiyotaka Oku', age:31) assert p1 == p2 assert p1 == p2 | | | | | Person@20e5f01b | false Person@57f68d7c
  6. import groovy.transform.EqualsAndHashCode @EqualsAndHashCode class Person { String name int age } def p1 = new Person(name:'Kiyotaka Oku', age:31) def p2 = new Person(name:'Kiyotaka Oku', age:31) assert p1 == p2 assert p1.hashCode() == p2.hashCode()
  7. 1.8 AST
  8. @Log @Commons @Log4j @Slf4j @Field @PackageScope @AutoClone @AutoExternalizable @ThreadInterrupt @TimedInterrupt @ConditionalInterrupt @ToString @EqualsAndHashCode @TupleConstructor @Canonical @InheritConstructors @WithReadLock @WithWriteLock @ListenerList
  9. 1.8
  10. Compilation customizers ImportCustomizer ASTTransformationCustomizer AST SecureASTCustomizer AST (?)
  11. import org.codehaus.groovy.control.CompilerConfiguration import org.codehaus.groovy.control.customizers.* import groovy.util.logging.Log def configuration = new CompilerConfiguration() configuration.addCompilationCustomizers( new ASTTransformationCustomizer(Log)) def shell = new GroovyShell(configuration) shell.evaluate(""" class Car { Car() { log.info 'Car constructed' } } log.info 'Constructing a car' def c = new Car() """)
  12. GroovyConsole
  13. YutoriConsole.groovy import javax.swing.UIManager import groovy.ui.Console import org.codehaus.groovy.control.CompilerConfiguration import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer import groovy.transform.* def transformations = [ThreadInterrupt, Canonical] Console.metaClass.newScript = { ClassLoader parent, Binding binding -> def config = new CompilerConfiguration() config.addCompilationCustomizers(*transformations.collect{ new ASTTransformationCustomizer(it)}) delegate.shell = new GroovyShell(parent, binding, config) } UIManager.lookAndFeel = UIManager.systemLookAndFeelClassName new Console(Console.class.classLoader.getRootLoader()).run() https://gist.github.com/1059105
  14. Groovy
Advertisement