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

com.github.wz2cool.dynamic.SortDescriptor Maven / Gradle / Ivy

There is a newer version: 3.2.32
Show newest version
package com.github.wz2cool.dynamic;


import com.github.wz2cool.dynamic.helper.CommonsHelper;
import com.github.wz2cool.dynamic.lambda.GetPropertyFunction;

import java.io.Serializable;

/**
 * The type Sort descriptor.
 *
 * @author Frank
 */
public class SortDescriptor extends BaseSortDescriptor implements Serializable {
    private static final long serialVersionUID = 819843464658066502L;

    private String propertyName;
    private SortDirection direction = SortDirection.ASC;

    /**
     * Instantiates a new Sort descriptor.
     */
    public SortDescriptor() {
        // create a empty instance.
    }

    /**
     * Instantiates a new Sort descriptor.
     *
     * @param propertyName  the property path
     * @param direction the sort direction
     */
    public SortDescriptor(String propertyName, SortDirection direction) {
        this.propertyName = propertyName;
        this.direction = direction;
    }

    public  SortDescriptor(GetPropertyFunction getFieldFunc, SortDirection direction) {
        this.propertyName = CommonsHelper.getPropertyInfo(getFieldFunc).getPropertyName();
        this.direction = direction;
    }

    /**
     * Gets property path.
     *
     * @return the property path
     */
    public String getPropertyName() {
        return propertyName;
    }

    /**
     * Sets property path.
     *
     * @param propertyName the property path
     */
    public void setPropertyName(String propertyName) {
        this.propertyName = propertyName;
    }

    public  void setPropertyPath(GetPropertyFunction getFieldFunc) {
        this.propertyName = CommonsHelper.getPropertyInfo(getFieldFunc).getPropertyName();
    }

    /**
     * Gets sort direction.
     *
     * @return the sort direction
     */
    public SortDirection getDirection() {
        return direction;
    }

    /**
     * Sets sort direction.
     *
     * @param direction the sort direction
     */
    public void setDirection(SortDirection direction) {
        this.direction = direction;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy