Skip to content

Commit 175c764

Browse files
committed
[#1741] Format exising code
1 parent d8e08d7 commit 175c764

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/mutation/GeneratorValueUtil.java

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
package org.hibernate.reactive.persister.entity.mutation;
77

88
import static org.hibernate.reactive.util.impl.CompletionStages.completedFuture;
9+
910
import java.util.concurrent.CompletionStage;
11+
1012
import org.hibernate.engine.spi.SharedSessionContractImplementor;
1113
import org.hibernate.generator.BeforeExecutionGenerator;
1214
import org.hibernate.generator.EventType;
@@ -22,27 +24,26 @@
2224

2325
final class GeneratorValueUtil {
2426

25-
private GeneratorValueUtil() {
26-
}
27-
28-
29-
static CompletionStage<?> generateValue(
30-
SharedSessionContractImplementor session, Object entity, Object currentValue,
31-
BeforeExecutionGenerator generator, EventType eventType) {
32-
if (generator instanceof StageGenerator) {
33-
final Stage.Session stageSession = new StageSessionImpl( (ReactiveSession) session );
34-
return ((StageGenerator) generator).generate(stageSession, entity, currentValue, eventType);
35-
}
36-
37-
if (generator instanceof MutinyGenerator) {
38-
MutinySessionFactoryImpl mutinyFactory = new MutinySessionFactoryImpl( (SessionFactoryImpl) session.getFactory() );
39-
Mutiny.Session mutinySession = new MutinySessionImpl( (ReactiveSession) session, mutinyFactory );
40-
return ((MutinyGenerator) generator).generate(mutinySession, entity, currentValue, eventType).subscribeAsCompletionStage();
41-
}
42-
43-
44-
// We should throw an exception, but I don't want to break things for people using @CreationTimestamp or similar
45-
// annotations. We need an alternative for Hibernate Reactive.
46-
return completedFuture( generator.generate( session, entity, currentValue, eventType) );
47-
}
27+
private GeneratorValueUtil() {
28+
}
29+
30+
static CompletionStage<?> generateValue(
31+
SharedSessionContractImplementor session, Object entity, Object currentValue,
32+
BeforeExecutionGenerator generator, EventType eventType) {
33+
if ( generator instanceof StageGenerator ) {
34+
final Stage.Session stageSession = new StageSessionImpl( (ReactiveSession) session );
35+
return ( (StageGenerator) generator ).generate( stageSession, entity, currentValue, eventType );
36+
}
37+
38+
if ( generator instanceof MutinyGenerator ) {
39+
MutinySessionFactoryImpl mutinyFactory = new MutinySessionFactoryImpl( (SessionFactoryImpl) session.getFactory() );
40+
Mutiny.Session mutinySession = new MutinySessionImpl( (ReactiveSession) session, mutinyFactory );
41+
return ( (MutinyGenerator) generator ).generate( mutinySession, entity, currentValue, eventType )
42+
.subscribeAsCompletionStage();
43+
}
44+
45+
// We should throw an exception, but I don't want to break things for people using @CreationTimestamp or similar
46+
// annotations. We need an alternative for Hibernate Reactive.
47+
return completedFuture( generator.generate( session, entity, currentValue, eventType ) );
48+
}
4849
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/tuple/MutinyGenerator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
public abstract class MutinyGenerator implements BeforeExecutionGenerator {
1717

1818
@Override
19-
public Object generate(SharedSessionContractImplementor session, Object owner, Object currentValue,
20-
EventType eventType) {
19+
public Object generate(SharedSessionContractImplementor session, Object owner, Object currentValue, EventType eventType) {
2120
throw new UnsupportedOperationException( "Use generate(Mutiny.Session, Object, Object, EventType) instead" );
2221
}
2322

hibernate-reactive-core/src/test/java/org/hibernate/reactive/CurrentUser.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ public EnumSet<EventType> getEventTypes() {
9191
public static abstract class AbstractLoggedUserGeneratorWithMutiny extends MutinyGenerator {
9292

9393
@Override
94-
public Uni<Object> generate(Mutiny.Session session, Object owner, Object currentValue,
95-
EventType eventType) {
94+
public Uni<String> generate(Mutiny.Session session, Object owner, Object currentValue, EventType eventType) {
9695
Objects.requireNonNull( session );
9796
String value = CurrentUser.INSTANCE.get();
9897
return Uni.createFrom().item( value );

0 commit comments

Comments
 (0)