Skip to content

Commit

Permalink
add toString, hashCode and equals
Browse files Browse the repository at this point in the history
  • Loading branch information
pschichtel committed Mar 12, 2024
1 parent a1f1896 commit 10b1e83
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import tel.schich.javacan.platform.linux.LinuxNetworkDevice;

import java.time.Instant;
import java.util.Objects;

/**
* This class represents immutable message headers included with RAW messages, not suitable for native operations.
Expand Down Expand Up @@ -67,4 +68,27 @@ public Instant getHardwareTimestamp() {
public ImmutableRawReceiveMessageHeader copy() {
return this;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ImmutableRawReceiveMessageHeader that = (ImmutableRawReceiveMessageHeader) o;
return dropCount == that.dropCount && Objects.equals(device, that.device) && Objects.equals(softwareTimestamp, that.softwareTimestamp) && Objects.equals(hardwareTimestamp, that.hardwareTimestamp);
}

@Override
public int hashCode() {
return Objects.hash(device, dropCount, softwareTimestamp, hardwareTimestamp);
}

@Override
public String toString() {
return "ImmutableRawReceiveMessageHeader{" +
"device=" + device +
", dropCount=" + dropCount +
", softwareTimestamp=" + softwareTimestamp +
", hardwareTimestamp=" + hardwareTimestamp +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ public ImmutableRawReceiveMessageHeader copy() {
return new ImmutableRawReceiveMessageHeader(getDevice(), getDropCount(), getSoftwareTimestamp(), getHardwareTimestamp());
}

@Override
public String toString() {
return "ImmutableRawReceiveMessageHeader{" +
"device=" + getDevice() +
", dropCount=" + getDropCount() +
", softwareTimestamp=" + getSoftwareTimestamp() +
", hardwareTimestamp=" + getHardwareTimestamp() +
'}';
}
ByteBuffer getBuffer() {
return buffer;
}
Expand Down

0 comments on commit 10b1e83

Please sign in to comment.