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

org.hibernate.search.engine.metadata.impl.PathsContext Maven / Gradle / Ivy

There is a newer version: 5.11.12.Final
Show newest version
/*
 * Hibernate Search, full-text search for your domain model
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.search.engine.metadata.impl;

import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

/**
 * Container class for information about the current set of paths as
 * well as tracking which paths have been encountered to validate the
 * existence of all configured paths.
 */
public class PathsContext {

	private final Map pathsEncounteredState = new LinkedHashMap<>();

	public void addIncludedPath(String path) {
		pathsEncounteredState.put( path, Boolean.FALSE );
	}

	public boolean isIncluded(DocumentFieldPath path) {
		return pathsEncounteredState.keySet().contains( path.getAbsoluteName() );
	}

	public void markEncounteredPath(DocumentFieldPath path) {
		pathsEncounteredState.put( path.getAbsoluteName(), Boolean.TRUE );
	}

	public Set getEncounteredPaths() {
		return pathsEncounteredState.keySet();
	}

	public Set getUnEncounteredPaths() {
		Set unEncounteredPaths = new LinkedHashSet<>();
		for ( String path : pathsEncounteredState.keySet() ) {
			if ( notEncountered( path ) ) {
				unEncounteredPaths.add( path );
			}
		}
		return unEncounteredPaths;
	}

	private boolean notEncountered(String path) {
		return !pathsEncounteredState.get( path );
	}
}






© 2015 - 2025 Weber Informatics LLC | Privacy Policy