Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wither and inheritance not work at all #740

Open
lombokissues opened this issue Jul 14, 2015 · 4 comments
Open

Wither and inheritance not work at all #740

lombokissues opened this issue Jul 14, 2015 · 4 comments

Comments

@lombokissues
Copy link

Migrated from Google Code (issue 705)

@lombokissues
Copy link
Author

👤 MAPADEP   🕗 Jul 15, 2014 at 20:02 UTC

Wither sould be inheritance compatible and pass that simple test.

@ Wither @ Getter
public class Foo {
    private int fooValue;

    public Foo(int fooValue) {
        this.fooValue = fooValue;
    }
}

@ Wither @ Getter
public class Bar extends Foo {
    private int barValue;

    public Bar(int fooValue, int barValue) {
        super(fooValue);
        this.barValue = barValue;
    }
}

@ Test
public void testWither() {
    final Bar bar = new Bar(3, 5);
    final Bar bar1 = bar.withBarValue(10);
    final Bar bar2 = bar.withFooValue(15);        

    assertThat(bar, instanceOf(Bar.class));
    assertThat(bar.getFooValue(), is(3));
    assertThat(bar.getBarValue(), is(5));

    assertThat(bar1, instanceOf(Bar.class));
    assertThat(bar1, is(not(bar)));
    assertThat(bar1.getFooValue(), is(3));
    assertThat(bar1.getBarValue(), is(10));

    assertThat(bar2, instanceOf(Bar.class));
    assertThat(bar2, is(not(bar)));
    assertThat(bar2.getFooValue(), is(15));
    assertThat(bar2.getBarValue(), is(5));
}

easiest way to implement - override with* methods in subclass and change return type.

@lombokissues
Copy link
Author

👤 MAPADEP   🕗 Jul 15, 2014 at 20:12 UTC

little correction to test:
instance check should be assertThat(bar1, not(sameInstance(bar))) instead
assertThat(bar1, is(not(bar)))
same for assertThat(bar2, is(not(bar)))

@lombokissues
Copy link
Author

👤 cesaryomismo   🕗 Apr 10, 2015 at 10:12 UTC

If we are using @ AllArgsConstructor inheritance doesn't work either...

@lombokissues
Copy link
Author

End of migration

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

No branches or pull requests

1 participant