org.hibernate.graph.spi.GraphImplementor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
JPMS Module-Info's for a few of the Jakarta Libraries just until they add them in themselves
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.graph.spi;
import java.util.List;
import java.util.function.Consumer;
import javax.persistence.metamodel.Attribute;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.graph.AttributeNode;
import org.hibernate.graph.CannotBecomeEntityGraphException;
import org.hibernate.graph.CannotContainSubGraphException;
import org.hibernate.graph.Graph;
import org.hibernate.graph.SubGraph;
import org.hibernate.metamodel.model.domain.spi.PersistentAttributeDescriptor;
import org.hibernate.metamodel.model.domain.spi.ManagedTypeDescriptor;
/**
* Integration version of the Graph contract
*
* @author Strong Liu
* @author Steve Ebersole
* @author Andrea Boriero
*/
public interface GraphImplementor extends Graph, GraphNodeImplementor {
boolean appliesTo(ManagedTypeDescriptor managedType);
boolean appliesTo(Class javaType);
@SuppressWarnings("unchecked")
void merge(GraphImplementor... others);
SessionFactoryImplementor sessionFactory();
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Co-variant returns
@Override
ManagedTypeDescriptor getGraphedType();
@Override
RootGraphImplementor makeRootGraph(String name, boolean mutable) throws CannotBecomeEntityGraphException;
@Override
SubGraphImplementor makeSubGraph(boolean mutable);
@Override
GraphImplementor makeCopy(boolean mutable);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// AttributeNode access
default void visitAttributeNodes(Consumer> consumer) {
getAttributeNodeImplementors().forEach( consumer );
}
AttributeNodeImplementor addAttributeNode(AttributeNodeImplementor makeCopy);
List> getAttributeNodeImplementors();
@Override
@SuppressWarnings("unchecked")
default List> getAttributeNodeList() {
return (List) getAttributeNodeImplementors();
}
@Override
AttributeNodeImplementor findAttributeNode(String attributeName);
AttributeNodeImplementor findAttributeNode(PersistentAttributeDescriptor attribute);
@Override
@SuppressWarnings("unchecked")
default AttributeNodeImplementor findAttributeNode(Attribute attribute) {
return (AttributeNodeImplementor) findAttributeNode( (PersistentAttributeDescriptor) attribute );
}
@Override
AttributeNodeImplementor addAttributeNode(String attributeName) throws CannotContainSubGraphException;
AttributeNodeImplementor addAttributeNode(PersistentAttributeDescriptor attribute) throws CannotContainSubGraphException;
@Override
@SuppressWarnings("unchecked")
default AttributeNodeImplementor addAttributeNode(Attribute attribute)
throws CannotContainSubGraphException {
return addAttributeNode( (PersistentAttributeDescriptor) attribute );
}
@SuppressWarnings("unchecked")
default AttributeNodeImplementor findOrCreateAttributeNode(String name) {
return findOrCreateAttributeNode( (PersistentAttributeDescriptor) getGraphedType().getAttribute( name ) );
}
AttributeNodeImplementor findOrCreateAttributeNode(PersistentAttributeDescriptor attribute);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// sub graph nodes
@Override
@SuppressWarnings("unchecked")
default SubGraphImplementor addSubGraph(String attributeName) throws CannotContainSubGraphException {
return (SubGraphImplementor) findOrCreateAttributeNode( attributeName ).makeSubGraph();
}
@Override
@SuppressWarnings("unchecked")
default SubGraphImplementor addSubGraph(String attributeName, Class subType) throws CannotContainSubGraphException {
return findOrCreateAttributeNode( attributeName ).makeSubGraph( subType );
}
default SubGraphImplementor addSubGraph(PersistentAttributeDescriptor attribute)
throws CannotContainSubGraphException {
return findOrCreateAttributeNode( attribute ).makeSubGraph();
}
default SubGraphImplementor addSubGraph(PersistentAttributeDescriptor attribute, Class subType)
throws CannotContainSubGraphException {
return findOrCreateAttributeNode( attribute ).makeSubGraph( subType );
}
@Override
@SuppressWarnings("unchecked")
default SubGraphImplementor addSubGraph(Attribute attribute)
throws CannotContainSubGraphException {
return addSubGraph( (PersistentAttributeDescriptor) attribute );
}
@Override
@SuppressWarnings("unchecked")
default SubGraph addSubGraph(Attribute attribute, Class type)
throws CannotContainSubGraphException {
return addSubGraph( (PersistentAttributeDescriptor) attribute, type );
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// key sub graph nodes
@Override
@SuppressWarnings("unchecked")
default SubGraphImplementor addKeySubGraph(String attributeName) {
return (SubGraphImplementor) findOrCreateAttributeNode( attributeName ).makeKeySubGraph();
}
@Override
@SuppressWarnings("unchecked")
default SubGraphImplementor addKeySubGraph(String attributeName, Class subtype) {
return findOrCreateAttributeNode( attributeName ).makeKeySubGraph( subtype );
}
@SuppressWarnings("unchecked")
default SubGraphImplementor addKeySubGraph(PersistentAttributeDescriptor attribute) {
return findOrCreateAttributeNode( attribute ).makeKeySubGraph();
}
@Override
@SuppressWarnings("unchecked")
default SubGraphImplementor addKeySubGraph(Attribute attribute) {
return addKeySubGraph( (PersistentAttributeDescriptor) attribute );
}
@SuppressWarnings("unchecked")
default SubGraphImplementor addKeySubGraph(
PersistentAttributeDescriptor attribute,
Class subType) throws CannotContainSubGraphException {
return findOrCreateAttributeNode( attribute ).makeKeySubGraph( subType );
}
@Override
@SuppressWarnings("unchecked")
default SubGraphImplementor addKeySubGraph(
Attribute attribute,
Class subType) throws CannotContainSubGraphException {
return addKeySubGraph( (PersistentAttributeDescriptor) attribute, subType );
}
}