Skip to content

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