Class DataSubset<T,I>

java.lang.Object
com.appiancorp.suiteapi.common.paging.DataSubset<T,I>
Type Parameters:
T - The type of the results accessible in getData()
I - The type of the identifiers
Direct Known Subclasses:
ListViewDataSubset, TypedValueDataSubset

public abstract class DataSubset<T,I> extends Object
This class is available as a preview of functionality that will be added to the supported public API in a future release. While it is in the preview phase, it is subject to change or removal without deprecation or notice. Although notice of change is not guaranteed, we will try to let developers know of major changes through announcements in release notes. A view that holds a range of data (getData()). If the results are part of larger set, getTotalCount() will be larger than the number of available results. The boundaries of the view, with respect to the larger set, can be retrieved from getStartIndex() and getBatchSize(). The results are identified by getIdentifiers(), which should be either null or of the same size as getData(). The identifiers are unique only when the underlying data source guarantees uniqueness.

To use this class in both expression functions and smart services, it's necessary to create a type that extends DataSubset and use the XmlSeeAlso annotation to specify the list of types (classes) that the result page may hold at runtime. It's not necessary to specify Java primitive wrappers or their array types nor it's necessary to list classes that can be statically reached from another type already included. The subclass must define both an XmlType and XmlRootElement annotations.

When subclasses are used as a parameter or return type in expression functions or smart services, it's recommended the Type annotation value matches the one defined by QNAME, not the one defined by the subclass, this is important if the subclass does not define extra fields since using will make the subclass appear as a generic DataSubset type to both expression functions and smart services, maximizing interoperability.

Any subclass of this should add the following Jaxb annotations:

  • Add @XmlElement(type=Object.class, nillable=true, namespace="") to getData() and getIdentifiers() along with an @XmlSeeAlso({T.class,I.class}) where T and I are the type parameters to this class.
  • Add @XmlRootElement(namespace=Type.APPIAN_NAMESPACE, name=DataSubset.XML_ROOT_ELEMENT) annotation to the class
  • Add @XmlType(namespace=[Your Namespace], propOrder = {"startIndex", "batchSize", "sort", "totalCount", "data", "identifiers"}) annotation to the class
  • For Example:
     
       @XmlRootElement(namespace=Type.APPIAN_NAMESPACE, name=DataSubset.XML_ROOT_ELEMENT)
       @XmlType(namespace=[Your Namespace], propOrder = {"startIndex", "batchSize", "sort", "totalCount", "data", "identifiers"})
       @XmlSeeAlso({Person.class,String.class})
       public static class PersonDataSubset extends DataSubset<Person,String> {
    
         private List<Person> data;
         private List<String> identifiers;
    
         public PersonDataSubset() {}
    
         @Override
         @XmlElement(type=Object.class, nillable=true, namespace="")
         public List<Person> getData() {
           return data;
         }
         @Override
         @XmlElement(type=Object.class, nillable=true, namespace="")
         public List<String> getIdentifiers() {
           return identifiers;
         }
         @Override
         protected void setData(List<Person> data) {
           this.data = data;
         }
         @Override
         protected void setIdentifiers(List<String> identifiers) {
           this.identifiers = identifiers;
         }
       }
     
     
    • Field Details

    • Constructor Details

      • DataSubset

        protected DataSubset()
      • DataSubset

        public DataSubset(int startIndex, int batchSize, List<SortInfo> sort, int totalCount, List<T> results, List<I> identifiers)
        Creates a view that holds a range of data. identifiers must be either null or the same size as results.
        Parameters:
        results - the view of the data.
        identifiers - underlying data source identifiers. Unique only when the data source guarantees uniqueness
        startIndex - the beginning of the view
        batchSize - the "requested" number of results. The actual number of results may be less if the end of the underlying data is reached. A negative batchSize indicates that the maximum number of returned results was not limited.
        totalCount - total number of results available in the data source
        sort -
    • Method Details

      • getStartIndex

        public int getStartIndex()
        Returns the start index of this paged result.
      • getBatchSize

        public int getBatchSize()
        Returns the number of requested elements. The actual number of results in this paged result can be retrieved from getData(). A negative batchSize indicates that the maximum number of returned results should not be limited.
      • getTotalCount

        public int getTotalCount()
        Returns the total number of results available in the data source.
      • getData

        public abstract List<T> getData()
        Returns the paged results.
      • getIdentifiers

        public abstract List<I> getIdentifiers()
        Returns the identifiers of the data in getData(). These are only unique if the underlying data source guarantees uniqueness.
      • setData

        protected abstract void setData(List<T> data)
        Sets the results
        Parameters:
        data - List of results
      • setIdentifiers

        protected abstract void setIdentifiers(List<I> identifiers)
        Sets the the identifiers of the data in getData().
        Parameters:
        identifiers - List of identifiers
      • getSort

        public List<SortInfo> getSort()
        Returns the sort expressions that have been applied to the data in getData().
      • toString

        public String toString()
        Overrides:
        toString in class Object
      • multilineToStringHelper

        protected com.appian.core.base.MultilineToStringHelper multilineToStringHelper(int indent)
      • multilineToString

        public static com.appian.core.base.ToStringFunction<? extends DataSubset> multilineToString(int indent)