Demo entry 6783565

Groovy class

   

Submitted by anonymous on Feb 16, 2019 at 15:24
Language: Groovy. Code size: 1.0 kB.

package example.app

import example.lib.Baz

/**
 * Example class.
 * 
 * With this we might use `Asciidoclet` or some <code>markup</code>.
 *
 * @author No One You Know <me@here.net>
 */
@CompileStatic
class Foo extends Bar {
    private final Baz baz // <1>
    private final String name
    private final List<Screen> screens = [new Screen('1'), new Screen('2')]
    private final Map<String, String> options = [
        one: '1',
        two: '2',
        three: """\
           This is a multiline text.
           Just to see.
        """.stripIndent()
    ]

    @Inject // <2>
    Foo(final Bar bar, final String name) { // <3>
        super(bar) // <4>
        this.name = name
    }

    void greet(String who) {
        screens.each { screen ->
            println "Hello, $who! It's ${name ?: 'me'} calling!"
        }
        for (final screen : screens} {
            screen.clear()
        }
        throw new IllegalArgumentException("who", who)
    }
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).