Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. abstract class A {
  2. private T1 a;
  3. private T2 b;
  4. ...
  5.  
  6. // If A is not abstract then this one may be protected since it's complicated.
  7. A(T1 a, T2 b, ... /* all fields */) {
  8. this.a = a;
  9. this.b = b;
  10. ...
  11. }
  12.  
  13. A(T1 a, T2 b, ... /* some fields omitted */) {
  14. this(a, b, ... , /* x: */ null, /* y: */ null, /* z: */ null);
  15. // omitted fields' init
  16. this.x = new HashMap<>();
  17. this.y = new HashSet<>();
  18. this.z = new ArrayList<>();
  19. }
  20.  
  21. A(T1 a, T2 b, ... /* more fields omitted */) { ... }
  22.  
  23. ... // and so on.
  24.  
  25. /* this may be private when used in a static method(factory)
  26. or special public init. method for the client. */
  27. private A() { ... /* all by default */ }
  28. }
  29.  
  30. abstract class B extends A {
  31. ... // B's fields
  32.  
  33. // Again the most complicated one for subclasses/internal used.
  34. B(T1 a, T2 b, ..., T26 z, ... /* then B's fields */) {
  35. super(a, b, ... , z); //
  36. }
  37.  
  38. ... // More constructors by the same idea as class A
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement