This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait Foo<T> { | |
| T getSomething() { | |
| // how to return an instance of whatever T represents?... | |
| } | |
| } | |
| class FooSomething implements Foo<Person> { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| groovy:000> | |
| groovy:000> aString = 'some string' | |
| ===> some string | |
| groovy:000> aDoubleQuotedString = "some string" | |
| ===> some string | |
| groovy:000> aGString = "Year: ${2070+42}" | |
| ===> Year: 2112 | |
| groovy:000> | |
| groovy:000> aString.class | |
| ===> class java.lang.String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def query = Person.where { | |
| pets.size() == 2 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import grails.boot.GrailsApp | |
| import grails.boot.config.GrailsAutoConfiguration | |
| import org.apache.catalina.Context | |
| import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer | |
| import org.springframework.context.annotation.Bean | |
| class Application extends GrailsAutoConfiguration { | |
| static void main(String[] args) { | |
| GrailsApp.run(Application, args) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Resource(uri='/people') | |
| class Person { | |
| String firstName | |
| String lastName | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| privateaccess $ cat Widget.java | |
| public class Widget { | |
| private int size = 42; | |
| } | |
| privateaccess $ | |
| privateaccess $ cat Demo.groovy | |
| class Demo { | |
| static void main(args) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ~ $ java -version | |
| java version "1.8.0_131" | |
| Java(TM) SE Runtime Environment (build 1.8.0_131-b11) | |
| Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode) | |
| ~ $ | |
| ~ $ cat Doit.java | |
| public class Doit { | |
| public static void main(String[] a) { | |
| System.out.println("Hi"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| groovy:000> initialMap = [name: 'Jeff', company: 'OCI'] | |
| ===> [name:Jeff, company:OCI] | |
| groovy:000> | |
| groovy:000> secondMap = initialMap.collectEntries { k, v -> | |
| groovy:001> ["-$k", v] | |
| groovy:002> } | |
| ===> [-name:Jeff, -company:OCI] | |
| groovy:000> | |
| groovy:000> println "Initial Map: $initialMap" | |
| Initial Map: [name:Jeff, company:OCI] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ~ $ mn create-app --features swagger-java withswagger | |
| | Generating Java project... | |
| | Application created at /Users/jeffbrown/withswagger | |
| ~ $ | |
| ~ $ | |
| ~ $ mn create-app withoutswagger | |
| | Generating Java project... | |
| | Application created at /Users/jeffbrown/withoutswagger | |
| ~ $ | |
| ~ $ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private Function<String, Mono<? extends Orders>> keyToOrder(RedisReactiveCommands<String, String> commands) { | |
| return { key -> | |
| Flux<KeyValue<String, String>> values = commands.hmget(key, "price", "description") | |
| Map map = [:] | |
| return values.reduce(map, (all, keyValue)= {all.put(keyValue.getKey(), keyValue.getValue()) | |
| return all | |
| }).map({entries -> ConvertibleValues.of(entries)}) | |
| .flatMap({entries -> | |
| String description = entries.get("description", String.class).orElseThrow({ new IllegalStateException("No description")}) | |
| BigDecimal price = entries.get("price", BigDecimal.class).orElseThrow({new IllegalStateException("No price")}) |