HHH-16900 Rework also the MutationGroup APIs
This commit is contained in:
parent
c608ee3a98
commit
c1767adee7
|
@ -8,7 +8,6 @@ package org.hibernate.sql.model.ast;
|
|||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import org.hibernate.sql.model.MutationOperation;
|
||||
import org.hibernate.sql.model.MutationTarget;
|
||||
import org.hibernate.sql.model.MutationType;
|
||||
|
||||
|
@ -25,9 +24,9 @@ public interface MutationGroup {
|
|||
|
||||
int getNumberOfTableMutations();
|
||||
|
||||
<O extends MutationOperation, M extends TableMutation<O>> M getSingleTableMutation();
|
||||
TableMutation getSingleTableMutation();
|
||||
|
||||
<O extends MutationOperation, M extends TableMutation<O>> M getTableMutation(String tableName);
|
||||
TableMutation getTableMutation(String tableName);
|
||||
|
||||
<O extends MutationOperation, M extends TableMutation<O>> void forEachTableMutation(BiConsumer<Integer, M> action);
|
||||
void forEachTableMutation(BiConsumer<Integer, TableMutation> action);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ package org.hibernate.sql.model.internal;
|
|||
import java.util.Locale;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import org.hibernate.sql.model.MutationOperation;
|
||||
import org.hibernate.sql.model.MutationTarget;
|
||||
import org.hibernate.sql.model.MutationType;
|
||||
import org.hibernate.sql.model.ast.MutationGroup;
|
||||
|
@ -51,22 +50,19 @@ public class MutationGroupSingle implements MutationGroup {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <O extends MutationOperation, M extends TableMutation<O>> M getSingleTableMutation() {
|
||||
//noinspection unchecked
|
||||
return (M) tableMutation;
|
||||
public TableMutation getSingleTableMutation() {
|
||||
return tableMutation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <O extends MutationOperation, M extends TableMutation<O>> M getTableMutation(String tableName) {
|
||||
public TableMutation getTableMutation(String tableName) {
|
||||
assert tableMutation.getMutatingTable().getTableName().equals( tableName );
|
||||
//noinspection unchecked
|
||||
return (M) tableMutation;
|
||||
return tableMutation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <O extends MutationOperation, M extends TableMutation<O>> void forEachTableMutation(BiConsumer<Integer, M> action) {
|
||||
//noinspection unchecked
|
||||
action.accept( 0, (M) tableMutation );
|
||||
public void forEachTableMutation(BiConsumer<Integer, TableMutation> action) {
|
||||
action.accept( 0, tableMutation );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,7 +9,6 @@ package org.hibernate.sql.model.internal;
|
|||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import org.hibernate.sql.model.MutationOperation;
|
||||
import org.hibernate.sql.model.MutationTarget;
|
||||
import org.hibernate.sql.model.MutationType;
|
||||
import org.hibernate.sql.model.ast.MutationGroup;
|
||||
|
@ -50,18 +49,17 @@ public class MutationGroupStandard implements MutationGroup {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <O extends MutationOperation, M extends TableMutation<O>> M getSingleTableMutation() {
|
||||
public TableMutation getSingleTableMutation() {
|
||||
throw new IllegalStateException( "Group contains multiple table mutations : " + mutationTarget.getNavigableRole() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <O extends MutationOperation, M extends TableMutation<O>> M getTableMutation(String tableName) {
|
||||
public TableMutation getTableMutation(String tableName) {
|
||||
for ( int i = 0; i < tableMutationList.size(); i++ ) {
|
||||
final TableMutation<?> tableMutation = tableMutationList.get( i );
|
||||
if ( tableMutation != null ) {
|
||||
if ( tableMutation.getMutatingTable().getTableName().equals( tableName ) ) {
|
||||
//noinspection unchecked
|
||||
return (M) tableMutation;
|
||||
return tableMutation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,10 +67,10 @@ public class MutationGroupStandard implements MutationGroup {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <O extends MutationOperation, M extends TableMutation<O>> void forEachTableMutation(BiConsumer<Integer, M> action) {
|
||||
public void forEachTableMutation(BiConsumer<Integer, TableMutation> action) {
|
||||
for ( int i = 0; i < tableMutationList.size(); i++ ) {
|
||||
//noinspection unchecked
|
||||
action.accept( i, (M)tableMutationList.get( i ) );
|
||||
action.accept( i, tableMutationList.get( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue