edu.byu.hbll.box.internal.util.BoxUtils Maven / Gradle / Ivy
package edu.byu.hbll.box.internal.util;
import edu.byu.hbll.box.BoxQuery;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Random utilities used by Box.
*
* @author Charles Draper
*/
public class BoxUtils {
/**
* Converts non _at_doc fields into _at_doc fields.
*
* @param fields dot-notated fields denoting what should be projected
* @return the new fields
*/
public static Set canonicalizeFields(Collection fields) {
return Collections.unmodifiableSet(
(Set)
fields
.stream()
.map(
field -> {
if (!field.equals(BoxQuery.DOCUMENT_FIELD)
&& !field.startsWith("@doc.")
&& !field.equals(BoxQuery.METADATA_FIELD)
&& !field.startsWith("@box.")) {
return "@doc." + field;
} else {
return field;
}
})
.collect(Collectors.toCollection(LinkedHashSet::new)));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy