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
| URLClassLoader cl = (URLClassLoader) App.class.getClassLoader(); | |
| URL url = cl.findResource("META-INF/MANIFEST.MF"); | |
| Manifest manifest = new Manifest(url.openStream()); | |
| Attributes attr = manifest.getMainAttributes()); | |
| System.out.println(manifest.getMainAttributes().getValue("Implementation-Title")); |
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
| package delegation | |
| import groovy.transform.Sortable | |
| class DelegationBean { | |
| @Delegate | |
| BeanOne person | |
| @Delegate | |
| BeanTwo dateOfBirth |
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
| package delegation | |
| import groovy.transform.TupleConstructor | |
| @TupleConstructor | |
| class BeanTwo implements Comparable<BeanTwo> { | |
| int yob | |
| public int getAge() { | |
| new Date().year - yob |
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
| package delegation | |
| import groovy.transform.TupleConstructor | |
| @TupleConstructor | |
| class BeanOne implements Comparable<BeanOne> { | |
| String firstName | |
| String familyName | |
| public String getFullName() { |
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
| class DelegationBean { | |
| @Delegate | |
| BeanOne person | |
| @Delegate | |
| BeanTwo dateOfBirth | |
| static void main(String... args) { | |
| DelegationBean one = new DelegationBean(person: new BeanOne("Liviu", "Tudor"), dateOfBirth: new BeanTwo(yob: 1975)) | |
| DelegationBean two = new DelegationBean(person: new BeanOne("William", "Shakespeare"), dateOfBirth: new BeanTwo(yob: 1564)) |
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 groovy.transform.Sortable | |
| import groovy.transform.TupleConstructor | |
| @Sortable | |
| @TupleConstructor | |
| class BeanTwo { | |
| int yob | |
| public int getAge() { | |
| new Date().year - yob |
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 groovy.transform.Sortable | |
| import groovy.transform.TupleConstructor | |
| @Sortable | |
| @TupleConstructor | |
| class BeanOne { | |
| String firstName | |
| String familyName | |
| public String getFullName() { |
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 java.beans.ConstructorProperties; | |
| public class JacksonBean { | |
| private final int value; | |
| private final String another; | |
| @ConstructorProperties({"value", "another"}) | |
| public JacksonBean(int value, String another) { | |
| this.value = value; | |
| this.another = another; |
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 com.fasterxml.jackson.annotation.JsonCreator; | |
| import com.fasterxml.jackson.annotation.JsonProperty; | |
| public class JacksonBean { | |
| private final int value; | |
| private final String another; | |
| @JsonCreator | |
| public JacksonBean(@JsonProperty("value") int value, @JsonProperty("another") String another) { | |
| this.value = value; |
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
| @GET | |
| public Observable<Response> processRequest( @QueryParam("id")String id, @QueryParam("userId")String userId ) { | |
| return Observable.zip( | |
| Observable.fromCallable(() -> database.retrieveRecord(id)), | |
| Observable.fromCallable(() -> userStore.retrieve(userId)), | |
| Observable.fromCallable(() -> logger.writeEntryFor(id, userId)), | |
| this::generateAdResponse | |
| ); | |
| } |
NewerOlder