All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.paypal.api.payments.Image Maven / Gradle / Ivy

There is a newer version: 1.14.0
Show newest version
// Generated by delombok at Wed Oct 12 18:15:55 CDT 2016
package com.paypal.api.payments;

import com.paypal.base.rest.PayPalModel;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;

public class Image extends PayPalModel {
	/**
	 * Image as base64 encoded String
	 */
	private String image;

	/**
	 * Default Constructor
	 */
	public Image() {
	}

	/**
	 * Saves the image to a file.
	 *
	 * @param fileName filename ending with .png
	 * @return boolean true if write successful. false, otherwise.
	 * @throws IOException
	 */
	public boolean saveToFile(String fileName) throws IOException {
		byte[] imageBytes = javax.xml.bind.DatatypeConverter.parseBase64Binary(this.image);
		BufferedImage img = ImageIO.read(new ByteArrayInputStream(imageBytes));
		return ImageIO.write(img, "png", new File(fileName));
	}

	/**
	 * Image as base64 encoded String
	 */
	@java.lang.SuppressWarnings("all")
	public String getImage() {
		return this.image;
	}

	/**
	 * Image as base64 encoded String
	 * @return this
	 */
	@java.lang.SuppressWarnings("all")
	public Image setImage(final String image) {
		this.image = image;
		return this;
	}

	@java.lang.Override
	@java.lang.SuppressWarnings("all")
	public java.lang.String toString() {
		return "Image(image=" + this.getImage() + ")";
	}

	@java.lang.Override
	@java.lang.SuppressWarnings("all")
	public boolean equals(final java.lang.Object o) {
		if (o == this) return true;
		if (!(o instanceof Image)) return false;
		final Image other = (Image) o;
		if (!other.canEqual((java.lang.Object) this)) return false;
		if (!super.equals(o)) return false;
		final java.lang.Object this$image = this.getImage();
		final java.lang.Object other$image = other.getImage();
		if (this$image == null ? other$image != null : !this$image.equals(other$image)) return false;
		return true;
	}

	@java.lang.SuppressWarnings("all")
	protected boolean canEqual(final java.lang.Object other) {
		return other instanceof Image;
	}

	@java.lang.Override
	@java.lang.SuppressWarnings("all")
	public int hashCode() {
		final int PRIME = 59;
		int result = 1;
		result = result * PRIME + super.hashCode();
		final java.lang.Object $image = this.getImage();
		result = result * PRIME + ($image == null ? 43 : $image.hashCode());
		return result;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy