Java tutorial
/* * Copyright 2005-2013 shopxx.net. All rights reserved. * Support: http://www.xmsoft.cn * License: http://www.xmsoft.cn/license */ package net.shopxx.entity; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Embeddable; import javax.persistence.Transient; import javax.validation.constraints.Min; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.CompareToBuilder; import org.hibernate.validator.constraints.Length; import org.springframework.web.multipart.MultipartFile; /** * Entity - ? * * @author SHOP++ Team * @version 3.0 */ @Embeddable public class ProductImage implements Serializable, Comparable<ProductImage> { private static final long serialVersionUID = -673883300094536107L; /** */ private String title; /** */ private String source; /** */ private String large; /** */ private String medium; /** */ private String thumbnail; /** ? */ private Integer order; /** */ private MultipartFile file; /** * ? * * @return */ @Length(max = 200) public String getTitle() { return title; } /** * * * @param title * */ public void setTitle(String title) { this.title = title; } /** * ? * * @return */ public String getSource() { return source; } /** * * * @param source * */ public void setSource(String source) { this.source = source; } /** * ? * * @return */ public String getLarge() { return large; } /** * * * @param large * */ public void setLarge(String large) { this.large = large; } /** * ? * * @return */ public String getMedium() { return medium; } /** * * * @param medium * */ public void setMedium(String medium) { this.medium = medium; } /** * ? * * @return */ public String getThumbnail() { return thumbnail; } /** * * * @param thumbnail * */ public void setThumbnail(String thumbnail) { this.thumbnail = thumbnail; } /** * ?? * * @return ? */ @Min(0) @Column(name = "orders") public Integer getOrder() { return order; } /** * ? * * @param order * ? */ public void setOrder(Integer order) { this.order = order; } /** * ? * * @return */ @Transient public MultipartFile getFile() { return file; } /** * * * @param file * */ public void setFile(MultipartFile file) { this.file = file; } /** * ? * * @return ? */ @Transient public boolean isEmpty() { return (getFile() == null || getFile().isEmpty()) && (StringUtils.isEmpty(getSource()) || StringUtils.isEmpty(getLarge()) || StringUtils.isEmpty(getMedium()) || StringUtils.isEmpty(getThumbnail())); } /** * compareTo * * @param productImage * ? * @return */ public int compareTo(ProductImage productImage) { return new CompareToBuilder().append(getOrder(), productImage.getOrder()).toComparison(); } }