Skip to content

Commit

Permalink
Merge branch 'tags-set'
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesagnew committed Sep 30, 2014
2 parents 75c5123 + 24caec9 commit 3eeea9b
Show file tree
Hide file tree
Showing 15 changed files with 570 additions and 276 deletions.
6 changes: 6 additions & 0 deletions hapi-fhir-base/src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
</properties>
<body>
<release version="0.7" date="TBD">
<action type="add" issue="30">
<![CDATA[<b>API CHANGE:</b>]]> The TagList class previously implemented ArrayList semantics,
but this has been replaced with LinkedHashMap semantics. This means that the list of
tags will no longer accept duplicate tags, but that tag order will still be
preserved. Thanks to Bill de Beaubien for reporting!
</action>
<action type="add" dev="suranga">
Documentation fixes
</action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,20 @@ public class Bundle extends BaseBundle /* implements IElement */{
private IntegerDt myTotalResults;
private InstantDt myUpdated;

/**
* @deprecated Tags wil become immutable in a future release of HAPI, so {@link #addCategory(String, String, String)} should be used instead
*/
public Tag addCategory() {
Tag retVal = new Tag();
getCategories().add(retVal);
return retVal;
}

public void addCategory(String theScheme, String theTerm, String theLabel) {
getCategories().add(new Tag(theScheme, theTerm, theLabel));
}


public void addCategory(Tag theTag) {
getCategories().add(theTag);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,19 @@ public class BundleEntry extends BaseBundle {
private StringDt myTitle;
private InstantDt myUpdated;

/**
* @deprecated Tags wil become immutable in a future release of HAPI, so {@link #addCategory(String, String, String)} should be used instead
*/
public Tag addCategory() {
Tag retVal = new Tag();
getCategories().add(retVal);
return retVal;
}

public void addCategory(String theScheme, String theTerm, String theLabel) {
getCategories().add(new Tag(theScheme, theTerm, theLabel));
}

public void addCategory(Tag theTag) {
getCategories().add(theTag);
}
Expand Down
90 changes: 57 additions & 33 deletions hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,52 @@
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
* A single tag
* <p>
* Note on equality- When computing hashCode or equals values for this class, only the
* {@link #getScheme() scheme} and
* </p>
*/
public class Tag extends BaseElement implements IElement {

public static final String ATTR_LABEL = "label";
public static final String ATTR_SCHEME = "scheme";
public static final String ATTR_TERM = "term";

/**
* Convenience constant containing the "http://hl7.org/fhir/tag" scheme
* value
* Convenience constant containing the "http://hl7.org/fhir/tag" scheme value
*/
public static final String HL7_ORG_FHIR_TAG = "http://hl7.org/fhir/tag";

/**
* Convenience constant containing the "http://hl7.org/fhir/tag/security" scheme
* value
* Convenience constant containing the "http://hl7.org/fhir/tag/profile" scheme value
*/
public static final String HL7_ORG_SECURITY_TAG = "http://hl7.org/fhir/tag/security";

public static final String HL7_ORG_PROFILE_TAG = "http://hl7.org/fhir/tag/profile";
/**
* Convenience constant containing the "http://hl7.org/fhir/tag/profile" scheme
* value
* Convenience constant containing the "http://hl7.org/fhir/tag/security" scheme value
*/
public static final String HL7_ORG_PROFILE_TAG = "http://hl7.org/fhir/tag/profile";
public static final String HL7_ORG_SECURITY_TAG = "http://hl7.org/fhir/tag/security";

public static final String ATTR_TERM = "term";
public static final String ATTR_LABEL = "label";
public static final String ATTR_SCHEME = "scheme";

private String myLabel;
private String myScheme;
private String myTerm;

/**
* @deprecated Tags will become immutable in a future release, so this constructor should not be used.
*/
public Tag() {
}

/**
* @deprecated There is no reason to create a tag with a term and not a scheme, so this constructor will be removed
*/
public Tag(String theTerm) {
this((String)null, theTerm, null);
this((String) null, theTerm, null);
}

public Tag(String theScheme, String theTerm) {
myScheme = theScheme;
myTerm = theTerm;
}

public Tag(String theScheme, String theTerm, String theLabel) {
Expand All @@ -78,6 +92,19 @@ public Tag(URI theScheme, URI theTerm, String theLabel) {
myLabel = theLabel;
}


public String getLabel() {
return myLabel;
}

public String getScheme() {
return myScheme;
}

public String getTerm() {
return myTerm;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
Expand All @@ -87,11 +114,6 @@ public boolean equals(Object obj) {
if (getClass() != obj.getClass())
return false;
Tag other = (Tag) obj;
if (myLabel == null) {
if (other.myLabel != null)
return false;
} else if (!myLabel.equals(other.myLabel))
return false;
if (myScheme == null) {
if (other.myScheme != null)
return false;
Expand All @@ -105,23 +127,10 @@ public boolean equals(Object obj) {
return true;
}

public String getLabel() {
return myLabel;
}

public String getScheme() {
return myScheme;
}

public String getTerm() {
return myTerm;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((myLabel == null) ? 0 : myLabel.hashCode());
result = prime * result + ((myScheme == null) ? 0 : myScheme.hashCode());
result = prime * result + ((myTerm == null) ? 0 : myTerm.hashCode());
return result;
Expand All @@ -132,16 +141,31 @@ public boolean isEmpty() {
return StringUtils.isBlank(myLabel) && StringUtils.isBlank(myScheme) && StringUtils.isBlank(myTerm);
}

/**
* @deprecated Tags will become immutable in a future release of HAPI in order to facilitate
* ensuring that the TagList acts as an unordered set. Use the constructor to set this field when creating a new
* tag object
*/
public Tag setLabel(String theLabel) {
myLabel = theLabel;
return this;
}

/**
* @deprecated Tags will become immutable in a future release of HAPI in order to facilitate
* ensuring that the TagList acts as an unordered set. Use the constructor to set this field when creating a new
* tag object
*/
public Tag setScheme(String theScheme) {
myScheme = theScheme;
return this;
}

/**
* @deprecated Tags will become immutable in a future release of HAPI in order to facilitate
* ensuring that the TagList acts as an unordered set. Use the constructor to set this field when creating a new
* tag object
*/
public Tag setTerm(String theTerm) {
myTerm = theTerm;
return this;
Expand Down

0 comments on commit 3eeea9b

Please sign in to comment.