Comments (6)
Ah, I see. The problem is that Parceler is largely incompatible with the immutable bean (@Value
) of Lombok/Hrisey because of the following:
- Lombok/Hrisey changes the contained fields to private
- Lombok/Hrisey adds a constructor that isn't annotated with
@ParcelConstructor
- 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.
@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.
@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.
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.
Thanks for outlining the options.
Guess I'll ty hrisays Parcelable class, once the bug with JDK 1.8 64bit is fixed.
from parceler.
Please reopen if something else comes up.
from parceler.
Related Issues (20)
- Ability to treat reflection warnings as errors HOT 5
- Parceler fails when used with with Lifecycle-viewmodel 2.2.0 HOT 7
- Facing Vulnerabilities in parceler library HOT 1
- Facing Vulnerabilities in parceler library HOT 1
- Polymorphism documentation not updated? HOT 6
- Cannot get working with navigation graph HOT 1
- Crashing on background HOT 4
- ParcelAnnotationProcessor.process take lot amount of time. HOT 15
- Unable to find generated Parcelable class HOT 1
- error: Parceler: Code generation did not complete successfully. HOT 47
- Cant find class to parcel ! HOT 1
- Can't generate code HOT 3
- Unable to Marshall with Parceler HOT 2
- Errors in HashMap$$PackageHelper HOT 3
- cannot running with kapt HOT 1
- Parceler: Code generation did not complete successfully. org.parceler.transfuse.transaction.TransactionRuntimeException: Encountered ErrorType <error>, unable to recover HOT 4
- [Request Feature] Support for Kotlin Symbol Processing
- Parceler code generation fails on AS 2023.3.1
- Getters and Setter Alphabetically Order for Write and Read
- Not sure how to convert a Cursor
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parceler.