Skip to content

Instantly share code, notes, and snippets.

View liviutudor's full-sized avatar

Liviu Tudor liviutudor

View GitHub Profile
@liviutudor
liviutudor / BeanOne.groovy
Created October 31, 2017 05:56
Groovy bean one with handcrafted comparison
package delegation
import groovy.transform.TupleConstructor
@TupleConstructor
class BeanOne implements Comparable<BeanOne> {
String firstName
String familyName
public String getFullName() {
@liviutudor
liviutudor / BeanTwo.groovy
Created October 31, 2017 05:57
Bean two with handcrafted comparison
package delegation
import groovy.transform.TupleConstructor
@TupleConstructor
class BeanTwo implements Comparable<BeanTwo> {
int yob
public int getAge() {
new Date().year - yob
@liviutudor
liviutudor / DelegationBean.groovy
Created October 31, 2017 05:58
after handcrafting the comparison in the beans we are delegating to
package delegation
import groovy.transform.Sortable
class DelegationBean {
@Delegate
BeanOne person
@Delegate
BeanTwo dateOfBirth
@liviutudor
liviutudor / ReadJarManifest.java
Created November 21, 2019 07:41
How to read own manifest file and get version number
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"));