All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.zulia.server.util.FieldAndSubFields Maven / Gradle / Ivy

There is a newer version: 1.6.4
Show newest version
package io.zulia.server.util;

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class FieldAndSubFields {

	private Map> topLevelToChildren = new HashMap<>();
	private Set topLevelFields = new HashSet<>();

	public FieldAndSubFields(Collection fields) {
		for (String field : fields) {
			int indexOfDot = field.indexOf('.');
			if (indexOfDot != -1) {
				String topLevel = field.substring(0, indexOfDot);
				topLevelFields.add(topLevel);
				topLevelToChildren.computeIfAbsent(topLevel, v -> new HashSet<>()).add(field.substring(indexOfDot + 1));
			}
			else {
				topLevelFields.add(field);
			}
		}
	}

	public Map> getTopLevelToChildren() {
		return topLevelToChildren;
	}

	public Set getTopLevelFields() {
		return topLevelFields;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy