Skip to content

Commit

Permalink
DocumentId.toIntOrThrow
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Jul 22, 2017
1 parent fee3b83 commit 7e6c58e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/de/metas/ui/web/window/datatypes/DocumentId.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,19 @@ public int toIntOr(final int fallbackValue)
{
return isInt() ? toInt() : fallbackValue;
}

public <X extends Throwable> int toIntOrThrow(@NonNull final Supplier<? extends X> exceptionSupplier) throws X
{
if(isInt())
{
return toInt();
}
else
{
throw exceptionSupplier.get();
}
}


private static final class IntDocumentId extends DocumentId
{
Expand Down

0 comments on commit 7e6c58e

Please sign in to comment.