Java tutorial
/* * Copyright 2014 guilin. All rights reserved. * Support: guilin * License: guilin */ package gov.guilin; import java.io.Serializable; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; /** * ? * * @author guilin * @version */ public class Order implements Serializable { private static final long serialVersionUID = -3078342809727773232L; /** * ? */ public enum Direction { /** */ asc, /** ? */ desc; /** * String?Direction * * @param value * * @return StringDirection */ public static Direction fromString(String value) { return Direction.valueOf(value.toLowerCase()); } } /** ? */ private static final Direction DEFAULT_DIRECTION = Direction.desc; /** */ private String property; /** ? */ private Direction direction = DEFAULT_DIRECTION; /** * ?Order */ public Order() { } /** * @param property * * @param direction * ? */ public Order(String property, Direction direction) { this.property = property; this.direction = direction; } /** * ? * * @param property * * @return ? */ public static Order asc(String property) { return new Order(property, Direction.asc); } /** * ?? * * @param property * * @return ?? */ public static Order desc(String property) { return new Order(property, Direction.desc); } /** * ? * * @return */ public String getProperty() { return property; } /** * * * @param property * */ public void setProperty(String property) { this.property = property; } /** * ?? * * @return ? */ public Direction getDirection() { return direction; } /** * ? * * @param direction * ? */ public void setDirection(Direction direction) { this.direction = direction; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } if (this == obj) { return true; } Order other = (Order) obj; return new EqualsBuilder().append(getProperty(), other.getProperty()) .append(getDirection(), other.getDirection()).isEquals(); } @Override public int hashCode() { return new HashCodeBuilder(17, 37).append(getProperty()).append(getDirection()).toHashCode(); } }