Use 'newInstance' as name for static factory methods

This commit is contained in:
cketti 2016-08-15 11:48:17 +02:00
parent 84cef1d8b1
commit 411ec0ec34
8 changed files with 16 additions and 16 deletions

View file

@ -20,7 +20,7 @@ public class MimeMultipart extends Multipart {
private final String boundary;
public static MimeMultipart createMimeMultipart() {
public static MimeMultipart newInstance() {
String boundary = BoundaryGenerator.getInstance().generateBoundary();
return new MimeMultipart(boundary);
}

View file

@ -986,7 +986,7 @@ class ImapFolder extends Folder<ImapMessage> {
/*
* This is a multipart/*
*/
MimeMultipart mp = MimeMultipart.createMimeMultipart();
MimeMultipart mp = MimeMultipart.newInstance();
for (int i = 0, count = bs.size(); i < count; i++) {
if (bs.get(i) instanceof ImapList) {
/*

View file

@ -717,11 +717,11 @@ public class MessageCompose extends K9Activity implements OnClickListener,
return null;
}
PgpMessageBuilder pgpBuilder = PgpMessageBuilder.createPgpMessageBuilder();
PgpMessageBuilder pgpBuilder = PgpMessageBuilder.newInstance();
recipientPresenter.builderSetProperties(pgpBuilder);
builder = pgpBuilder;
} else {
builder = SimpleMessageBuilder.createSimpleMessageBuilder();
builder = SimpleMessageBuilder.newInstance();
}
builder.setSubject(mSubjectView.getText().toString())

View file

@ -49,7 +49,7 @@ public class PgpMessageBuilder extends MessageBuilder {
private boolean opportunisticSecondPass;
public static PgpMessageBuilder createPgpMessageBuilder() {
public static PgpMessageBuilder newInstance() {
Context context = Globals.getContext();
MessageIdGenerator messageIdGenerator = MessageIdGenerator.getInstance();
BoundaryGenerator boundaryGenerator = BoundaryGenerator.getInstance();

View file

@ -14,7 +14,7 @@ import com.fsck.k9.mail.internet.MimeMessage;
public class SimpleMessageBuilder extends MessageBuilder {
public static SimpleMessageBuilder createSimpleMessageBuilder() {
public static SimpleMessageBuilder newInstance() {
Context context = Globals.getContext();
MessageIdGenerator messageIdGenerator = MessageIdGenerator.getInstance();
BoundaryGenerator boundaryGenerator = BoundaryGenerator.getInstance();

View file

@ -55,7 +55,7 @@ public class MessageDecryptVerifierTest {
@Test
public void findEncryptedPartsShouldReturnEmptyEncryptedPart() throws Exception {
MimeMessage message = new MimeMessage();
MimeMultipart multipartEncrypted = MimeMultipart.createMimeMultipart();
MimeMultipart multipartEncrypted = MimeMultipart.newInstance();
multipartEncrypted.setSubType("encrypted");
MimeMessageHelper.setBody(message, multipartEncrypted);
setContentTypeWithProtocol(message, MIME_TYPE_MULTIPART_ENCRYPTED, PROTCOL_PGP_ENCRYPTED);
@ -69,11 +69,11 @@ public class MessageDecryptVerifierTest {
@Test
public void findEncryptedPartsShouldReturnMultipleEncryptedParts() throws Exception {
MimeMessage message = new MimeMessage();
MimeMultipart multipartMixed = MimeMultipart.createMimeMultipart();
MimeMultipart multipartMixed = MimeMultipart.newInstance();
multipartMixed.setSubType("mixed");
MimeMessageHelper.setBody(message, multipartMixed);
MimeMultipart multipartEncryptedOne = MimeMultipart.createMimeMultipart();
MimeMultipart multipartEncryptedOne = MimeMultipart.newInstance();
multipartEncryptedOne.setSubType("encrypted");
MimeBodyPart bodyPartOne = new MimeBodyPart(multipartEncryptedOne);
setContentTypeWithProtocol(bodyPartOne, MIME_TYPE_MULTIPART_ENCRYPTED, PROTCOL_PGP_ENCRYPTED);
@ -82,7 +82,7 @@ public class MessageDecryptVerifierTest {
MimeBodyPart bodyPartTwo = new MimeBodyPart(null, "text/plain");
multipartMixed.addBodyPart(bodyPartTwo);
MimeMultipart multipartEncryptedThree = MimeMultipart.createMimeMultipart();
MimeMultipart multipartEncryptedThree = MimeMultipart.newInstance();
multipartEncryptedThree.setSubType("encrypted");
MimeBodyPart bodyPartThree = new MimeBodyPart(multipartEncryptedThree);
setContentTypeWithProtocol(bodyPartThree, MIME_TYPE_MULTIPART_ENCRYPTED, PROTCOL_PGP_ENCRYPTED);
@ -279,7 +279,7 @@ public class MessageDecryptVerifierTest {
}
MimeBodyPart multipart(String type, BodyPart... subParts) throws MessagingException {
MimeMultipart multiPart = MimeMultipart.createMimeMultipart();
MimeMultipart multiPart = MimeMultipart.newInstance();
multiPart.setSubType(type);
for (BodyPart subPart : subParts) {
multiPart.addBodyPart(subPart);

View file

@ -52,7 +52,7 @@ public class AttachmentResolverTest {
@Test
public void buildCidMap__onMultipartWithNoParts__shouldReturnEmptyMap() throws Exception {
Multipart multipartBody = MimeMultipart.createMimeMultipart();
Multipart multipartBody = MimeMultipart.newInstance();
Part multipartPart = new MimeBodyPart(multipartBody);
Map<String,Uri> result = AttachmentResolver.buildCidToAttachmentUriMap(attachmentInfoExtractor, multipartPart);
@ -62,7 +62,7 @@ public class AttachmentResolverTest {
@Test
public void buildCidMap__onMultipartWithEmptyBodyPart__shouldReturnEmptyMap() throws Exception {
Multipart multipartBody = MimeMultipart.createMimeMultipart();
Multipart multipartBody = MimeMultipart.newInstance();
BodyPart bodyPart = spy(new MimeBodyPart());
Part multipartPart = new MimeBodyPart(multipartBody);
multipartBody.addBodyPart(bodyPart);
@ -75,7 +75,7 @@ public class AttachmentResolverTest {
@Test
public void buildCidMap__onTwoPart__shouldReturnBothUris() throws Exception {
Multipart multipartBody = MimeMultipart.createMimeMultipart();
Multipart multipartBody = MimeMultipart.newInstance();
Part multipartPart = new MimeBodyPart(multipartBody);
BodyPart subPart1 = new MimeBodyPart();

View file

@ -151,7 +151,7 @@ public class MessageViewInfoExtractorTest {
TextBody body2 = new TextBody(bodyText2);
// Create multipart/mixed part
MimeMultipart multipart = MimeMultipart.createMimeMultipart();
MimeMultipart multipart = MimeMultipart.newInstance();
MimeBodyPart bodyPart1 = new MimeBodyPart(body1, "text/plain");
MimeBodyPart bodyPart2 = new MimeBodyPart(body2, "text/plain");
multipart.addBodyPart(bodyPart1);
@ -209,7 +209,7 @@ public class MessageViewInfoExtractorTest {
MimeMessageHelper.setBody(innerMessage, innerBody);
// Create multipart/mixed part
MimeMultipart multipart = MimeMultipart.createMimeMultipart();
MimeMultipart multipart = MimeMultipart.newInstance();
MimeBodyPart bodyPart1 = new MimeBodyPart(textBody, "text/plain");
MimeBodyPart bodyPart2 = new MimeBodyPart(innerMessage, "message/rfc822");
bodyPart2.setHeader("Content-Disposition", "inline; filename=\"message.eml\"");