Using code snippets from real sources to demonstrate the subclassing vs. delegation
1.1 --- a/samples/delegatingwriterfinal/src-api1.0/api/Writer.java Sat Jun 14 09:53:07 2008 +0200
1.2 +++ b/samples/delegatingwriterfinal/src-api1.0/api/Writer.java Sat Jun 14 09:53:07 2008 +0200
1.3 @@ -7,6 +7,7 @@
1.4 *
1.5 * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
1.6 */
1.7 +// BEGIN: writer.final.1.0
1.8 public final class Writer {
1.9 private final Impl impl;
1.10
1.11 @@ -72,7 +73,5 @@
1.12 public void write(String str, int off, int len) throws IOException;
1.13 public void write(char[] arr, int off, int len) throws IOException;
1.14 }
1.15 -
1.16 -
1.17 -
1.18 }
1.19 +// END: writer.final.1.0
2.1 --- a/samples/delegatingwriterfinal/src-api2.0/api/Writer.java Sat Jun 14 09:53:07 2008 +0200
2.2 +++ b/samples/delegatingwriterfinal/src-api2.0/api/Writer.java Sat Jun 14 09:53:07 2008 +0200
2.3 @@ -1,6 +1,5 @@
2.4 package api;
2.5
2.6 -import java.io.BufferedWriter;
2.7 import java.io.IOException;
2.8
2.9 /** Fixing the problem caused by mixing subclassing and delegation in
2.10 @@ -8,6 +7,7 @@
2.11 *
2.12 * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
2.13 */
2.14 +// BEGIN: writer.final.2.0
2.15 public final class Writer implements Appendable {
2.16 private final Impl impl;
2.17 private final ImplSeq seq;
2.18 @@ -130,7 +130,5 @@
2.19 public void flush() throws IOException;
2.20 public void write(CharSequence seq) throws IOException;
2.21 }
2.22 -
2.23 -
2.24 -
2.25 }
2.26 +// END: writer.final.2.0
2.27 \ No newline at end of file