org.hibernate.search.engine.environment.bean.CompositeBeanHolder 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
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.search.engine.environment.bean;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.search.util.common.impl.Closer;
import org.hibernate.search.util.common.impl.CollectionHelper;
final class CompositeBeanHolder implements BeanHolder> {
private final List extends BeanHolder extends T>> dependencies;
private final List instances;
CompositeBeanHolder(List extends BeanHolder extends T>> dependencies) {
this.dependencies = dependencies;
List tmp = new ArrayList<>( dependencies.size() );
for ( BeanHolder extends T> delegate : dependencies ) {
tmp.add( delegate.get() );
}
this.instances = CollectionHelper.toImmutableList( tmp );
}
@Override
public String toString() {
return getClass().getSimpleName() + "["
+ "instances=" + instances
+ ", dependencies=" + dependencies
+ "]";
}
@Override
public List get() {
return instances;
}
@Override
public void close() {
try ( Closer closer = new Closer<>() ) {
closer.pushAll( BeanHolder::close, dependencies );
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy