Separate commonly used DepositionTypeCheck into methods
Closes gh-34573 Signed-off-by: ChanHyeongLee <cksgud410@gmail.com> [brian.clozel@broadcom.com: apply code conventions] Signed-off-by: Brian Clozel <brian.clozel@broadcom.com>
This commit is contained in:
committed by
Brian Clozel
parent
de75b6e1a2
commit
8ee09e5766
@@ -99,7 +99,7 @@ public final class ContentDisposition {
|
|||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
public boolean isAttachment() {
|
public boolean isAttachment() {
|
||||||
return (this.type != null && this.type.equalsIgnoreCase("attachment"));
|
return isDispositionType("attachment");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,7 +107,7 @@ public final class ContentDisposition {
|
|||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
public boolean isFormData() {
|
public boolean isFormData() {
|
||||||
return (this.type != null && this.type.equalsIgnoreCase("form-data"));
|
return isDispositionType("form-data");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,7 +115,11 @@ public final class ContentDisposition {
|
|||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
public boolean isInline() {
|
public boolean isInline() {
|
||||||
return (this.type != null && this.type.equalsIgnoreCase("inline"));
|
return isDispositionType("inline");
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isDispositionType(String type) {
|
||||||
|
return this.type != null && this.type.equalsIgnoreCase(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -556,6 +560,7 @@ public final class ContentDisposition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mutable builder for {@code ContentDisposition}.
|
* A mutable builder for {@code ContentDisposition}.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -310,4 +310,28 @@ class ContentDispositionTests {
|
|||||||
.isEqualTo(filename);
|
.isEqualTo(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void attachmentType(){
|
||||||
|
ContentDisposition attachment = ContentDisposition.attachment().build();
|
||||||
|
assertThat(attachment.isAttachment()).isTrue();
|
||||||
|
assertThat(attachment.isFormData()).isFalse();
|
||||||
|
assertThat(attachment.isInline()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void formDataType(){
|
||||||
|
ContentDisposition formData = ContentDisposition.formData().build();
|
||||||
|
assertThat(formData.isAttachment()).isFalse();
|
||||||
|
assertThat(formData.isFormData()).isTrue();
|
||||||
|
assertThat(formData.isInline()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void inlineType(){
|
||||||
|
ContentDisposition inline = ContentDisposition.inline().build();
|
||||||
|
assertThat(inline.isAttachment()).isFalse();
|
||||||
|
assertThat(inline.isFormData()).isFalse();
|
||||||
|
assertThat(inline.isInline()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user