Skip to content
Snippets Groups Projects
Commit be962ea4 authored by Dominique Marcadet's avatar Dominique Marcadet
Browse files

revert to full attribute use for hashCode() and equals()

default values should be present for missing values
parent 13c6c2e6
No related branches found
No related tags found
1 merge request!22Resolve "load .AppNS and .snsd files"
...@@ -30,7 +30,6 @@ public class NsIdentification { ...@@ -30,7 +30,6 @@ public class NsIdentification {
private Integer release; private Integer release;
public NsIdentification( String id, Integer version, String revision, Integer release ) { public NsIdentification( String id, Integer version, String revision, Integer release ) {
super();
this.id = id; this.id = id;
this.version = version; this.version = version;
this.revision = revision; this.revision = revision;
...@@ -38,17 +37,31 @@ public class NsIdentification { ...@@ -38,17 +37,31 @@ public class NsIdentification {
} }
public NsIdentification( AgNSIdentification identification ) { public NsIdentification( AgNSIdentification identification ) {
super();
this.id = identification.getId(); this.id = identification.getId();
this.version = identification.getVersion(); this.version = identification.getVersion();
this.revision = identification.getRevision(); this.revision = identification.getRevision();
this.release = identification.getRelease(); this.release = identification.getRelease();
} }
public String getId() {
return id;
}
public Integer getVersion() {
return version;
}
public String getRevision() {
return revision;
}
public Integer getRelease() {
return release;
}
@Override @Override
public int hashCode() { public int hashCode() {
// Only id and version are required, revision and release are optional return Objects.hash( id, release, revision, version );
return Objects.hash( id, version );
} }
@Override @Override
...@@ -57,15 +70,13 @@ public class NsIdentification { ...@@ -57,15 +70,13 @@ public class NsIdentification {
if( obj == null ) return false; if( obj == null ) return false;
if( getClass() != obj.getClass() ) return false; if( getClass() != obj.getClass() ) return false;
NsIdentification other = ( NsIdentification ) obj; NsIdentification other = ( NsIdentification ) obj;
return Objects.equals( id, other.id ) && Objects.equals( version, other.version ); return Objects.equals( id, other.id ) && Objects.equals( release, other.release )
&& Objects.equals( revision, other.revision ) && Objects.equals( version, other.version );
} }
@Override @Override
public String toString() { public String toString() {
return "NsIdentification [" + ( id != null ? "id=" + id + ", " : "" ) return "NsIdentification [id=" + id + ", version=" + version + ", revision=" + revision + ", release=" + release + "]";
+ ( version != null ? "version=" + version + ", " : "" )
+ ( revision != null ? "revision=" + revision + ", " : "" )
+ ( release != null ? "release=" + release : "" ) + "]";
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment