MAILBOX-321 More functional code for MessageParser::isTextPart
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/4189dda8 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/4189dda8 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/4189dda8 Branch: refs/heads/master Commit: 4189dda8eb9f7e340413b54e2d76ddfb77bff5d7 Parents: b292d37 Author: benwa <[email protected]> Authored: Tue Nov 28 10:31:34 2017 +0700 Committer: Antoine Duprat <[email protected]> Committed: Thu Nov 30 14:54:09 2017 +0100 ---------------------------------------------------------------------- .../mailbox/store/mail/model/impl/MessageParser.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/4189dda8/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java index c6b6b56..5494e29 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java @@ -205,14 +205,10 @@ public class MessageParser { } private boolean isTextPart(Entity part) { - Optional<ContentTypeField> contentTypeField = getContentTypeField(part); - if (contentTypeField.isPresent()) { - String mediaType = contentTypeField.get().getMediaType(); - if (mediaType != null && mediaType.equals(TEXT_MEDIA_TYPE)) { - return true; - } - } - return false; + return getContentTypeField(part) + .map(ContentTypeField::getMediaType) + .map(TEXT_MEDIA_TYPE::equals) + .orElse(false); } private byte[] getBytes(Body body) throws IOException { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
