Skip to content

Commit

Permalink
Argument checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
aldenml committed Jan 26, 2015
1 parent a20ce7f commit 44313a5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/com/frostwire/jlibtorrent/FileSliceTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,19 @@ public int getNumSlices() {
return slices.size();
}

public boolean isComplete(long offset) {
return Boolean.TRUE.equals(slices.get(offset).second);
public boolean isComplete(long offset) throws IllegalArgumentException {
Pair<FileSlice, Boolean> p = slices.get(offset);
if (p == null) {
throw new IllegalArgumentException("offset is not contained in the internal structure");
}
return Boolean.TRUE.equals(p.second);
}

public void setComplete(long offset, boolean complete) {
public void setComplete(long offset, boolean complete) throws IllegalArgumentException {
Pair<FileSlice, Boolean> p = slices.get(offset);
if (p == null) {
throw new IllegalArgumentException("offset is not contained in the internal structure");
}
slices.put(offset, new Pair<FileSlice, Boolean>(p.first, Boolean.valueOf(complete)));
}
}

0 comments on commit 44313a5

Please sign in to comment.