Skip to content

Commit

Permalink
Fixes #161 - Deprecate 2 argument insert in Root
Browse files Browse the repository at this point in the history
The title aspect of change unifies the interface so that Root is
the same as all GedObjects as far as insert is concerned.

Together with this I eliminated the constructors in the data
model that only take a parent. Most of these were being used either:

* in places where a string was being added after construction
* or in being passed a null

Switched the null versions to using a default constructor. Switched
the instance where a string was being set immediately after to use
the version with a parent and a string.
  • Loading branch information
dickschoeller committed Feb 17, 2017
1 parent 22970e0 commit 6c4ca08
Show file tree
Hide file tree
Showing 83 changed files with 504 additions and 717 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
*/
public abstract class AbstractSource extends GedObject {
/**
* @param parent parent object of this attribute
* Default constructor.
*/
public AbstractSource(final GedObject parent) {
super(parent);
public AbstractSource() {
super();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
* @author Dick Schoeller
*/
public abstract class AbstractSpecialObject extends GedObject {
/**
* Default constructor.
*/
public AbstractSpecialObject() {
super();
}

/**
* @param parent parent object of this attribute
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,24 @@
*/
public final class FamC extends AbstractLink {
/**
* @param parent
* parent object of this link
* Default constructor.
*/
public FamC(final GedObject parent) {
super(parent);
public FamC() {
super();
}

/**
* @param parent
* parent object of this link
* @param string
* long version of type string
* @param parent parent object of this link
* @param string long version of type string
*/
public FamC(final GedObject parent, final String string) {
super(parent, string);
}

/**
* @param parent
* person that is a child in the referred family
* @param string
* long version of type string
* @param xref
* the reference to a family object
* @param parent person that is a child in the referred family
* @param string long version of type string
* @param xref the reference to a family object
*/
public FamC(final GedObject parent, final String string,
final ObjectId xref) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*/
public final class FamS extends AbstractLink implements FamilyLinkage {
/**
* @param parent parent object of this link
* Default constructor.
*/
public FamS(final GedObject parent) {
super(parent);
public FamS() {
super();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ public Family() {
super();
}

/**
* @param parent parent object of this family
*/
public Family(final GedObject parent) {
super(parent);
}

/**
* @param parent parent object of this family
* @param xref cross reference to this family
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,26 +348,38 @@ public final GedObject find(final String str) {
}

/**
* @return the filename associated with this data set.
* @return the filename associated with this data set
*/
public final String getFilename() {
return finder.getFilename(this);
}

/**
* @return the filename associated with this data set.
* @return the filename associated with this data set
*/
public final String getDbName() {
return finder.getDbName(this);
}

/**
* @param gob object to insert.
* @param gob object to insert
*/
public final void insert(final GedObject gob) {
if (gob == null) {
return;
}
extraInsert(gob);
finder.insert(this, gob);
}

/**
* @param gob object to insert
*/
public void extraInsert(final GedObject gob) {
// The default implementation is empty. Some derived
// classes implement this.
}

/**
* Set the strategy that implements finding.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
*/
public final class Head extends AbstractSpecialObject {
/**
* @param parent parent object of this object
* Default constructor.
*/
public Head(final GedObject parent) {
super(parent);
public Head() {
super();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ public Husband() {
super();
}

/**
* @param parent parent object of this husband
*/
public Husband(final GedObject parent) {
super(parent);
}

/**
* @param parent parent object of this husband
* @param string long version of type string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ public final class Multimedia extends AbstractAttribute {
private String tail;

/**
* @param parent
* parent object of this attribute
* Default constructor.
*/
public Multimedia(final GedObject parent) {
super(parent);
public Multimedia() {
super();
this.tail = "";
this.setAppender(new MultimediaAppender(this));
}

/**
* @param parent
* parent object of this attribute
* @param string
* long version of type string
* @param parent parent object of this attribute
* @param string long version of type string
*/
public Multimedia(final GedObject parent, final String string) {
super(parent, string);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ public Person() {
super();
}

/**
* @param parent parent object of this person
*/
public Person(final GedObject parent) {
super(parent);
}

/**
* @param parent parent object of this person
* @param xref cross reference to this person
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
public final class Place extends AbstractAttribute
implements Comparable<Place> {
/**
* @param parent parent object of this child
* Default constructor.
*/
public Place(final GedObject parent) {
super(parent);
public Place() {
super();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,67 +27,43 @@ public final class Root extends AbstractSpecialObject {
private final transient Index surnameIndex;

/**
* @param parent
* parent object of this child
* Default constructor.
*/
public Root(final GedObject parent) {
super(parent);
surnameIndex = new Index(this);
setFinder(new RootFinder());
public Root() {
this(new RootFinder());
}

/**
* @param parent parent object of this child
* @param string long version of type string
* @param finder the engine for find objects in this data set
*/
public Root(final GedObject parent, final String string,
final FinderStrategy finder) {
super(parent, string);
surnameIndex = new Index(this);
setFinder(finder);
public Root(final String string, final FinderStrategy finder) {
this(finder);
setString(string);
}

/**
* @param parent parent object of this child
* @param finder the engine for finding objects in the data set
*/
public Root(final GedObject parent, final FinderStrategy finder) {
super(parent);
public Root(final FinderStrategy finder) {
super();
surnameIndex = new Index(this);
setFinder(finder);
}

/**
* @param parent
* parent object of this child
* @param string
* long version of type string
* @param string long version of type string
*/
public Root(final GedObject parent, final String string) {
super(parent, string);
surnameIndex = new Index(this);
setFinder(new RootFinder());
public Root(final String string) {
this(string, new RootFinder());
}

/**
* @param str ID string of object to insert
* @param gob object to insert
*/
public void insert(final String str, final GedObject gob) {
if (gob == null) {
// I don't think this should happen. We would only get
// here is the factory for a level 0 tag didn't return
// anything. Even then, I think that that insert would
// have been cut off by gob being NULL.
return;
}

if (str == null || str.isEmpty()) {
objects.put(gob.getString(), gob);
} else {
objects.put(str, gob);
}
@Override
public void extraInsert(final GedObject gob) {
objects.put(gob.getString(), gob);
addAttribute(gob);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public GedObject find(final GedObject owner, final String str) {
@Override
public void insert(final GedObject owner, final GedObject gob) {
final Root root = (Root) owner;
root.insert(gob.getString(), gob);
root.extraInsert(gob);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
*/
public final class Source extends AbstractSource {
/**
* @param parent parent object of this source
* Default constructor.
*/
public Source(final GedObject parent) {
super(parent);
public Source() {
super();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
*/
public final class SourceLink extends AbstractLink {
/**
* @param parent parent object of this link
* Default constructor.
*/
public SourceLink(final GedObject parent) {
super(parent);
public SourceLink() {
super();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
*/
public final class Submittor extends AbstractSource implements Nameable {
/**
* @param parent parent object of this submittor
* Default constructor.
*/
public Submittor(final GedObject parent) {
super(parent);
public Submittor() {
super();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
*/
public final class SubmittorLink extends AbstractLink {
/**
* @param parent parent object of this link
* Default constructor.
*/
public SubmittorLink(final GedObject parent) {
super(parent);
public SubmittorLink() {
super();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
*/
public final class Trailer extends AbstractSpecialObject {
/**
* @param parent parent object of this object
* Default constructor.
*/
public Trailer(final GedObject parent) {
super(parent);
public Trailer() {
super();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ public Wife() {
super();
}

/**
* @param parent parent object of this wife
*/
public Wife(final GedObject parent) {
super(parent);
}

/**
* @param parent parent object of this wife
* @param string long version of type string
Expand Down

0 comments on commit 6c4ca08

Please sign in to comment.