nyla.solutions.core.data.Data Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nyla.solutions.core Show documentation
Show all versions of nyla.solutions.core Show documentation
This Java API provides support for application utilities (application configuration, data encryption, debugger, text processing, and more).
The newest version!
package nyla.solutions.core.data;
import nyla.solutions.core.util.Debugger;
import java.io.Serializable;
import java.util.*;
/**
* Data represents a Serializable data type.
* @author Gregory Green
* @version 1.0
*/
public abstract class Data
implements Serializable
{
/**
*
*/
private static final long serialVersionUID = -2411033885084918560L;
/**
* Represent a true value
*/
public static final int NULL = -1;
/**
* Represent a true value
*/
public static final String TRUE = "T";
/**
* Represent a flag value
*/
public static final String FALSE = "F";
/**
* Represent a true value
*/
public static final String YES = "Y";
/**
* Represent a flase value
*/
public static final String NO = "N";
/**
* Determines whether the provided str is equal to null
* or the length is equal to zero
* @param text the text to text
* @return true when str is null or length = 0
*/
public static boolean isNull(String text)
{
return text == null || text.trim().length() == 0 ||
"null".equals(text.trim());
} //---------------------------------------------
/**
* @return the string representation of a object
*/
public String toString()
{
return Debugger.toString(this);
}
/**
* Sort a list
* @param the type
* @param aVOs the value objects
* @return collection the sorted criteria
*/
public static Collection sortByCriteria(Collection aVOs)
{
final List list;
if (aVOs instanceof List)
list = (List) aVOs;
else
list = new ArrayList(aVOs);
Collections.sort(list, new CriteriaComparator());
return list;
} //-----------------------------------------------
/**
* Sort a list by a date property (Updateable)
* @param collection the collection
* @param THE TYPE
* @return COLLECTION OF type stored
*/
public static Collection sortByUpdateDate(Collection collection)
{
List list = collection instanceof List ? (List) collection : new ArrayList(collection);
Collections.sort(list, new UpdateDateComparator());
return list;
} //-----------------------------------------------
/**
* Comparator for the status active flag
*/
public static class CriteriaComparator implements Comparator
© 2015 - 2025 Weber Informatics LLC | Privacy Policy