Created
February 3, 2018 04:21
-
-
Save bangarharshit/c4ec0bee365cc4ef30270f10d4d1aa2f to your computer and use it in GitHub Desktop.
The current generated code (only the POJO part and removed adapter for brevity):
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
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.List; | |
import javax.annotation.Nonnull; | |
import javax.annotation.Nullable; | |
public class EmailDummy { | |
@Nonnull | |
public final String From; | |
@Nullable | |
public final List<String> To; | |
@Nullable | |
public final List<String> CC; | |
@Nullable | |
public final List<String> BCC; | |
@Nullable | |
public final String Subject; | |
@Nullable | |
public final String Body; | |
private EmailDummy(Builder builder) { | |
this.From = builder.From; | |
this.To = builder.To == null ? null : Collections.unmodifiableList(builder.To); | |
this.CC = builder.CC == null ? null : Collections.unmodifiableList(builder.CC); | |
this.BCC = builder.BCC == null ? null : Collections.unmodifiableList(builder.BCC); | |
this.Subject = builder.Subject; | |
this.Body = builder.Body; | |
} | |
@Override | |
@SuppressWarnings("StringEquality") | |
public boolean equals(Object other) { | |
if (this == other) return true; | |
if (other == null) return false; | |
if (!(other instanceof EmailDummy)) return false; | |
EmailDummy that = (EmailDummy) other; | |
return (this.From == that.From || this.From.equals(that.From)) | |
&& (this.To == that.To || (this.To != null && this.To.equals(that.To))) | |
&& (this.CC == that.CC || (this.CC != null && this.CC.equals(that.CC))) | |
&& (this.BCC == that.BCC || (this.BCC != null && this.BCC.equals(that.BCC))) | |
&& (this.Subject == that.Subject || (this.Subject != null && this.Subject.equals(that.Subject))) | |
&& (this.Body == that.Body || (this.Body != null && this.Body.equals(that.Body))); | |
} | |
@Override | |
public int hashCode() { | |
int code = 16777619; | |
code ^= this.From.hashCode(); | |
code *= 0x811c9dc5; | |
code ^= (this.To == null) ? 0 : this.To.hashCode(); | |
code *= 0x811c9dc5; | |
code ^= (this.CC == null) ? 0 : this.CC.hashCode(); | |
code *= 0x811c9dc5; | |
code ^= (this.BCC == null) ? 0 : this.BCC.hashCode(); | |
code *= 0x811c9dc5; | |
code ^= (this.Subject == null) ? 0 : this.Subject.hashCode(); | |
code *= 0x811c9dc5; | |
code ^= (this.Body == null) ? 0 : this.Body.hashCode(); | |
code *= 0x811c9dc5; | |
return code; | |
} | |
@Override | |
public String toString() { | |
return "Email{From=" + this.From + ", To=" + this.To + ", CC=" + this.CC + ", BCC=" + this.BCC + ", Subject=" + this.Subject + ", Body=" + this.Body + ", Attachments=" + "}"; | |
} | |
public static final class Builder { | |
private String From; | |
private List<String> To; | |
private List<String> CC; | |
private List<String> BCC; | |
private String Subject; | |
private String Body; | |
public Builder() { | |
} | |
public Builder(EmailDummy struct) { | |
this.From = struct.From; | |
this.To = struct.To; | |
this.CC = struct.CC; | |
this.BCC = struct.BCC; | |
this.Subject = struct.Subject; | |
this.Body = struct.Body; | |
} | |
public Builder From(String From) { | |
if (From == null) { | |
throw new NullPointerException("Required field 'From' cannot be null"); | |
} | |
this.From = From; | |
return this; | |
} | |
public Builder To(List<String> To) { | |
this.To = To; | |
return this; | |
} | |
public Builder CC(List<String> CC) { | |
this.CC = CC; | |
return this; | |
} | |
public Builder BCC(List<String> BCC) { | |
this.BCC = BCC; | |
return this; | |
} | |
public Builder Subject(String Subject) { | |
this.Subject = Subject; | |
return this; | |
} | |
public Builder Body(String Body) { | |
this.Body = Body; | |
return this; | |
} | |
public Builder Attachments(List<Attachment> Attachments) { | |
if (Attachments == null) { | |
throw new NullPointerException("Required field 'Attachments' cannot be null"); | |
} | |
return this; | |
} | |
public EmailDummy build() { | |
if (this.From == null) { | |
throw new IllegalStateException("Required field 'From' is missing"); | |
} | |
return new EmailDummy(this); | |
} | |
public void reset() { | |
this.From = null; | |
this.To = null; | |
this.CC = null; | |
this.BCC = null; | |
this.Subject = null; | |
this.Body = null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment