View Javadoc
1   package ca.uhn.fhir.model.api;
2   
3   import org.apache.commons.lang3.builder.ToStringBuilder;
4   
5   /*
6    * #%L
7    * HAPI FHIR - Core Library
8    * %%
9    * Copyright (C) 2014 University Health Network
10   * %%
11   * Licensed under the Apache License, Version 2.0 (the "License");
12   * you may not use this file except in compliance with the License.
13   * You may obtain a copy of the License at
14   * 
15   *      http://www.apache.org/licenses/LICENSE-2.0
16   * 
17   * Unless required by applicable law or agreed to in writing, software
18   * distributed under the License is distributed on an "AS IS" BASIS,
19   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20   * See the License for the specific language governing permissions and
21   * limitations under the License.
22   * #L%
23   */
24  
25  /**
26   * Represents a FHIR resource path specification, e.g.
27   * <code>Patient.gender.coding</code>
28   * <p>
29   * Note on equality: This class uses the {@link Include#setValue(String) value} 
30   * as the single item used to provide {@link #hashCode()} and {@link #equals(Object)}.
31   * </p>
32   */
33  public class Include {
34  
35  	private String myValue;
36  
37  	public Include(String theValue) {
38  		myValue = theValue;
39  	}
40  
41  	@Override
42  	public boolean equals(Object obj) {
43  		if (this == obj)
44  			return true;
45  		if (obj == null)
46  			return false;
47  		if ((obj instanceof Include)==false)
48  			return false;
49  		Include other = (Include) obj;
50  		if (myValue == null) {
51  			if (other.myValue != null)
52  				return false;
53  		} else if (!myValue.equals(other.myValue))
54  			return false;
55  		return true;
56  	}
57  
58  	public String getValue() {
59  		return myValue;
60  	}
61  
62  	@Override
63  	public int hashCode() {
64  		final int prime = 31;
65  		int result = 1;
66  		result = prime * result + ((myValue == null) ? 0 : myValue.hashCode());
67  		return result;
68  	}
69  
70  	public void setValue(String theValue) {
71  		myValue = theValue;
72  	}
73  
74  	@Override
75  	public String toString() {
76  		ToStringBuilder builder = new ToStringBuilder(this);
77  		builder.append("myValue", myValue);
78  		return builder.toString();
79  	}
80  	
81  }