Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Avoid NPE in SwapQueue when selecting empty seat
Browse files Browse the repository at this point in the history
  • Loading branch information
yurloc committed Jun 28, 2015
1 parent 087b038 commit af4ddfd
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/main/java/org/iypt/planner/gui/swap/IdleSwap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.iypt.planner.gui.swap;

import java.util.Objects;
import org.iypt.planner.domain.Juror;

public class IdleSwap implements SwapArgument {
Expand All @@ -24,4 +25,26 @@ public void apply(Juror other) {
public boolean isTarget() {
return false;
}

@Override
public int hashCode() {
int hash = 7;
hash = 29 * hash + Objects.hashCode(this.juror);
return hash;
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final IdleSwap other = (IdleSwap) obj;
if (!Objects.equals(this.juror, other.juror)) {
return false;
}
return true;
}
}
23 changes: 23 additions & 0 deletions src/main/java/org/iypt/planner/gui/swap/SeatSwap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.iypt.planner.gui.swap;

import java.util.Objects;
import org.iypt.planner.domain.Juror;
import org.iypt.planner.gui.SeatInfo;

Expand All @@ -25,4 +26,26 @@ public void apply(Juror other) {
public boolean isTarget() {
return true;
}

@Override
public int hashCode() {
int hash = 3;
hash = 47 * hash + Objects.hashCode(this.seat);
return hash;
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final SeatSwap other = (SeatSwap) obj;
if (!Objects.equals(this.seat, other.seat)) {
return false;
}
return true;
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/iypt/planner/gui/swap/SwapQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class SwapQueue {
public void add(SwapArgument arg) {
if (source == null) {
source = arg;
} else if (!source.getJuror().equals(arg.getJuror())) {
} else if (!source.equals(arg)) {
target = source;
source = arg;
}
Expand Down

0 comments on commit af4ddfd

Please sign in to comment.