Skip to content

Commit

Permalink
Clean up CodeWriter modifiers
Browse files Browse the repository at this point in the history
Makes it possible to override toString (something that is needed when
the CodeWriter is doing things like managing imports), and makes a
couple of methods final that should have already of been final.
  • Loading branch information
mtdowling committed Aug 27, 2019
1 parent 8ac7b3f commit fe4830a
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ public static String formatLiteral(Object value) {
* @param formatter Formatter function that formats the given object as a String.
* @return Returns the CodeWriter.
*/
public CodeWriter putFormatter(char identifier, BiFunction<Object, String, String> formatter) {
public final CodeWriter putFormatter(char identifier, BiFunction<Object, String, String> formatter) {
this.formatter.putFormatter(identifier, formatter);
return this;
}
Expand All @@ -430,7 +430,7 @@ public CodeWriter putFormatter(char identifier, BiFunction<Object, String, Strin
* @return Returns the generated code.
*/
@Override
public final String toString() {
public String toString() {
String result = currentState.toString();

// Trim excessive blank lines.
Expand Down Expand Up @@ -828,7 +828,7 @@ public final CodeWriter write(Object content, Object... args) {
* @param content Content to write if present.
* @return Returns the CodeWriter.
*/
public CodeWriter writeOptional(Object content) {
public final CodeWriter writeOptional(Object content) {
if (content == null) {
return this;
} else if (content instanceof Optional) {
Expand All @@ -846,7 +846,7 @@ public CodeWriter writeOptional(Object content) {
* @param task Method to invoke.
* @return Returns the CodeWriter.
*/
public CodeWriter call(Runnable task) {
public final CodeWriter call(Runnable task) {
task.run();
return this;
}
Expand Down Expand Up @@ -875,7 +875,7 @@ public CodeWriter putContext(String key, Object value) {
* @param mappings Key value pairs to add.
* @return Returns the CodeWriter.
*/
public CodeWriter putContext(Map<String, Object> mappings) {
public final CodeWriter putContext(Map<String, Object> mappings) {
mappings.forEach(currentState::putContext);
return this;
}
Expand Down

0 comments on commit fe4830a

Please sign in to comment.