All Projects → google → easybundler

google / easybundler

Licence: Apache-2.0 License
A code generator for Android Bundles

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to easybundler

retidy
Extract, unminify, and beautify ("retidy") each file from a webpack/parcel bundle (JavaScript reverse engineering)
Stars: ✭ 27 (-49.06%)
Mutual labels:  bundle
macpack
Makes a macOS binary redistributable by searching the dependency tree and copying/patching non-system libraries.
Stars: ✭ 20 (-62.26%)
Mutual labels:  bundle
CQRSAzure
CQRS on Windows Azure
Stars: ✭ 25 (-52.83%)
Mutual labels:  codegen
SonataAdminSearchBundle
[Abandoned] Implement Search Engine (ElasticSearch) inside Sonata Admin
Stars: ✭ 19 (-64.15%)
Mutual labels:  bundle
BaseBundle
Base for your Symfony bundles.
Stars: ✭ 28 (-47.17%)
Mutual labels:  bundle
mpx-es-check
Checks the version of ES in JavaScript files with simple shell commands
Stars: ✭ 15 (-71.7%)
Mutual labels:  bundle
revgen
Speed up go:generate by auto detecting code changes
Stars: ✭ 20 (-62.26%)
Mutual labels:  codegen
LibBundle
Library and programs for bundle.bin in Content.ggpk of PathOfExile
Stars: ✭ 26 (-50.94%)
Mutual labels:  bundle
atbuild
Use JavaScript to generate JavaScript
Stars: ✭ 26 (-50.94%)
Mutual labels:  codegen
react-native-ci-tools
Change application bundle name and ID on the fly (build time) for both Android and IOS
Stars: ✭ 30 (-43.4%)
Mutual labels:  bundle
UmaSupporter.WebClient
🏃🏽‍♀️ 우마무스메 육성 도우미 '우마서포터'의 프론트엔드 애플리케이션입니다.
Stars: ✭ 14 (-73.58%)
Mutual labels:  codegen
ExpandedCollectionBundle
Symfony bundle for render entity collections as a selectable expanded list.
Stars: ✭ 13 (-75.47%)
Mutual labels:  bundle
LiipMultiplexBundle
[DEPRECATED] Symfony2 controller that allows calling multiple URL's in one request as well as JSON-ifying any controller
Stars: ✭ 12 (-77.36%)
Mutual labels:  bundle
go2dts
A simple cli-tools to transform golang `struct` and `const` to typescript `interface` and `type`
Stars: ✭ 44 (-16.98%)
Mutual labels:  codegen
AutoFormBundle
Automate Symfony form building
Stars: ✭ 68 (+28.3%)
Mutual labels:  bundle
VreshTwilioBundle
A Symfony2 wrapper for the official SDK provided by Twilio.
Stars: ✭ 45 (-15.09%)
Mutual labels:  bundle
ParamConverterBundle
This bundle provides additional param converters for Symfony.
Stars: ✭ 16 (-69.81%)
Mutual labels:  bundle
SonataTranslationBundle
SonataTranslationBundle
Stars: ✭ 72 (+35.85%)
Mutual labels:  bundle
genqlient
a truly type-safe Go GraphQL client
Stars: ✭ 532 (+903.77%)
Mutual labels:  codegen
bem-sdk
BEM SDK packages
Stars: ✭ 83 (+56.6%)
Mutual labels:  bundle

EasyBundler

EasyBundler is a library to simplify converting state objects into Bundles for Android applications. This repository is also a demonstration of simple annotation processing for Android libraries.

Download

In order to use EasyBundler you will need to add a compile dependency for the API as well as an annotationProcessor dependency for the compiler:

dependencies {
    compile 'pub.devrel.easybundler:easybundler-api:0.1.1'
    annotationProcessor 'pub.devrel.easybundler:easybundler-compiler:0.1.1'
}

Basic Usage

First, define a simple state class in your application and annotate it with @BundlerClass:

@BundlerClass
public class MyState {

    public String message;

    private int[] favoriteNumbers;

    public MyState() {}

    public int[] getFavoriteNumbers() {
        return favoriteNumbers;
    }

    public void setFavoriteNumbers(int[] favoriteNumbers) {
        this.favoriteNumbers = favoriteNumbers;
    }
}

There are a few important requirements for a state object to work with EasyBundler:

  • The class must have a public constructor with no arguments.
  • Any private fields that should be put into the bundle must have JavaBean-style getters and setters. So field foo must come with getFoo() and setFoo(). Any private fields that do not meet this requirement will be ignored.

At compile time, EasyBundler will generate code like this:

public final class MyStateBundler {
  public static Bundle toBundle(MyState object) {
    Bundle bundle = new Bundle();
    bundle.putString("KEY_pub.devrel.bundler.objects.MyState_message", object.message);
    bundle.putIntArray("KEY_pub.devrel.bundler.objects.MyState_favoriteNumbers", object.getFavoriteNumbers());
    return bundle;
  }

  public static MyState fromBundle(Bundle bundle) {
    MyState object = new MyState();
    object.message = (String) bundle.getString("KEY_pub.devrel.bundler.objects.MyState_message");
    object.setFavoriteNumbers((int[]) bundle.getIntArray("KEY_pub.devrel.bundler.objects.MyState_favoriteNumbers"));
    return object;
  }
}

You can use the Bundler class directly in your application, but it's even easier to use the helper methods provided by EasyBundler.

For example to serialize an object to Bundle, use the EasyBundler.toBundle(Object) method. And to turn that Bundle back into an object, use the EasyBundler.fromBundle(Bundle, Class) method. Both of these methods will fail if there is no generated Bundler class available.

If you are passing objects through Intents, you can use the EasyBundler.putExtra(Intent, Object) and EasyBundler.fromIntent(Intent, Class) methods to quickly add objects to and retrieve objects from an Intent.

FAQs

Is EasyBundler efficient?

EasyBundler does most of the heavy lifting at compile time to generate the Bundler classes, so bundling and unbundling objects should be very fast due to the limited use of reflection at runtime.

If you want to maximize efficiency by eliminating all reflection, use the Bundler classes directly rather than the EasyBundler helper methods (which have to do a Class lookup at runtime to find the Bundler classes).

Can I customize how EasyBundler serializes and deserializes?

Not yet! But if you have a use case that is blocked by the lack of customization please open an Issue so we can discuss it.

Does EasyBundler support inheritance?

No, the current version of EasyBundler only looks at properties of the annotated class, not its parent class(es).

Publishing

To install the library to your mavenLocal() repository, run:

./gradlew clean build :bundler-api:jarRelease publishToMavenLocal

To publish to Bintray, run:

./gradlew clean build test :bundler-api:jarRelease bintrayUpload
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].