Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor - Reorder field modifiers as per Java specification and some lambda syntax enhancements #1069

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
public class DistributedLeaderAction<S, E> implements Action<S, E> {

private final static Log log = LogFactory.getLog(DistributedLeaderAction.class);
private static final Log log = LogFactory.getLog(DistributedLeaderAction.class);
private final Action<S, E> action;
private final StateMachineEnsemble<S, E> ensemble;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
public abstract class AbstractConfiguredAnnotationBuilder<O,I,B extends AnnotationBuilder<O>>
extends AbstractAnnotationBuilder<O> {

private final static Log log = LogFactory.getLog(AbstractConfiguredAnnotationBuilder.class);
private static final Log log = LogFactory.getLog(AbstractConfiguredAnnotationBuilder.class);

/** Configurers which are added to this builder before the configure step */
private final LinkedHashMap<Class<? extends AnnotationConfigurer<O, B>>, List<AnnotationConfigurer<O, B>>> mainConfigurers =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/
final class AutowireBeanFactoryObjectPostProcessor implements ObjectPostProcessor<Object>, DisposableBean, SmartLifecycle {

private final static Log log = LogFactory.getLog(AutowireBeanFactoryObjectPostProcessor.class);
private static final Log log = LogFactory.getLog(AutowireBeanFactoryObjectPostProcessor.class);

private final AutowireCapableBeanFactory autowireBeanFactory;
private final List<DisposableBean> disposableBeans = new ArrayList<DisposableBean>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@Configuration
public class ObjectPostProcessorConfiguration {

private final static String POST_PROCESSOR_BEAN_ID = "org.springframework.statemachine.config.common.annotation.configuration.objectPostProcessor";
private static final String POST_PROCESSOR_BEAN_ID = "org.springframework.statemachine.config.common.annotation.configuration.objectPostProcessor";

@Bean(name = POST_PROCESSOR_BEAN_ID)
public ObjectPostProcessor<Object> objectPostProcessor(AutowireCapableBeanFactory beanFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
*/
public class DistributedStateMachine<S, E> extends LifecycleObjectSupport implements StateMachine<S, E> {

private final static Log log = LogFactory.getLog(DistributedStateMachine.class);
private static final Log log = LogFactory.getLog(DistributedStateMachine.class);
private final StateMachineEnsemble<S, E> ensemble;
private final StateMachine<S, E> delegate;
private final LocalEnsembleListener listener = new LocalEnsembleListener();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/
public class DefaultStateMachineService<S, E> implements StateMachineService<S, E>, DisposableBean {

private final static Log log = LogFactory.getLog(DefaultStateMachineService.class);
private static final Log log = LogFactory.getLog(DefaultStateMachineService.class);
private final StateMachineFactory<S, E> stateMachineFactory;
private final Map<String, StateMachine<S, E>> machines = new HashMap<String, StateMachine<S, E>>();
private StateMachinePersist<S, E, String> stateMachinePersist;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@ public Mono<Void> exit(StateContext<S, E> context) {
}
return Mono.empty();
})
.then(Mono.<Void>fromRunnable(() -> {
completionListeners.clear();
}))
.then(Mono.<Void>fromRunnable(completionListeners::clear))
.then(cancelStateActions())
.then(Mono.<Void>fromRunnable(() -> {
stateListener.onExit(context);
Expand Down Expand Up @@ -360,12 +358,12 @@ public void removeActionListener(ActionListener<S, E> listener) {

@Override
protected Mono<Void> doPreStartReactively() {
return Mono.fromRunnable(() -> armTriggers());
return Mono.fromRunnable(this::armTriggers);
}

@Override
protected Mono<Void> doPreStopReactively() {
return Mono.fromRunnable(() -> disarmTriggers());
return Mono.fromRunnable(this::disarmTriggers);
}

/**
Expand Down Expand Up @@ -525,9 +523,7 @@ private Mono<Void> cancelStateActions() {
}
})
// we're done, clear state scheduled state actions
.thenEmpty(Mono.fromRunnable(() -> {
scheduledActions.clear();
}));
.thenEmpty(Mono.fromRunnable(scheduledActions::clear));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*/
public class ChoicePseudoState<S, E> implements PseudoState<S, E> {

private final static Log log = LogFactory.getLog(ChoicePseudoState.class);
private static final Log log = LogFactory.getLog(ChoicePseudoState.class);
private final List<ChoiceStateData<S, E>> choices;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public EntryPseudoState(State<S, E> state) {
}

@Override
final public PseudoStateKind getKind() {
public final PseudoStateKind getKind() {
return PseudoStateKind.ENTRY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ExitPseudoState(StateHolder<S, E> state) {
}

@Override
final public PseudoStateKind getKind() {
public final PseudoStateKind getKind() {
return PseudoStateKind.EXIT;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*/
public class JoinPseudoState<S, E> extends AbstractPseudoState<S, E> {

private final static Log log = LogFactory.getLog(JoinPseudoState.class);
private static final Log log = LogFactory.getLog(JoinPseudoState.class);
private final List<List<State<S, E>>> joins;
private final JoinTracker tracker;
private final List<JoinStateData<S, E>> joinTargets;
Expand All @@ -68,15 +68,13 @@ public Mono<State<S, E>> entry(StateContext<S, E> context) {
return Flux.fromIterable(joinTargets)
.filterWhen(jst -> evaluateInternal(jst.guard, context))
.next()
.map(jst -> jst.getState());
.map(JoinStateData::getState);
});
}

@Override
public Mono<Void> exit(StateContext<S, E> context) {
return Mono.fromRunnable(() -> {
tracker.reset();
});
return Mono.fromRunnable(tracker::reset);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*/
public class JunctionPseudoState<S, E> implements PseudoState<S, E> {

private final static Log log = LogFactory.getLog(JunctionPseudoState.class);
private static final Log log = LogFactory.getLog(JunctionPseudoState.class);
private final List<JunctionStateData<S, E>> junctions;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,17 @@ public boolean sendEvent(E event) {

@Override
public Flux<StateMachineEventResult<S, E>> sendEvents(Flux<Message<E>> events) {
return events.flatMap(e -> handleEvent(e));
return events.flatMap(this::handleEvent);
}

@Override
public Flux<StateMachineEventResult<S, E>> sendEvent(Mono<Message<E>> event) {
return event.flatMapMany(e -> handleEvent(e));
return event.flatMapMany(this::handleEvent);
}

@Override
public Mono<List<StateMachineEventResult<S, E>>> sendEventCollect(Mono<Message<E>> event) {
return event.flatMapMany(e -> handleEvent(e)).collectList();
return event.flatMapMany(this::handleEvent).collectList();
}

@Override
Expand Down Expand Up @@ -319,7 +319,7 @@ public Mono<Void> doOnComplete(StateContext<S, E> context) {

@Override
public Mono<Void> transit(Transition<S, E> t, StateContext<S, E> ctx, Message<E> message) {
return Mono.fromSupplier(() -> System.currentTimeMillis())
return Mono.fromSupplier(System::currentTimeMillis)
.doOnNext(now -> {
notifyTransitionStart(buildStateContext(Stage.TRANSITION_START, message, t, getRelayStateMachine()));
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public abstract class LifecycleObjectSupport

public LifecycleObjectSupport() {
this.reactiveLifecycleManager = new ReactiveLifecycleManager(
() -> doPreStartReactively(),
() -> doPreStopReactively(),
() -> doPostStartReactively(),
() -> doPostStopReactively()
this::doPreStartReactively,
this::doPreStopReactively,
this::doPostStartReactively,
this::doPostStopReactively
);
this.reactiveLifecycleManager.setOwner(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ public abstract class TreeTraverser<T> {

public final Iterable<T> postOrderTraversal(final T root) {
Assert.notNull(root, "root cannot be null");
return new Iterable<T>() {
@Override
public Iterator<T> iterator() {
return postOrderIterator(root);
}
};
return () -> postOrderIterator(root);
}

Iterator<T> postOrderIterator(T root) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*/
public abstract class AbstractTransition<S, E> implements Transition<S, E> {

private final static Log log = LogFactory.getLog(AbstractTransition.class);
private static final Log log = LogFactory.getLog(AbstractTransition.class);
protected final State<S, E> target;
protected final Collection<Function<StateContext<S, E>, Mono<Void>>> actions;
private final State<S, E> source;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@
*/
public class ZookeeperStateMachineEnsemble<S, E> extends StateMachineEnsembleObjectSupport<S, E> {

private final static Log log = LogFactory.getLog(ZookeeperStateMachineEnsemble.class);
private static final Log log = LogFactory.getLog(ZookeeperStateMachineEnsemble.class);
private final String uuid = UUID.randomUUID().toString();
private final static int DEFAULT_LOGSIZE = 32;
private final static String PATH_CURRENT = "current";
private final static String PATH_LOG = "log";
private final static String PATH_MEMBERS = "members";
private final static String PATH_MUTEX = "mutex";
private static final int DEFAULT_LOGSIZE = 32;
private static final String PATH_CURRENT = "current";
private static final String PATH_LOG = "log";
private static final String PATH_MEMBERS = "members";
private static final String PATH_MUTEX = "mutex";
private final CuratorFramework curatorClient;
private final String baseDataPath;
private final String statePath;
Expand Down Expand Up @@ -121,7 +121,7 @@ protected void onInit() throws Exception {

@Override
protected Mono<Void> doPreStartReactively() {
return Mono.fromRunnable(() -> doStart());
return Mono.fromRunnable(this::doStart);
}

protected void doStart() {
Expand Down Expand Up @@ -149,7 +149,7 @@ protected void doStart() {

@Override
protected Mono<Void> doPreStopReactively() {
return Mono.fromRunnable(() -> doStop());
return Mono.fromRunnable(this::doStop);
}

protected void doStop() {
Expand Down