Giter VIP home page Giter VIP logo

Comments (6)

johncarl81 avatar johncarl81 commented on May 16, 2024 1

Ah, I see. The problem is that Parceler is largely incompatible with the immutable bean (@Value) of Lombok/Hrisey because of the following:

  1. Lombok/Hrisey changes the contained fields to private
  2. Lombok/Hrisey adds a constructor that isn't annotated with @ParcelConstructor
  3. The technique Lombok/Hrisey uses to generate code introduces its getters after the fact... after Parceler runs.

Looking at Hrisey, it has an option for generating Parcelable classes, maybe that's a better option.
If you're looking for immutability, Parceler supports an immutable style, like the following:

@Parcel
class ImmutableExample{
    private final String value;
    @ParcelConstructor
    public ImmutableExample(String value){
        this.value = value;
    }
    //...
}

Alternatively you could use Google Autovalue:

@AutoValue
@Parcel
public abstract class AutoValueParcel {

    @ParcelProperty("value")
    public abstract String value();

    @ParcelFactory
    public static AutoValueParcel create(@ParcelProperty("value") String value) {
        return new AutoValueParcel_ExampleParcel(value);
    }
}

The only caveat with the above integration is instead of Parcels.wrap() you need to use the generated Parcelable directly: new AutoValueParcel$$Parcelable(autoValueParcel));

from parceler.

johncarl81 avatar johncarl81 commented on May 16, 2024

@Airblaster Can you share your Lombok/Hrisey bean? I tried it out and the following compiled and generated code just fine:

@Data
@Parcel
public class HriseyTest {
    String test;
}

Also, are you using version 0.2.10?

from parceler.

 avatar commented on May 16, 2024

@johncarl81 I've now reverted all files except for one. The code of this one file looks like this:

@Parcel
@Value
@AllArgsConstructor
@NoArgsConstructor
@RequiredArgsConstructor
public class Product {
    @NonNull String title;
    @NonNull String url;
    @NonNull double price;
    @NonNull String image;
    @NonNull String source;
    String color = "";
}

I'm using parceler version 0.2.11-SNAPSHOT
With this the error above is gone, but I get errors like this:

  symbol:   method getTitle()
  location: variable product of type Product
C:\ws\Presents\app\src\main\java\com\unitedinternet\presents\app\PresentsApp.java:74: error: cannot find symbol
        String urlString = product.getUrl();
                                  ^

This doesn't seem to be related to parceler, so I'll ask the developer of hrisey.

from parceler.

 avatar commented on May 16, 2024

I've changed a few things and now I get a different error:

C:\ws\Presents\app\src\main\java\com\unitedinternet\presents\app\domain\Product.java:17: error: Parceler: No @ParcelConstructor annotated constructor and no default empty bean constructor found.
public class Product {
       ^

Does this mean that parceler doesn't see the generated constructor?

from parceler.

 avatar commented on May 16, 2024

Thanks for outlining the options.
Guess I'll ty hrisays Parcelable class, once the bug with JDK 1.8 64bit is fixed.

from parceler.

johncarl81 avatar johncarl81 commented on May 16, 2024

Please reopen if something else comes up.

from parceler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.