Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Annotations in abstract classes confuse Mapper #88

Open
cgarciae opened this issue Mar 12, 2015 · 0 comments
Open

Annotations in abstract classes confuse Mapper #88

cgarciae opened this issue Mar 12, 2015 · 0 comments

Comments

@cgarciae
Copy link
Contributor

I have this hierarchy of classes (here simplified). Once Ref was a normal class but not its abstract, and as you see it has a @Field() annotation.

class Resp
{
    @Field() String error;
}

class DbObj extends Resp
{
    @Id() String id;
}

abstract class Ref extends DbObj
{
    @Field() String get href;
}

abstract class Vista extends Ref
{
    String get icon;
}

class NormalVista extends Ref implements Vista
{
    @Field() String get icon => "algo";
    @Field() String get href => "someHost/$id"; 
}

For some strange reason when encoding NormalVista I was getting href with the id included but not the id field itself in the JSON. It had to be there because href showed it, but the mapper wasn't including it.

The error is solved by removing the @Field() annotation from href in Ref, but its not obvious because in many cases it works, just that in this particular setup it doesn't.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant