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

self() in parent is sufficient #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcusadrian
Copy link

No description provided.

@Piecewar
Copy link

No description provided.

when an abstract self() method is provided in parent
if you extends Builder in your subclass like this:
public static class Builder extends Pizza.Builder<Calzone.Builder> (wrong import or others)
other than
public static class Builder extends Pizza.Builder<Builder>
there will be a compile error when you implements self() method in subclass, then you will fix this error.

However, if self() method is not an abstract method in parent and use @SuppressWarnings on it,
you will find this problem until you try to create the object:

  1. you will get a compile error when
    NyPizza pizza = new NyPizza.Builder(SMALL).addToppings(SAUSAGE).build();
  2. or a ClassCastException occurs in runtime when
    Calzone calzone = new NyPizza.Builder(SMALL).addToppings(SAUSAGE).build();

but I'm not sure whether this example is right or not...

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

Successfully merging this pull request may close these issues.

2 participants