String featureTypeName = featureType.getTypeName();
LOGGER.fine("PagedUnique process called on resource: " + featureTypeName
+ " - field: " + fieldName);
UniqueVisitor visitor = new UniqueVisitor(FF.property(fieldName));
Integer listSize = 0;
List<String> list = new ArrayList<String>();
try {
// counts total elements
features.accepts(visitor, null);
if(visitor.getResult() == null || visitor.getResult().toList() == null) {
listSize = 0;
list = new ArrayList<String>(0);
} else {
listSize = visitor.getResult().toList().size();
if(maxFeatures == null || maxFeatures > listSize) {
maxFeatures = listSize;
}
// Reset visitor and set pagination
visitor.reset();
if(startIndex != null) {
visitor.setStartIndex(startIndex);
}
if(maxFeatures != null) {
visitor.setMaxFeatures(maxFeatures);
}
visitor.setPreserveOrder(true);
features.accepts(visitor, null);
if(visitor.getResult() == null || visitor.getResult().toList() == null) {
list = new ArrayList<String>(0);
} else {
list = visitor.getResult().toList();
}
}
return new Results(featureTypeName, fieldName, listSize, list);
} catch (Exception e) {