@Singleton
public class ListBlobsOptionsToListOptions implements
Function<ListBlobsOptions[], ListContainerOptions> {
public ListContainerOptions apply(ListBlobsOptions[] optionsList) {
ListContainerOptions options = new ListContainerOptions();
if (optionsList.length != 0) {
if (optionsList[0].getDelimiter() == null) {
options.recursive();
} else if (!optionsList[0].getDelimiter().equals("/")) {
throw new IllegalArgumentException("only '/' is allowed as a blobstore delimiter");
}
if (optionsList[0].getMarker() != null) {
options.afterMarker(optionsList[0].getMarker());
}
if (optionsList[0].getMaxResults() != null) {
options.maxResults(optionsList[0].getMaxResults());
}
if (optionsList[0].getPrefix() != null) {
options.inDirectory(optionsList[0].getPrefix());
}
if (optionsList[0].getIncludeMetadata()) {
options.withDetails();
}
}
return options;
}