Skip to content
develop
Go to file
Code
This branch is 83 commits ahead, 1292 commits behind rzwitserloot:master.

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
doc
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Hrisey Build Status

Join the chat at https://gitter.im/mg6maciej/hrisey

Boilerplate code suppressor tool for Android platform based on Project Lombok.

More details on available annotaions in wiki pages.

Current limitation: doesn't work with JDK 8. Any help resolving this issue is highly appreciated.

Usage

Add Hrisey as a dependency:

dependencies {
    provided 'pl.mg6.hrisey:hrisey:0.3.1'
}

Install Hrisey Plugin in IntelliJ IDEA or Android Studio.

And then just start using it:

@hrisey.Parcelable
class ParcelableClass implements android.os.Parcelable {

    String myString;
}

Note: adding implements android.os.Parcelable seems redundant, but is there only because of a limitation when using certain Jetbrains APIs. Hrisey will generate it if missing, but IDEA / Android Studio will not undestand it.

This will generate

class ParcelableClass implements android.os.Parcelable {

    public static final android.os.Parcelable.Creator<ParcelableClass> CREATOR = new CreatorImpl();

    String myString;

    public int describeContents() {
        return 0;
    }

    public void writeToParcel(android.os.Parcel dest, int flags) {
        dest.writeString(this.myString);
    }

    protected ParcelableClass(android.os.Parcel source) {
        this.myString = source.readString();
    }

    private static class CreatorImpl implements android.os.Parcelable.Creator<ParcelableClass> {

        public ParcelableClass createFromParcel(android.os.Parcel source) {
            return new ParcelableClass(source);
        }

        public ParcelableClass[] newArray(int size) {
            return new ParcelableClass[size];
        }
    }
}

during preprocessing phase. You will never see this code again!

Optimization hint: when possible, add final to classes with @Parcelable annotation to avoid some reflection and storing unnecessary bits of data.

Why is Hrisey better?

Because it "adds" code to your classes. Other tools use JSR 269 to generate new classes, which leads to leaking abstraction in your code. Hrisey is transparent and can be technically removed from your project in a matter of minutes. But when you start using it, you will never think of doing so.

Why is Hrisey worse?

Because it "adds" code to your classes. You have to be careful not to put there too much logic yourself, because debugging might be more complicated.

About Lombok

Project Lombok makes java a spicier language by adding 'handlers' that know how to build and compile simple, boilerplate-free, not-quite-java code. See LICENSE for the Project Lombok license.

To start, run:

ant -projecthelp

HINT: If you'd like to develop lombok in eclipse, run ant eclipse first. It creates the necessary project infrastructure and downloads dependencies. Note that, in order to run "LombokizedEclipse.launch", you need to have "Eclipse SDK" installed.

For a list of all authors, see the AUTHORS file.

Project Lombok was started by:

Reinier Zwitserloot
twitter: @surial
home: http://zwitserloot.com/

Roel Spilker
twitter: @rspilker

About

Hrisey - boilerplate code suppressor tool for Android platform

Topics

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.