com.cloudinary.transformation.AbstractLayer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cloudinary-core Show documentation
Show all versions of cloudinary-core Show documentation
Cloudinary is a cloud service that offers a solution to a web application's entire image management pipeline. Upload images to the cloud. Automatically perform smart image resizing, cropping and conversion without installing any complex software. Integrate Facebook or Twitter profile image extraction in a snap, in any dimension and style to match your websiteâs graphics requirements. Images are seamlessly delivered through a fast CDN, and much much more. This Java library allows to easily integrate with Cloudinary in Java applications.
The newest version!
package com.cloudinary.transformation;
import java.io.Serializable;
import java.util.ArrayList;
import com.cloudinary.utils.StringUtils;
public abstract class AbstractLayer> implements Serializable{
abstract T getThis();
protected String resourceType = null;
protected String type = null;
protected String publicId = null;
protected String format = null;
public T resourceType(String resourceType) {
this.resourceType = resourceType;
return getThis();
}
public T type(String type) {
this.type = type;
return getThis();
}
public T publicId(String publicId) {
this.publicId = publicId.replace('/', ':');
return getThis();
}
public T format(String format) {
this.format = format;
return getThis();
}
@Override
public String toString() {
ArrayList components = new ArrayList();
if (this.resourceType != null && !this.resourceType.equals("image")) {
components.add(this.resourceType);
}
if (this.type != null && !this.type.equals("upload")) {
components.add(this.type);
}
if (this.publicId == null) {
throw new IllegalArgumentException("Must supply publicId");
}
components.add(formattedPublicId());
return StringUtils.join(components, ":");
}
protected String formattedPublicId() {
String transientPublicId = this.publicId;
if (this.format != null) {
transientPublicId = transientPublicId + "." + this.format;
}
return transientPublicId;
}
}