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

com.foxinmy.weixin4j.model.paging.Sort Maven / Gradle / Ivy

There is a newer version: 1.10.2
Show newest version
package com.foxinmy.weixin4j.model.paging;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class Sort implements Serializable {

	private static final long serialVersionUID = -4298853295391613880L;

	public static final Direction DEFAULT_DIRECTION = Direction.ASC;
	private Map> orders;

	public Sort() {
	}

	public Sort(String... properties) {
		this(DEFAULT_DIRECTION, properties);
	}

	public Sort(Direction direction, String... properties) {
		this(direction, properties == null ? new ArrayList() : Arrays
				.asList(properties));
	}

	public Sort(Direction direction, List properties) {
		if (properties == null || properties.isEmpty()) {
			throw new IllegalArgumentException(
					"You have to provide at least one property to sort by!");
		}
		this.orders = new LinkedHashMap>(
				properties.size());
		this.orders.put(direction, properties);
	}

	public Map> getOrders() {
		return orders;
	}

	public boolean hasSort() {
		return orders != null && !orders.isEmpty();
	}

	public static enum Direction {
		ASC, DESC;
	}

	@Override
	public String toString() {
		return "Sort [" + orders + "]";
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy