1
package org.hisp.dhis.importexport.analysis;
4
* Copyright (c) 2004-2007, University of Oslo
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
* * Redistributions of source code must retain the above copyright notice, this
10
* list of conditions and the following disclaimer.
11
* * Redistributions in binary form must reproduce the above copyright notice,
12
* this list of conditions and the following disclaimer in the documentation
13
* and/or other materials provided with the distribution.
14
* * Neither the name of the HISP project nor the names of its contributors may
15
* be used to endorse or promote products derived from this software without
16
* specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
* @author Lars Helge Overland
34
public class EntityPropertyValue
35
implements Comparable<EntityPropertyValue>
37
private String entity;
39
private String property;
43
// -------------------------------------------------------------------------
45
// -------------------------------------------------------------------------
47
public EntityPropertyValue( Class<?> entity, String property, String value )
49
this.entity = entity.getSimpleName();
50
this.property = property;
54
// -------------------------------------------------------------------------
55
// Getters and setters
56
// -------------------------------------------------------------------------
58
public String getEntity()
63
public void setEntity( String entity )
68
public String getProperty()
73
public void setProperty( String property )
75
this.property = property;
78
public String getValue()
83
public void setValue( String value )
88
// -------------------------------------------------------------------------
89
// hashCode, equals, toString, compareTo
90
// -------------------------------------------------------------------------
99
result = prime * result + ( ( entity == null ) ? 0 : entity.hashCode() );
100
result = prime * result + ( ( property == null ) ? 0 : property.hashCode() );
101
result = prime * result + ( ( value == null ) ? 0 : value.hashCode() );
107
public boolean equals( Object object )
109
if ( this == object )
114
if ( object == null )
119
if ( getClass() != object.getClass() )
124
final EntityPropertyValue other = (EntityPropertyValue) object;
126
if ( entity == null )
128
if ( other.entity != null )
133
else if ( !entity.equals( other.entity ) )
138
if ( property == null )
140
if ( other.property != null )
145
else if ( !property.equals( other.property ) )
152
if ( other.value != null )
157
else if ( !value.equals( other.value ) )
166
public String toString()
168
return "[" + entity + ", " + property + ", " + value + "]";
171
public int compareTo( EntityPropertyValue other )
178
int compare1 = compareTo( entity, other.entity );
179
int compare2 = compareTo( property, other.property );
180
int compare3 = compareTo( value, other.value );
182
return ( compare1 != 0 ) ? compare1 : ( compare2 != 0 ) ? compare2 : compare3;
185
private int compareTo( String string1, String string2 )
187
if ( string1 == null && string2 == null )
192
if ( string1 == null )
197
if ( string2 == null )
202
return string1.compareTo( string2 );