Skip to content

Commit

Permalink
Merge pull request #15 from CodeDojoOfficial/master
Browse files Browse the repository at this point in the history
Update ColoredPrinter.java
  • Loading branch information
dialex committed Sep 11, 2018
2 parents 30b8ca7 + 9dba56d commit 74441b7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/main/java/com/diogonunes/jcdp/color/ColoredPrinter.java
Expand Up @@ -24,7 +24,7 @@
* @author Diogo Nunes
* @version 2.0
*/
public class ColoredPrinter implements IColoredPrinter {
public class ColoredPrinter implements IColoredPrinter, AutoCloseable {

// object with printer's implementation
private AbstractColoredPrinter _impl;
Expand Down Expand Up @@ -392,4 +392,19 @@ public void debugPrintln(Object msg, Attribute attr, FColor fg, BColor bg) {
public void debugPrintln(Object msg, int level, Attribute attr, FColor fg, BColor bg) {
getImpl().debugPrintln(msg, level, attr, fg, bg);
}
}

/**
* This method is called through the java.lang.AutoCloseable interface. It is called
* when the garbage collector of the JVM determines that this object no longer has any
* references being made to it. It is usually used for streams that must be closed in
* order to assure that the data has made it's way through the stream.
* <p>
* This method removes the need to call {@linkplain #clear()}. Do not call this method.
*
* @author CodeDojo
*/
@Override
public void close() {
getImpl().clear();
}
}

0 comments on commit 74441b7

Please sign in to comment.