Skip to content

Commit

Permalink
Merge pull request #163 from itesla/temporary_limit_value
Browse files Browse the repository at this point in the history
Add convenient method to get temporary limit value
  • Loading branch information
mathbagu authored Nov 29, 2016
2 parents 4f12cba + ca40c12 commit 8bc7e5c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,12 @@ interface TemporaryLimit {
* @return the temporary limit
*/
TemporaryLimit getTemporaryLimit(int acceptableDuration);

/**
* Get a temporary limit value from its acceptable duration. Return NaN if there is non temporay limit with this
* acceptable duration.
* @param acceptableDuration acceptable duration in second
* @return the temporary limit value or NaN if there is no temporary limit for this acceptable duration
*/
float getTemporaryLimitValue(int acceptableDuration);
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,10 @@ public Collection<TemporaryLimit> getTemporaryLimits() {
public TemporaryLimit getTemporaryLimit(int acceptableDuration) {
return temporaryLimits.get(acceptableDuration);
}

@Override
public float getTemporaryLimitValue(int acceptableDuration) {
TemporaryLimit tl = getTemporaryLimit(acceptableDuration);
return tl != null ? tl.getValue() : Float.NaN;
}
}

0 comments on commit 8bc7e5c

Please sign in to comment.