io.github.nichetoolkit.rest.image.ImageVerify Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rest-toolkit-utils Show documentation
Show all versions of rest-toolkit-utils Show documentation
Rest toolkit utils project for Spring Boot
The newest version!
package io.github.nichetoolkit.rest.image;
import io.github.nichetoolkit.rest.constant.UtilConstants;
import io.github.nichetoolkit.rest.util.GeneralUtils;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;
/**
* ImageVerify
* The image verify class.
* @author Cyan ([email protected])
* @see java.io.Serializable
* @see lombok.Getter
* @see lombok.Setter
* @see lombok.extern.slf4j.Slf4j
* @see java.lang.SuppressWarnings
* @since Jdk1.8
*/
@Getter
@Setter
@Slf4j
@SuppressWarnings("SameNameButDifferent")
public class ImageVerify implements Serializable {
/**
* content
* {@link java.lang.String} The content
field.
* @see java.lang.String
*/
private String content;
/**
* image
* {@link java.awt.image.BufferedImage} The image
field.
* @see java.awt.image.BufferedImage
*/
private BufferedImage image;
/**
* ImageVerify
* Instantiates a new image verify.
*/
public ImageVerify() {
}
/**
* ImageVerify
* Instantiates a new image verify.
* @param content {@link java.lang.String} The content parameter is String
type.
* @param image {@link java.awt.image.BufferedImage} The image parameter is BufferedImage
type.
* @see java.lang.String
* @see java.awt.image.BufferedImage
*/
public ImageVerify(String content, BufferedImage image) {
this.content = content;
this.image = image;
}
/**
* write
* The write method.
* @param outputStream {@link java.io.OutputStream} The output stream parameter is OutputStream
type.
* @see java.io.OutputStream
*/
public void write(OutputStream outputStream) {
write(UtilConstants.IMAGE_SUFFIX,outputStream);
}
/**
* write
* The write method.
* @param formatName {@link java.lang.String} The format name parameter is String
type.
* @param outputStream {@link java.io.OutputStream} The output stream parameter is OutputStream
type.
* @see java.lang.String
* @see java.io.OutputStream
*/
public void write(String formatName,OutputStream outputStream) {
try {
ImageIO.write(image, formatName, outputStream);
} catch (IOException exception) {
log.error("It is failed during image writing to output stream!", exception);
GeneralUtils.printStackTrace(exception);
}
}
}