Created
November 24, 2014 16:17
-
-
Save dkowis/c3a603537d101c04b779 to your computer and use it in GitHub Desktop.
This file contains 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
def parseDelegationValues(delegationValues: Seq[String]): Seq[HttpDelegationHeaderBean] = { | |
// TODO: Performance concerns | |
delegationValues.map(parseDelegationHeader).filter { | |
case Success(_) => | |
true | |
case Failure(e) => | |
LOG.warn("Failed to parse a delegation header: " + e.getMessage) | |
false | |
}.map(_.get) | |
//Using flatmap to auto-extract | |
delegationValues.map(parseDelegationHeader).flatMap { | |
case Success(bean) => Some(bean) | |
case Failure(e) => | |
LOG.warn("Failed to parse a delegation header: " + e.getMessage) | |
None | |
} | |
//Least amount of looping | |
delegationValues.flatMap { value => | |
parseDelegationHeader(value) match { | |
case Success(bean) => Some(bean) | |
case Failure(e) => | |
LOG.warn("Failed to parse a delegation header: " + e.getMessage) | |
None | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment