Skip to content

Commit

Permalink
Fixed Arrays.equals check, and cleaned a few minor bugs from FindBugs…
Browse files Browse the repository at this point in the history
… [25881733]
  • Loading branch information
SQUIDwarrior committed Apr 11, 2012
1 parent b144880 commit 0690c0c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/main/java/edu/cmu/sv/arinc838/dao/FileDefinitionDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ public boolean equals(Object obj) {

public boolean equals(FileDefinitionDao obj){
return obj != null &&
this == obj ||
(this == obj ||
(this.getFileIntegrityDefinition().equals(obj.getFileIntegrityDefinition()) &&
((this.isFileLoadable() && obj.isFileLoadable() || (!this.isFileLoadable() && !obj.isFileLoadable()))) &&
this.getFileName().equals(obj.getFileName()) &&
(this.getFileSize() == obj.getFileSize()));
(this.getFileSize() == obj.getFileSize())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public byte[] getIntegrityValue() {
@Override
public int hashCode() {
if (this.getIntegrityValue() != null) {
return this.getIntegrityValue().hashCode();
return Arrays.hashCode(this.getIntegrityValue());
}

return 0;
Expand All @@ -102,9 +102,9 @@ public boolean equals(Object obj) {

public boolean equals(IntegrityDefinitionDao obj) {
return obj != null
&& this == obj
&& (this == obj
|| (Arrays.equals(this.getIntegrityValue(),
obj.getIntegrityValue()) && (this.getIntegrityType() == obj
.getIntegrityType()));
.getIntegrityType())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.arinc.arinc838.FileDefinition;
Expand Down Expand Up @@ -172,13 +173,13 @@ public boolean equals(Object obj) {

public boolean equals(SoftwareDefinitionFileDao obj) {
return obj != null
&& this == obj
&& (this == obj
|| (this.getSoftwareDescription().equals(obj.getSoftwareDescription())
&& this.getFileFormatVersion().equals(obj.getFileFormatVersion())
&& Arrays.equals(this.getFileFormatVersion(), obj.getFileFormatVersion())
&& this.getTargetHardwareDefinitions().equals(obj.getTargetHardwareDefinitions())
&& this.getFileDefinitions().equals(obj.getFileDefinitions())
&& this.getSdfIntegrityDefinition().equals(obj.getSdfIntegrityDefinition()) && this
.getLspIntegrityDefinition().equals(obj.getLspIntegrityDefinition()));
.getLspIntegrityDefinition().equals(obj.getLspIntegrityDefinition())));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNull;

import java.util.Arrays;

import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

Expand Down Expand Up @@ -91,7 +93,7 @@ public void testIntegrityTypeEnumFromLong()
@Test
public void testHashCode(){
IntegrityDefinitionDao integDao = new IntegrityDefinitionDao(integDef);
assertEquals(integDao.hashCode(), integDao.getIntegrityValue().hashCode());
assertEquals(integDao.hashCode(), Arrays.hashCode(integDao.getIntegrityValue()));
}

@Test
Expand Down

0 comments on commit 0690c0c

Please sign in to comment.