Polishing contribution

Closes gh-25647
This commit is contained in:
Rossen Stoyanchev
2020-10-23 18:27:49 +01:00
parent 6e640c806f
commit a40cc8bbe0
2 changed files with 68 additions and 86 deletions

View File

@@ -48,18 +48,6 @@ public final class ContentDisposition {
private static final String INVALID_HEADER_FIELD_PARAMETER_FORMAT =
"Invalid header field parameter format (as defined in RFC 5987)";
/**
* The {@literal attachment} content-disposition type.
*/
private static final String ATTACHMENT = "attachment";
/**
* The {@literal form-data} content-disposition type.
*/
private static final String FORM_DATA = "form-data";
/**
* The {@literal inline} content-disposition type.
*/
private static final String INLINE = "inline";
@Nullable
private final String type;
@@ -105,8 +93,34 @@ public final class ContentDisposition {
/**
* Return the disposition type, like for example {@literal inline}, {@literal attachment},
* {@literal form-data}, or {@code null} if not defined.
* Return whether the {@link #getType() type} is {@literal "attachment"}.
* @since 5.3
*/
public boolean isAttachment() {
return (this.type != null && this.type.equalsIgnoreCase("attachment"));
}
/**
* Return whether the {@link #getType() type} is {@literal "form-data"}.
* @since 5.3
*/
public boolean isFormData() {
return (this.type != null && this.type.equalsIgnoreCase("form-data"));
}
/**
* Return whether the {@link #getType() type} is {@literal "inline"}.
* @since 5.3
*/
public boolean isInline() {
return (this.type != null && this.type.equalsIgnoreCase("inline"));
}
/**
* Return the disposition type.
* @see #isAttachment()
* @see #isFormData()
* @see #isInline()
*/
@Nullable
public String getType() {
@@ -186,30 +200,6 @@ public final class ContentDisposition {
return this.readDate;
}
/**
* Return whether the {@link #getType() type} is {@literal attachment}.
* @since 5.3
*/
public boolean isAttachment() {
return ATTACHMENT.equals(this.type);
}
/**
* Return whether the {@link #getType() type} is {@literal form-data}.
* @since 5.3
*/
public boolean isFormData() {
return FORM_DATA.equals(this.type);
}
/**
* Return whether the {@link #getType() type} is {@literal inline}.
* @since 5.3
*/
public boolean isInline() {
return INLINE.equals(this.type);
}
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
@@ -289,6 +279,30 @@ public final class ContentDisposition {
}
/**
* Return a builder for a {@code ContentDisposition} of type {@literal "attachment"}.
* @since 5.3
*/
public static Builder attachment() {
return builder("attachment");
}
/**
* Return a builder for a {@code ContentDisposition} of type {@literal "form-data"}.
* @since 5.3
*/
public static Builder formData() {
return builder("form-data");
}
/**
* Return a builder for a {@code ContentDisposition} of type {@literal "inline"}.
* @since 5.3
*/
public static Builder inline() {
return builder("inline");
}
/**
* Return a builder for a {@code ContentDisposition}.
* @param type the disposition type like for example {@literal inline},
@@ -299,36 +313,6 @@ public final class ContentDisposition {
return new BuilderImpl(type);
}
/**
* Return a builder for a {@code ContentDisposition} with
* the {@link #ATTACHMENT attachment} type.
* @return the builder
* @since 5.3
*/
public static Builder attachment() {
return builder(ATTACHMENT);
}
/**
* Return a builder for a {@code ContentDisposition} with
* the {@link #FORM_DATA form-data} type.
* @return the builder
* @since 5.3
*/
public static Builder formData() {
return builder(FORM_DATA);
}
/**
* Return a builder for a {@code ContentDisposition} with
* the {@link #INLINE inline} type.
* @return the builder
* @since 5.3
*/
public static Builder inline() {
return builder(INLINE);
}
/**
* Return an empty content disposition.
*/