Added some null checks so the users of this library don't have to
This commit is contained in:
parent
0d67701735
commit
702ac6cb82
@ -132,16 +132,26 @@ public class Message implements ExtendedEncoding.ExtendedType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Builder addParent(Plaintext parent) {
|
public Builder addParent(Plaintext parent) {
|
||||||
parents.add(parent.getInventoryVector());
|
if (parent != null) {
|
||||||
|
InventoryVector iv = parent.getInventoryVector();
|
||||||
|
if (iv == null) {
|
||||||
|
LOG.debug("Ignored parent without IV");
|
||||||
|
} else {
|
||||||
|
parents.add(iv);
|
||||||
|
}
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder addParent(InventoryVector iv) {
|
public Builder addParent(InventoryVector iv) {
|
||||||
|
if (iv != null) {
|
||||||
parents.add(iv);
|
parents.add(iv);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder addFile(File file, Attachment.Disposition disposition) {
|
public Builder addFile(File file, Attachment.Disposition disposition) {
|
||||||
|
if (file != null) {
|
||||||
try {
|
try {
|
||||||
files.add(new Attachment.Builder()
|
files.add(new Attachment.Builder()
|
||||||
.name(file.getName())
|
.name(file.getName())
|
||||||
@ -152,11 +162,14 @@ public class Message implements ExtendedEncoding.ExtendedType {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.error(e.getMessage(), e);
|
LOG.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder addFile(Attachment file) {
|
public Builder addFile(Attachment file) {
|
||||||
|
if (file != null) {
|
||||||
files.add(file);
|
files.add(file);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user