Commits

Anonymous committed 3e0aa41

CHECKPOINT: Bringing things back to life after hiatus

Comments (0)

Files changed (8)

contacts-base/src/main/java/net/poalsoft/dossier/contacts/rendering/json/internal/JsonRenderingVisitorImpl.java

 
     @Override
     public JsonRenderingVisitorImpl reset() {
-        this.rendered
-                .set(new StringBuilder());
+        this.rendered.remove();
         return this;
     }
 

contacts-base/src/main/java/net/poalsoft/dossier/contacts/rendering/plaintext/internal/PlainTextRenderingVisitorImpl.java

 
     @Override
     public PlainTextRenderingVisitorImpl reset() {
-        this.rendered.set(new StringBuilder());
-        this.indentation.set(0);
+        this.rendered.remove();
+        this.indentation.remove();
+        this.separator.remove();
         return this;
     }
 

contacts-base/src/main/java/net/poalsoft/dossier/contacts/rendering/vcard/internal/VCardRenderingVisitorImpl.java

 public class VCardRenderingVisitorImpl extends AbstractVisitor implements VCardRenderingVisitor {
 
     public VCardRenderingVisitorImpl() {
-        this.vCardCollection = new ThreadLocal<Collection<VCard>>() {
-            @Override
-            protected Collection<VCard> initialValue() {
-                return new LinkedList<>();
-            }
-        };
-
-        this.vcardVersion = new ThreadLocal<VCardVersion>() {
-            @Override
-            protected VCardVersion initialValue() {
-                return VCardVersion.vCard4;
-            }
-        };
     }
 
     @Override
     public VCardRenderingVisitorImpl reset() {
-        this.vCardCollection
-                .set(new LinkedList<VCard>());
-        this.vcardVersion
-                .set(VCardVersion.vCard4);
+        this.vCardCollection.remove();
+        this.vcardVersion.remove();
         return this;
     }
 
 
     private static final Logger logger = LoggerFactory.getLogger(VCardRenderingVisitorImpl.class);
 
-    private final ThreadLocal<Collection<VCard>> vCardCollection;
+    private final ThreadLocal<Collection<VCard>> vCardCollection = new ThreadLocal<Collection<VCard>>() {
+                @Override
+                protected Collection<VCard> initialValue() {
+                    return new LinkedList<>();
+                }
+            };
 
-    private final ThreadLocal<VCardVersion> vcardVersion;
+    private final ThreadLocal<VCardVersion> vcardVersion = new ThreadLocal<VCardVersion>() {
+                @Override
+                protected VCardVersion initialValue() {
+                    return VCardVersion.vCard4;
+                }
+            };
 
     @Autowired
     private PersonVCardRenderer personVcardRenderer;

contacts-base/src/main/java/net/poalsoft/dossier/contacts/rendering/xml/internal/XmlRenderingVisitorImpl.java

 
     @Override
     public XmlRenderingVisitor reset() {
-        try {
-            final Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
-            final Element contacts = document.createElement("contacts");
-            document.appendChild(contacts);
-            this.rendered.set(document);
-        } catch (ParserConfigurationException e) {
-            throw new RuntimeException("Failed to create XML document", e);
-        }
+        this.rendered.remove();
         return this;
     }
 

contacts-tool/src/main/java/net/poalsoft/dossier/contacts/tool/internal/ExportContactsAsVCardImpl.java

     @Parameter(names = {"-v", "--version"},
                description = "Specifies the vCard version to use (vCard4, xCard, vCard3)",
                required = false,
-               converter = VcardStringConverter.class)
+               converter = VCardStringConverter.class)
     public void setVcardVersion(VCardVersion vcardVersion) {
         this.vcardVersion = vcardVersion;
     }

contacts-tool/src/main/java/net/poalsoft/dossier/contacts/tool/internal/ImportContactsFromVCardImpl.java

     @Parameter(names = {"-v", "--version"},
                description = "Specifies the vCard version to use (vCard4, xCard, vCard3)",
                required = false,
-               converter = VcardStringConverter.class)
+               converter = VCardStringConverter.class)
     public void setVcardVersion(VCardVersion vcardVersion) {
         this.vcardVersion = vcardVersion;
     }

