-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #435 from dickschoeller/368-369-376-codebeat
Fix codebeat issues
- Loading branch information
Showing
15 changed files
with
323 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...enderer/src/main/java/org/schoellerfamily/gedbrowser/renderer/PersonLifeSpanRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.schoellerfamily.gedbrowser.renderer; | ||
|
||
import org.schoellerfamily.gedbrowser.datamodel.Person; | ||
import org.schoellerfamily.gedbrowser.datamodel.visitor.GetDateVisitor; | ||
|
||
/** | ||
* @author Dick Schoeller | ||
*/ | ||
public interface PersonLifeSpanRenderer { | ||
/** | ||
* @return whether the current person is confidential. | ||
*/ | ||
boolean isConfidential(); | ||
|
||
/** | ||
* @return whether the current person is confidential. | ||
*/ | ||
boolean isHiddenLiving(); | ||
|
||
/** | ||
* @return the GedObject | ||
*/ | ||
Person getGedObject(); | ||
|
||
/** | ||
* @return lifespan string. | ||
*/ | ||
default String getLifeSpanString() { | ||
if (isConfidential() || isHiddenLiving()) { | ||
return ""; | ||
} | ||
|
||
return String.format("(%s-%s)", date("Birth"), date("Death")); | ||
} | ||
|
||
/** | ||
* @param type the event type to find a date for | ||
* @return the date string | ||
*/ | ||
default String date(final String type) { | ||
final GetDateVisitor birthVisitor = new GetDateVisitor(type); | ||
getGedObject().accept(birthVisitor); | ||
return birthVisitor.getDate(); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
...er-renderer/src/main/java/org/schoellerfamily/gedbrowser/renderer/PersonNameRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package org.schoellerfamily.gedbrowser.renderer; | ||
|
||
import org.schoellerfamily.gedbrowser.datamodel.GedObject; | ||
import org.schoellerfamily.gedbrowser.datamodel.Name; | ||
import org.schoellerfamily.gedbrowser.datamodel.Person; | ||
|
||
/** | ||
* @author Dick Schoeller | ||
*/ | ||
public interface PersonNameRenderer { | ||
/** | ||
* @return whether the current person is confidential. | ||
*/ | ||
boolean isConfidential(); | ||
|
||
/** | ||
* @return whether the current person is confidential. | ||
*/ | ||
boolean isHiddenLiving(); | ||
|
||
/** | ||
* @param attribute The sub-object to render. | ||
* @return The renderer. | ||
*/ | ||
GedRenderer<? extends GedObject> createGedRenderer(GedObject attribute); | ||
|
||
/** | ||
* @return the GedObject | ||
*/ | ||
Person getGedObject(); | ||
|
||
/** | ||
* @return the name string in title format. | ||
*/ | ||
default String getTitleName() { | ||
final Name name = getGedObject().getName(); | ||
if (isConfidential()) { | ||
return "Confidential"; | ||
} else if (isHiddenLiving()) { | ||
return "Living"; | ||
} else { | ||
final GedRenderer<?> nameRenderer = createGedRenderer(name); | ||
return nameRenderer.getNameHtml(); | ||
} | ||
} | ||
|
||
/** | ||
* @return Get the whole name without markup. | ||
*/ | ||
default String getWholeName() { | ||
if (isConfidential()) { | ||
return "Confidential"; | ||
} else if (isHiddenLiving()) { | ||
return "Living"; | ||
} | ||
final Name name = getGedObject().getName(); | ||
|
||
final String prefix = | ||
RenderingContextRenderer.escapeString(name.getPrefix()); | ||
final String surname = | ||
RenderingContextRenderer.escapeString(name.getSurname()); | ||
final String suffix = | ||
RenderingContextRenderer.escapeString(" ", name.getSuffix()); | ||
|
||
return String.format("%s %s%s", prefix, surname, suffix); | ||
} | ||
|
||
/** | ||
* @return surname if not confidential | ||
*/ | ||
default String getSurname() { | ||
if (isConfidential() || isHiddenLiving()) { | ||
return "?"; | ||
} else { | ||
return getGedObject().getSurname(); | ||
} | ||
} | ||
|
||
/** | ||
* @return surname first letter if not confidential | ||
*/ | ||
default String getSurnameLetter() { | ||
if (isConfidential() || isHiddenLiving()) { | ||
return "?"; | ||
} else { | ||
return getGedObject().getSurnameLetter(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.