package io.vertx.ext.web.multipart.impl;
import io.vertx.core.buffer.Buffer;
import io.vertx.ext.web.multipart.FormDataPart;
public class FormDataPartImpl implements FormDataPart {
private final String name;
private final String value;
private final String filename;
private final String mediaType;
private final String pathname;
private final Buffer content;
private final Boolean text;
public FormDataPartImpl(String name, String value) {
if (name == null) {
throw new NullPointerException();
}
if (value == null) {
throw new NullPointerException();
}
this.name = name;
this.value = value;
this.filename = null;
this.pathname = null;
this.content = null;
this.mediaType = null;
this.text = null;
}
public FormDataPartImpl(String name, String filename, String pathname, String mediaType, boolean text) {
if (name == null) {
throw new NullPointerException();
}
if (filename == null) {
throw new NullPointerException();
}
if (pathname == null) {
throw new NullPointerException();
}
if (mediaType == null) {
throw new NullPointerException();
}
this.name = name;
this.value = null;
this.filename = filename;
this.pathname = pathname;
this.content = null;
this.mediaType = mediaType;
this.text = text;
}
public FormDataPartImpl(String name, String filename, Buffer content, String mediaType, boolean text) {
if (name == null) {
throw new NullPointerException();
}
if (filename == null) {
throw new NullPointerException();
}
if (content == null) {
throw new NullPointerException();
}
if (mediaType == null) {
throw new NullPointerException();
}
this.name = name;
this.value = null;
this.filename = filename;
this.pathname = null;
this.content = content;
this.mediaType = mediaType;
this.text = text;
}
@Override
public String name() {
return name;
}
@Override
public boolean isAttribute() {
return value != null;
}
@Override
public boolean isFileUpload() {
return value == null;
}
@Override
public String value() {
return value;
}
@Override
public String filename() {
return filename;
}
@Override
public String pathname() {
return pathname;
}
@Override
public Buffer content() {
return content;
}
@Override
public String mediaType() {
return mediaType;
}
@Override
public Boolean isText() {
return text;
}
}