Skip to content
This repository has been archived by the owner on Jun 11, 2023. It is now read-only.

Commit

Permalink
#54 [cleanup] Rewrite the 'toString()' method from FXMLModel, -View.
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoghuman committed Mar 6, 2019
1 parent 5ba749a commit 3be0d7a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
2 changes: 2 additions & 0 deletions release/Release_v0.3.0-PRERELEASE_2019-03-dd_HH-mm.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ and connect them to a controller (called the presenter).


#### Refactoring
#54 [cleanup] Rewrite the 'toString()' method from FXMLModel, -View.
#51 [cleanup] Rename the class FXMLPresenter to FXMLController.
#46 [cleanup] Rewrite the 'create(...)' methods in FXMLView.
#44 [cleanup] Rename 'data' in FXMLModel.
Expand All @@ -50,6 +51,7 @@ Naoghuman


[//]: # (Issues which will be integrated in this release)
#42 [test] Rename the demo applications to fit the necessities from the api.



Expand Down
35 changes: 33 additions & 2 deletions src/main/java/com/github/naoghuman/lib/fxml/core/FXMLModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.github.naoghuman.lib.fxml.internal.DefaultFXMLValidator;
import com.github.naoghuman.lib.logger.core.LoggerFacade;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Optional;

/**
Expand Down Expand Up @@ -118,9 +120,38 @@ public void put(final String key, final Object value) {
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("FXMLModel [").append("\n"); // NOI18N
sb.append("FXMLModel [\n"); // NOI18N

sb.append(" model: ").append(model.toString()).append("\n"); // NOI18N
final Iterator<Map.Entry<String, Object>> iterator = model.entrySet().iterator();
if (!iterator.hasNext()) {
sb.append(" <no-entries-defined>"); // NOI18N
}

int maxLength = 0;
for(final String key : model.keySet()) {
maxLength = Math.max(maxLength, key.length());
}

final int elements = model.size();
int counter = 0;
while (iterator.hasNext()) {
final Map.Entry<String, Object> next = iterator.next();
final String key = next.getKey();
final Object value = next.getValue();

sb.append(" "); // NOI18N
sb.append(String.format("%-" + maxLength + "s", key)); // NOI18N
sb.append(" = "); // NOI18N
sb.append(value);

++counter;
if (counter < elements) {
sb.append(",\n"); // NOI18N
}
else {
sb.append("\n"); // NOI18N
}
}

sb.append("]"); // NOI18N

Expand Down
19 changes: 9 additions & 10 deletions src/main/java/com/github/naoghuman/lib/fxml/core/FXMLView.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,10 @@ private void initializeResourceBundle(final Class<? extends FXMLController> cont
try {
resourceBundle = Optional.ofNullable(ResourceBundle.getBundle(baseBundleName));
} catch (MissingResourceException ex) {
LoggerFacade.getDefault().warn(this.getClass(),
LoggerFacade.getDefault().debug(this.getClass(),
String.format(
"Can't found a ResourceBundle with the specified 'base' name: %s", // NOI18N
baseBundleName),
ex);
baseBundleName));
}
}

Expand Down Expand Up @@ -255,14 +254,14 @@ public URL getURLforFXML() {
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("FXMLView [").append("\n"); // NOI18N
sb.append("FXMLView [\n"); // NOI18N

sb.append(" controller : ").append(this.getController().getClass().getName()).append("\n"); // NOI18N
sb.append(" conventionalName: ").append(this.getConventionalName() ).append("\n"); // NOI18N
sb.append(" baseBundleName : ").append(this.getBaseBundleName() ).append("\n"); // NOI18N
sb.append(" urlForFXML : ").append(this.getURLforFXML() != null ? this.getURLforFXML().toString() : "<NOT-DEFINED>").append("\n"); // NOI18N
sb.append(" urlForCSS : ").append(this.getURLforCSS().isPresent() ? this.getURLforCSS().get().toString() : "<NOT-DEFINED>").append("\n"); // NOI18N
sb.append(" root : ").append(this.getRoot().isPresent() ? this.getRoot().get().toString() : "<NOT-DEFINED>").append("\n"); // NOI18N
sb.append(" controller = ").append(this.getController().getClass().getName()).append(",\n"); // NOI18N
sb.append(" conventionalName = ").append(this.getConventionalName() ).append(",\n"); // NOI18N
sb.append(" baseBundleName = ").append(this.getBaseBundleName() ).append(",\n"); // NOI18N
sb.append(" urlForFXML = ").append(this.getURLforFXML() != null ? this.getURLforFXML().toString() : "<not-defined>").append(",\n"); // NOI18N
sb.append(" urlForCSS = ").append(this.getURLforCSS().isPresent() ? this.getURLforCSS().get().toString() : "<not-defined>").append(",\n"); // NOI18N
sb.append(" root = ").append(this.getRoot().isPresent() ? this.getRoot().get().toString() : "<not-defined>").append("\n"); // NOI18N

sb.append("]"); // NOI18N

Expand Down

0 comments on commit 3be0d7a

Please sign in to comment.