Skip to content

Commit 1df8a7d

Browse files
author
Yegor Bugayenko
committed
#16 fixed
1 parent 274da08 commit 1df8a7d

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

src/main/java/com/jcabi/email/Envelope.java

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ public Message unwrap() {
9494
@EqualsAndHashCode(of = "encs")
9595
@Loggable(Loggable.DEBUG)
9696
final class MIME implements Envelope {
97-
/**
98-
* Original envelope.
99-
*/
100-
private final transient Envelope origin;
10197
/**
10298
* List of stamps.
10399
*/
@@ -111,43 +107,32 @@ final class MIME implements Envelope {
111107
* @since 1.3
112108
*/
113109
public MIME() {
114-
this(Envelope.EMPTY, new Array<Stamp>(), new Array<Enclosure>());
110+
this(new Array<Stamp>(), new Array<Enclosure>());
115111
}
116112
/**
117113
* Ctor.
118114
* @param env Original envelope
119115
* @since 1.5
120116
*/
121117
public MIME(final Envelope env) {
122-
this(env, new Array<Stamp>(), new Array<Enclosure>());
123-
}
124-
/**
125-
* Ctor.
126-
* @param stmps Stamps
127-
* @param list List of enclosures
128-
*/
129-
public MIME(final Iterable<Stamp> stmps,
130-
final Iterable<Enclosure> list) {
131118
this(
132-
Envelope.EMPTY, new Array<Stamp>(stmps),
133-
new Array<Enclosure>(list)
119+
Envelope.MIME.class.cast(env).stamps,
120+
Envelope.MIME.class.cast(env).encs
134121
);
135122
}
136123
/**
137124
* Ctor.
138-
* @param env Original envelope
139125
* @param stmps Stamps
140126
* @param list List of enclosures
141127
*/
142-
public MIME(final Envelope env, final Iterable<Stamp> stmps,
128+
public MIME(final Iterable<Stamp> stmps,
143129
final Iterable<Enclosure> list) {
144-
this.origin = env;
145130
this.stamps = new Array<Stamp>(stmps);
146131
this.encs = new Array<Enclosure>(list);
147132
}
148133
@Override
149134
public Message unwrap() throws IOException {
150-
final Message msg = this.origin.unwrap();
135+
final Message msg = Envelope.EMPTY.unwrap();
151136
final Multipart multi = new MimeMultipart("alternative");
152137
try {
153138
for (final Enclosure enc : this.encs) {
@@ -170,7 +155,6 @@ public Message unwrap() throws IOException {
170155
*/
171156
public Envelope.MIME with(final Stamp stamp) {
172157
return new Envelope.MIME(
173-
this.origin,
174158
this.stamps.with(stamp),
175159
this.encs
176160
);
@@ -183,7 +167,6 @@ public Envelope.MIME with(final Stamp stamp) {
183167
*/
184168
public Envelope.MIME with(final Enclosure enc) {
185169
return new Envelope.MIME(
186-
this.origin,
187170
this.stamps,
188171
this.encs.with(enc)
189172
);

src/test/java/com/jcabi/email/EnvelopeTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
* @author Yegor Bugayenko (yegor@teamed.io)
5050
* @version $Id$
5151
* @since 1.4
52+
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
5253
*/
5354
public final class EnvelopeTest {
5455

0 commit comments

Comments
 (0)