Last active
December 24, 2015 16:39
-
-
Save jlandahl/6829934 to your computer and use it in GitHub Desktop.
Code reduction with Option
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// candidate.mimeType and candidate.uri are both Options | |
candidate.mimeType.exists(_.equalsIgnoreCase(MimeTypes.PDF)) || | |
candidate.uri.exists(_.getPath.toLowerCase.endsWith(FileExtensions.PDF)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val mimeTypeIsPdf = candidate.mimeType match { | |
case None => false | |
case Some(candidateMimeType) => candidateMimeType.equalsIgnoreCase(MimeTypes.PDF) | |
} | |
val urlHasPdfExtension = candidate.uri match { | |
case None => true | |
LowerCase().endsWith(FileExtensions.PDF) | |
} | |
mimeTypeIsPdf || urlHasPdfExtension |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment