From 08e9f5fb512e682b97aedf7fd1f1ae807afd7022 Mon Sep 17 00:00:00 2001 From: Rick Porter Date: Wed, 11 Nov 2026 06:08:47 -0500 Subject: [PATCH 1/4] Rename PrettyObject to DisplayBuilder --- README.md | 14 +++++++------- .../prettytable/example/pets/PetsCli.java | 4 ++-- .../rickwporter/prettytable/BuilderConfig.java | 2 +- .../{PrettyObject.java => DisplayBuilder.java} | 6 +++--- .../rickwporter/prettytable/OutputFormat.java | 2 +- ...ObjectTest.java => DisplayBuilderTest.java} | 18 +++++++++--------- 6 files changed, 23 insertions(+), 23 deletions(-) rename src/main/java/rickwporter/prettytable/{PrettyObject.java => DisplayBuilder.java} (96%) rename src/test/java/rickwporter/prettytable/{PrettyObjectTest.java => DisplayBuilderTest.java} (90%) diff --git a/README.md b/README.md index 59c8daa..a8275fe 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Here's an example of the standard **text** output: +------------+----------+------------+ ``` -The `PrettyTable` class handles a table as shown above. The `TableBuilder` class can be used to turn a `Map` or `List` object into a `PrettyTable`. `PrettyObject` also renders similar data types directly to a string with special handling for **json** and **yaml**. +The `PrettyTable` class handles a table as shown above. The `TableBuilder` class can be used to turn a `Map` or `List` object into a `PrettyTable`. `DisplayBuilder` also renders similar data types directly to a string with special handling for **json** and **yaml**. ## PrettyTable Usage Here are the basics for how to create a `PrettyTable` as shown above: @@ -411,13 +411,13 @@ import rickwporter.prettytable.BuilderConfig; | `setUrlPrefixes` | `http://`, `https://`, `ftp://` | | `setColumns` | `null` | -## PrettyObject Usage -`PrettyObject` renders a `Map` or a `List` to a string. The constructor takes an optional `BuilderConfig`. The output format and the data are passed to `render`. +## DisplayBuilder Usage +`DisplayBuilder` renders a `Map` or a `List` to a string. The constructor takes an optional `BuilderConfig`. The output format and the data are passed to `render`. -The `PrettyObject` adds some special handling for other data types, and **json** and **yaml** output formats. The **json** and **yaml** output formats render the object directly, while the other types build/render the data into a `PrettyTable` using the `TableBuilder` with provided configuration. +The `DisplayBuilder` adds some special handling for other data types, and **json** and **yaml** output formats. The **json** and **yaml** output formats render the object directly, while the other types build/render the data into a `PrettyTable` using the `TableBuilder` with provided configuration. ```Java -import rickwporter.prettytable.PrettyObject; +import rickwporter.prettytable.DisplayBuilder; import rickwporter.prettytable.OutputFormat; Map item = new LinkedHashMap(); @@ -426,7 +426,7 @@ import rickwporter.prettytable.OutputFormat; item.put("jkl", Arrays.asList("mno", "pqr", "stu")); item.put("yxa", null); - PrettyObject pretty = new PrettyObject(); + DisplayBuilder pretty = new DisplayBuilder(); System.out.println(pretty.render(OutputFormat.TEXT, item)); ``` @@ -461,7 +461,7 @@ A `BuilderConfig` changes the table formats. **json** and **yaml** keep the obje import rickwporter.prettytable.BuilderConfig; BuilderConfig config = new BuilderConfig().setPropertyLabel("Field"); - System.out.println(new PrettyObject(config).render(OutputFormat.RICH, item)); + System.out.println(new DisplayBuilder(config).render(OutputFormat.RICH, item)); ``` ## Example diff --git a/examples/pets-cli/src/main/java/rickwporter/prettytable/example/pets/PetsCli.java b/examples/pets-cli/src/main/java/rickwporter/prettytable/example/pets/PetsCli.java index ae18e91..305e854 100644 --- a/examples/pets-cli/src/main/java/rickwporter/prettytable/example/pets/PetsCli.java +++ b/examples/pets-cli/src/main/java/rickwporter/prettytable/example/pets/PetsCli.java @@ -20,7 +20,7 @@ import picocli.CommandLine.ParentCommand; import picocli.CommandLine.ScopeType; import picocli.CommandLine.Spec; -import rickwporter.prettytable.PrettyObject; +import rickwporter.prettytable.DisplayBuilder; import rickwporter.prettytable.OutputFormat; @Command( @@ -137,7 +137,7 @@ protected int usage(String message) { } private String render(Object body) { - PrettyObject pretty = new PrettyObject(); + DisplayBuilder pretty = new DisplayBuilder(); return pretty.render(this.parent.format, body); } diff --git a/src/main/java/rickwporter/prettytable/BuilderConfig.java b/src/main/java/rickwporter/prettytable/BuilderConfig.java index 50ced50..bcc3374 100644 --- a/src/main/java/rickwporter/prettytable/BuilderConfig.java +++ b/src/main/java/rickwporter/prettytable/BuilderConfig.java @@ -6,7 +6,7 @@ import java.util.Objects; /** - * Labels, truncation limits, and column selection for {@link TableBuilder} and {@link PrettyObject}. + * Labels, truncation limits, and column selection for {@link TableBuilder} and {@link DisplayBuilder}. * Each setter returns this config so calls can be chained. String setters reject {@code null}. * List setters store a copy of the given list. */ diff --git a/src/main/java/rickwporter/prettytable/PrettyObject.java b/src/main/java/rickwporter/prettytable/DisplayBuilder.java similarity index 96% rename from src/main/java/rickwporter/prettytable/PrettyObject.java rename to src/main/java/rickwporter/prettytable/DisplayBuilder.java index a2cfc6b..e4b06f0 100644 --- a/src/main/java/rickwporter/prettytable/PrettyObject.java +++ b/src/main/java/rickwporter/prettytable/DisplayBuilder.java @@ -14,14 +14,14 @@ * {@link String#valueOf(Object)}. JSON and YAML write the value with Jackson. Every other format * builds a {@link PrettyTable} from a {@link java.util.Map} or {@link java.util.List}. */ -public final class PrettyObject { +public final class DisplayBuilder { private static final String INDENT = " "; private BuilderConfig config; /** * Creates a renderer that uses {@link BuilderConfig} defaults. */ - public PrettyObject() { + public DisplayBuilder() { this(null); } @@ -32,7 +32,7 @@ public PrettyObject() { * * @param options labels, limits, and format settings, or {@code null} */ - public PrettyObject(BuilderConfig options) { + public DisplayBuilder(BuilderConfig options) { this.config = options == null ? new BuilderConfig() : options; } diff --git a/src/main/java/rickwporter/prettytable/OutputFormat.java b/src/main/java/rickwporter/prettytable/OutputFormat.java index a86b9fc..f6ead3a 100644 --- a/src/main/java/rickwporter/prettytable/OutputFormat.java +++ b/src/main/java/rickwporter/prettytable/OutputFormat.java @@ -1,7 +1,7 @@ package rickwporter.prettytable; /** - * Output produced by {@link PrettyTable} and {@link PrettyObject}. + * Output produced by {@link PrettyTable} and {@link DisplayBuilder}. */ public enum OutputFormat { /** ASCII rules and vertical bars. */ diff --git a/src/test/java/rickwporter/prettytable/PrettyObjectTest.java b/src/test/java/rickwporter/prettytable/DisplayBuilderTest.java similarity index 90% rename from src/test/java/rickwporter/prettytable/PrettyObjectTest.java rename to src/test/java/rickwporter/prettytable/DisplayBuilderTest.java index ef1fa24..401db5d 100644 --- a/src/test/java/rickwporter/prettytable/PrettyObjectTest.java +++ b/src/test/java/rickwporter/prettytable/DisplayBuilderTest.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; -public class PrettyObjectTest { +public class DisplayBuilderTest { private String loadFileContent(String filename) { URL resource = getClass().getClassLoader().getResource(filename); if (resource == null) { @@ -64,10 +64,10 @@ public void testSimpleDict() { extensions.put(OutputFormat.JSON, "json"); extensions.put(OutputFormat.YAML, "yaml"); - PrettyObject pretty = new PrettyObject(); + DisplayBuilder pretty = new DisplayBuilder(); Map data = this.simpleDict(); for (Map.Entry entry : extensions.entrySet()) { - String filename = "PrettyObject_simple_dict." + entry.getValue(); + String filename = "DisplayBuilder_simple_dict." + entry.getValue(); Assertions.assertEquals( this.loadFileContent(filename), pretty.render(entry.getKey(), data), @@ -77,7 +77,7 @@ public void testSimpleDict() { @Test public void testNullValue() { - PrettyObject uut = new PrettyObject(); + DisplayBuilder uut = new DisplayBuilder(); for (OutputFormat format : OutputFormat.values()) { Assertions.assertEquals("", uut.render(format, null)); @@ -86,7 +86,7 @@ public void testNullValue() { @Test public void testSimpleValues() { - PrettyObject uut = new PrettyObject(); + DisplayBuilder uut = new DisplayBuilder(); for (OutputFormat format : OutputFormat.values()) { Assertions.assertEquals("1", uut.render(format, 1)); @@ -100,8 +100,8 @@ public void testConfig() { Map data = this.simpleDict(); String label = "My label"; - PrettyObject config = new PrettyObject(new BuilderConfig().setPropertyLabel(label)); - PrettyObject unconfig = new PrettyObject(); + DisplayBuilder config = new DisplayBuilder(new BuilderConfig().setPropertyLabel(label)); + DisplayBuilder unconfig = new DisplayBuilder(); String labeled = config.render(OutputFormat.RICH, data); String unlabeled = unconfig.render(OutputFormat.RICH, data); @@ -117,7 +117,7 @@ public void testJsonProcessingException() throws JsonProcessingException { ObjectMapper mapper = mock(ObjectMapper.class); when(mapper.writeValueAsString(any())).thenThrow(failure); - PrettyObject uut = new PrettyObject(); + DisplayBuilder uut = new DisplayBuilder(); IllegalStateException ex = Assertions.assertThrows( IllegalStateException.class, () -> uut.renderJson(this.simpleDict(), mapper) @@ -132,7 +132,7 @@ public void testYamlProcessingException() throws JsonProcessingException { YAMLMapper mapper = mock(YAMLMapper.class); when(mapper.writeValueAsString(any())).thenThrow(failure); - PrettyObject uut = new PrettyObject(); + DisplayBuilder uut = new DisplayBuilder(); IllegalStateException ex = Assertions.assertThrows( IllegalStateException.class, () -> uut.renderYaml(this.simpleDict(), mapper) From 6353e2dad17fc5b617cae2ad917ec8f4f7748299 Mon Sep 17 00:00:00 2001 From: Rick Porter Date: Wed, 11 Nov 2026 06:13:39 -0500 Subject: [PATCH 2/4] Update example section of README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a8275fe..2d10229 100644 --- a/README.md +++ b/README.md @@ -466,7 +466,7 @@ import rickwporter.prettytable.BuilderConfig; ## Example -[`examples/pets-cli`](examples/pets-cli) is a [picocli](https://picocli.info/) client for the modified [OpenAPI Petstore](examples/pets.yaml). It prints JSON responses with `TableBuilder`. See the example README for how to build and run it. +[`examples/pets-cli`](examples/pets-cli) is a [picocli](https://picocli.info/) client for the modified [OpenAPI Petstore](examples/pets.yaml). It prints JSON responses with `DisplayBuilder`. See the example README for how to build and run it. ## Development From d70150584e211bf623992ecfb247aa396e7a03c7 Mon Sep 17 00:00:00 2001 From: Rick Porter Date: Wed, 11 Nov 2026 06:19:05 -0500 Subject: [PATCH 3/4] Update example README, too --- examples/pets-cli/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pets-cli/README.md b/examples/pets-cli/README.md index 70af142..f74f8f1 100644 --- a/examples/pets-cli/README.md +++ b/examples/pets-cli/README.md @@ -1,6 +1,6 @@ # pets -A [picocli](https://picocli.info/) command line client for the Swagger Petstore in [`pet.yaml`](pet.yaml). Responses are printed with `TableBuilder`. +A [picocli](https://picocli.info/) command line client for the Swagger Petstore in [`pet.yaml`](pet.yaml). Responses are printed with `DisplayBuilder`. The default server is `http://petstore.swagger.io/v1`. A flag on the command line wins over the environment variable. From 228e3f0f801deeefaab1582f13767ed6e1ec20da Mon Sep 17 00:00:00 2001 From: Rick Porter Date: Wed, 11 Nov 2026 06:23:03 -0500 Subject: [PATCH 4/4] Rename test resources, too --- ...rettyObject_simple_dict.csv => DisplayBuilder_simple_dict.csv} | 0 ...ttyObject_simple_dict.html => DisplayBuilder_simple_dict.html} | 0 ...ttyObject_simple_dict.json => DisplayBuilder_simple_dict.json} | 0 ...ttyObject_simple_dict.text => DisplayBuilder_simple_dict.text} | 0 ...rettyObject_simple_dict.txt => DisplayBuilder_simple_dict.txt} | 0 ...ttyObject_simple_dict.yaml => DisplayBuilder_simple_dict.yaml} | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename src/test/resources/{PrettyObject_simple_dict.csv => DisplayBuilder_simple_dict.csv} (100%) rename src/test/resources/{PrettyObject_simple_dict.html => DisplayBuilder_simple_dict.html} (100%) rename src/test/resources/{PrettyObject_simple_dict.json => DisplayBuilder_simple_dict.json} (100%) rename src/test/resources/{PrettyObject_simple_dict.text => DisplayBuilder_simple_dict.text} (100%) rename src/test/resources/{PrettyObject_simple_dict.txt => DisplayBuilder_simple_dict.txt} (100%) rename src/test/resources/{PrettyObject_simple_dict.yaml => DisplayBuilder_simple_dict.yaml} (100%) diff --git a/src/test/resources/PrettyObject_simple_dict.csv b/src/test/resources/DisplayBuilder_simple_dict.csv similarity index 100% rename from src/test/resources/PrettyObject_simple_dict.csv rename to src/test/resources/DisplayBuilder_simple_dict.csv diff --git a/src/test/resources/PrettyObject_simple_dict.html b/src/test/resources/DisplayBuilder_simple_dict.html similarity index 100% rename from src/test/resources/PrettyObject_simple_dict.html rename to src/test/resources/DisplayBuilder_simple_dict.html diff --git a/src/test/resources/PrettyObject_simple_dict.json b/src/test/resources/DisplayBuilder_simple_dict.json similarity index 100% rename from src/test/resources/PrettyObject_simple_dict.json rename to src/test/resources/DisplayBuilder_simple_dict.json diff --git a/src/test/resources/PrettyObject_simple_dict.text b/src/test/resources/DisplayBuilder_simple_dict.text similarity index 100% rename from src/test/resources/PrettyObject_simple_dict.text rename to src/test/resources/DisplayBuilder_simple_dict.text diff --git a/src/test/resources/PrettyObject_simple_dict.txt b/src/test/resources/DisplayBuilder_simple_dict.txt similarity index 100% rename from src/test/resources/PrettyObject_simple_dict.txt rename to src/test/resources/DisplayBuilder_simple_dict.txt diff --git a/src/test/resources/PrettyObject_simple_dict.yaml b/src/test/resources/DisplayBuilder_simple_dict.yaml similarity index 100% rename from src/test/resources/PrettyObject_simple_dict.yaml rename to src/test/resources/DisplayBuilder_simple_dict.yaml