com.qccr.livtrip.web.util.Order.java Source code

Java tutorial

Introduction

Here is the source code for com.qccr.livtrip.web.util.Order.java

Source

/*
 * Copyright 2005-2015 shopxx.net. All rights reserved.
 * Support: http://www.shopxx.net
 * License: http://www.shopxx.net/license
 */
package com.qccr.livtrip.web.util;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.io.Serializable;

/**
 * ?
 * 
 * @author SHOP++ Team
 * @version 4.0
 */
public class Order implements Serializable {

    private static final long serialVersionUID = -3078342809727773232L;

    /**
     * ?
     */
    public enum Direction {

        /**  */
        asc,

        /** ? */
        desc
    }

    /** ? */
    private static final Order.Direction DEFAULT_DIRECTION = Order.Direction.desc;

    /**  */
    private String property;

    /** ? */
    private Order.Direction direction = DEFAULT_DIRECTION;

    public Order() {
    }

    /**
     * @param property
     *            
     * @param direction
     *            ?
     */
    public Order(String property, Order.Direction direction) {
        this.property = property;
        this.direction = direction;
    }

    /**
     * ?
     *
     * @param property
     *            
     * @return ?
     */
    public static Order asc(String property) {
        return new Order(property, Order.Direction.asc);
    }

    /**
     * ??
     *
     * @param property
     *            
     * @return ??
     */
    public static Order desc(String property) {
        return new Order(property, Order.Direction.desc);
    }

    /**
     * ?
     *
     * @return 
     */
    public String getProperty() {
        return property;
    }

    /**
     * 
     *
     * @param property
     *            
     */
    public void setProperty(String property) {
        this.property = property;
    }

    /**
     * ??
     *
     * @return ?
     */
    public Order.Direction getDirection() {
        return direction;
    }

    /**
     * ?
     *
     * @param direction
     *            ?
     */
    public void setDirection(Order.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();
    }

}