contacts-tool/src/main/java/net/poalsoft/dossier/contacts/tool/internal/VcardStringConverter.java

  *
  * @author Kevin Poalses
  */
-public class VcardStringConverter extends BaseConverter<VCardVersion> implements IStringConverter<VCardVersion> {
+public class VCardStringConverter extends BaseConverter<VCardVersion> implements IStringConverter<VCardVersion> {
 
-    public VcardStringConverter(String optionName) {
+    public VCardStringConverter(String optionName) {
         super(optionName);
     }
 

ui/src/main/java/net/poalsoft/dossier/ui/view/internal/AbstractVisualEntityTableViewBuilder.java

                                                                          VisualEntityTableViewBuilder<VisualEntity> {
 
     public AbstractVisualEntityTableViewBuilder() {
-
-        this.tableViewBuilder = new ThreadLocal<TableViewBuilder<VisualEntity, ?>>() {
-            @Override
-            protected TableViewBuilder<VisualEntity, ?> initialValue() {
-                return TableViewBuilder.create();
-            }
-        };
-        this.defaultTableColumns = new
-                ThreadLocal<Collection<TableColumn<VisualEntity, ?>>>() {
-                    @Override
-                    protected Collection<TableColumn<VisualEntity, ?>> initialValue() {
-                        return new ArrayList<>(INITIAL_TABLE_COLUMNS_CAPACITY);
-                    }
-                };
-        this.extraTableColumns = new
-                ThreadLocal<Collection<TableColumn<VisualEntity, ?>>>() {
-                    @Override
-                    protected Collection<TableColumn<VisualEntity, ?>> initialValue() {
-                        return new ArrayList<>(INITIAL_TABLE_COLUMNS_CAPACITY);
-                    }
-                };
-
     }
 
     @Override
      */
     @Override
     public VisualEntityTableViewBuilder<VisualEntity> reset() {
-        this.tableViewBuilder
-                .set(TableViewBuilder.<VisualEntity>create());
-        this.defaultTableColumns
-                .set(new ArrayList<TableColumn<VisualEntity, ?>>(INITIAL_TABLE_COLUMNS_CAPACITY));
+        this.tableViewBuilder.remove();
+        this.defaultTableColumns.remove();
+        this.extraTableColumns.remove();
         return this;
     }
 
                 .add(tableColumn);
     }
 
-    private final ThreadLocal<Collection<TableColumn<VisualEntity, ?>>> defaultTableColumns;
+    private final ThreadLocal<Collection<TableColumn<VisualEntity, ?>>> defaultTableColumns = new
+                    ThreadLocal<Collection<TableColumn<VisualEntity, ?>>>() {
+                        @Override
+                        protected Collection<TableColumn<VisualEntity, ?>> initialValue() {
+                            return new ArrayList<>(INITIAL_TABLE_COLUMNS_CAPACITY);
+                        }
+                    };
 
-    private final ThreadLocal<Collection<TableColumn<VisualEntity, ?>>> extraTableColumns;
+    private final ThreadLocal<Collection<TableColumn<VisualEntity, ?>>> extraTableColumns = new
+                    ThreadLocal<Collection<TableColumn<VisualEntity, ?>>>() {
+                        @Override
+                        protected Collection<TableColumn<VisualEntity, ?>> initialValue() {
+                            return new ArrayList<>(INITIAL_TABLE_COLUMNS_CAPACITY);
+                        }
+                    };
 
-    private final ThreadLocal<TableViewBuilder<VisualEntity, ?>> tableViewBuilder;
+    private final ThreadLocal<TableViewBuilder<VisualEntity, ?>> tableViewBuilder = new ThreadLocal<TableViewBuilder<VisualEntity, ?>>() {
+                @Override
+                protected TableViewBuilder<VisualEntity, ?> initialValue() {
+                    return TableViewBuilder.create();
+                }
+            };
 
     private static final int INITIAL_TABLE_COLUMNS_CAPACITY = 20;
 }