org.hibernate.search.engine.search.aggregation.AggregationKey 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
Hibernate Search engine, always required
/*
* 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.search.aggregation;
import java.util.Objects;
import org.hibernate.search.engine.search.query.SearchResult;
import org.hibernate.search.util.common.impl.Contracts;
/**
* A key allowing to retrieve an aggregation from the search result.
*
* @param The type of result for this aggregation.
*
* @see SearchResult#aggregation(AggregationKey)
*/
public final class AggregationKey {
/**
* @param name The name of the aggregation. All root aggregation names must be unique within a single query.
* @param The type of result for this aggregation.
* @return A new aggregation key.
*/
public static AggregationKey of(String name) {
Contracts.assertNotNullNorEmpty( name, "name" );
return new AggregationKey<>( name );
}
private final String name;
private AggregationKey(String name) {
this.name = name;
}
@Override
public String toString() {
return getClass().getSimpleName() + "[" + name + "]";
}
@Override
public boolean equals(Object o) {
if ( this == o ) {
return true;
}
if ( o == null || getClass() != o.getClass() ) {
return false;
}
AggregationKey> that = (AggregationKey>) o;
return Objects.equals( name, that.name );
}
@Override
public int hashCode() {
return Objects.hash( name );
}
/**
* @return The name passed to {@link #of(String)}.
*/
public String name() {
return name;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy