org.hibernate.search.cfg.spi.ParameterAnnotationsReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-search-engine Show documentation
Show all versions of hibernate-search-engine Show documentation
Core of the Object/Lucene mapper, query engine and index management
/*
* 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.cfg.spi;
import java.util.LinkedHashMap;
import java.util.Map;
import org.hibernate.search.annotations.Parameter;
import org.hibernate.search.util.logging.impl.Log;
import org.hibernate.search.util.logging.impl.LoggerFactory;
import java.lang.invoke.MethodHandles;
/**
* Helper to convert the org.hibernate.search.annotations.Parameter
* annotations.
*/
public final class ParameterAnnotationsReader {
private static final Log log = LoggerFactory.make( MethodHandles.lookup() );
private ParameterAnnotationsReader() {
// Not to be constructed
}
/**
* Converts the Parameter key/value pairs in a map, and validates
* against conflicting duplicates.
* Any duplicate will cause to throw a SearchException
* @param parameters
* @return a new Map instance containing the key/value pairs
* @throws org.hibernate.search.exception.SearchException
*/
public static Map toNewMutableMap(Parameter[] parameters) {
Map map = new LinkedHashMap<>();
if ( parameters != null ) {
for ( Parameter param : parameters ) {
String previous = map.put( param.name(), param.value() );
if ( previous != null ) {
throw log.conflictingParameterDefined( param.name(), param.value(), previous );
}
}
}
return map;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy