diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/AbstractStateMachineFactory.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/AbstractStateMachineFactory.java index 85df3046..f6d20a84 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/AbstractStateMachineFactory.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/AbstractStateMachineFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -864,7 +864,7 @@ public abstract class AbstractStateMachineFactory extends LifecycleObjectS } DefaultExternalTransition transition = new DefaultExternalTransition(stateMap.get(source), stateMap.get(target), transitionData.getActions(), event, transitionData.getGuard(), trigger, - transitionData.getSecurityRule()); + transitionData.getSecurityRule(), transitionData.getName()); transitions.add(transition); } else if (transitionData.getKind() == TransitionKind.LOCAL) { @@ -874,12 +874,12 @@ public abstract class AbstractStateMachineFactory extends LifecycleObjectS } DefaultLocalTransition transition = new DefaultLocalTransition(stateMap.get(source), stateMap.get(target), transitionData.getActions(), event, transitionData.getGuard(), trigger, - transitionData.getSecurityRule()); + transitionData.getSecurityRule(), transitionData.getName()); transitions.add(transition); } else if (transitionData.getKind() == TransitionKind.INTERNAL) { DefaultInternalTransition transition = new DefaultInternalTransition(stateMap.get(source), transitionData.getActions(), event, transitionData.getGuard(), trigger, - transitionData.getSecurityRule()); + transitionData.getSecurityRule(), transitionData.getName()); transitions.add(transition); } } diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineTransitionBuilder.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineTransitionBuilder.java index c1fa85a9..2e736f49 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineTransitionBuilder.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/builders/StateMachineTransitionBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -176,17 +176,19 @@ public class StateMachineTransitionBuilder * @param guard the guard * @param kind the kind * @param securityRule the security rule + * @param name the name */ public void addTransition(S source, S target, S state, E event, Long period, Integer count, Collection, Mono>> actions, - Function, Mono> guard, TransitionKind kind, SecurityRule securityRule) { + Function, Mono> guard, TransitionKind kind, SecurityRule securityRule, + String name) { // if rule not given, get it from global if (securityRule == null) { @SuppressWarnings("unchecked") ConfigurationData config = getSharedObject(ConfigurationData.class); securityRule = config.getTransitionSecurityRule(); } - transitionData.add(new TransitionData<>(source, target, state, event, period, count, actions, guard, kind, securityRule)); + transitionData.add(new TransitionData<>(source, target, state, event, period, count, actions, guard, kind, securityRule, name)); } /** diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/AbstractTransitionConfigurer.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/AbstractTransitionConfigurer.java index ae9cdf87..2b8ed79f 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/AbstractTransitionConfigurer.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/AbstractTransitionConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,6 +53,7 @@ public abstract class AbstractTransitionConfigurer extends private final Collection, Mono>> actions = new ArrayList<>(); private Function, Mono> guard; private SecurityRule securityRule; + private String name; protected S getSource() { return source; @@ -94,6 +95,10 @@ public abstract class AbstractTransitionConfigurer extends return securityRule; } + protected String getName() { + return name; + } + protected void setSource(S source) { this.source = source; } @@ -156,4 +161,8 @@ public abstract class AbstractTransitionConfigurer extends securityRule.setExpression(expression); } + protected void setName(String name) { + this.name = name; + } + } diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultExternalTransitionConfigurer.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultExternalTransitionConfigurer.java index 145351b4..bb611d6a 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultExternalTransitionConfigurer.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultExternalTransitionConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ public class DefaultExternalTransitionConfigurer extends AbstractTransitio @Override public void configure(StateMachineTransitionBuilder builder) throws Exception { builder.addTransition(getSource(), getTarget(), getState(), getEvent(), getPeriod(), getCount(), getActions(), getGuard(), TransitionKind.EXTERNAL, - getSecurityRule()); + getSecurityRule(), getName()); } @Override @@ -127,4 +127,10 @@ public class DefaultExternalTransitionConfigurer extends AbstractTransitio return this; } + @Override + public ExternalTransitionConfigurer name(String name) { + setName(name); + return this; + } + } diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultInternalTransitionConfigurer.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultInternalTransitionConfigurer.java index 022dab11..5b3ee3ce 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultInternalTransitionConfigurer.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultInternalTransitionConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ public class DefaultInternalTransitionConfigurer extends AbstractTransitio @Override public void configure(StateMachineTransitionBuilder builder) throws Exception { builder.addTransition(getSource(), getTarget(), getState(), getEvent(), getPeriod(), getCount(), getActions(), getGuard(), TransitionKind.INTERNAL, - getSecurityRule()); + getSecurityRule(), getName()); } @Override @@ -121,4 +121,10 @@ public class DefaultInternalTransitionConfigurer extends AbstractTransitio return this; } + @Override + public InternalTransitionConfigurer name(String name) { + setName(name); + return this; + } + } diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultLocalTransitionConfigurer.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultLocalTransitionConfigurer.java index 724b0760..072d012c 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultLocalTransitionConfigurer.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/DefaultLocalTransitionConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ public class DefaultLocalTransitionConfigurer extends AbstractTransitionCo @Override public void configure(StateMachineTransitionBuilder builder) throws Exception { builder.addTransition(getSource(), getTarget(), getState(), getEvent(), getPeriod(), getCount(), getActions(), getGuard(), TransitionKind.LOCAL, - getSecurityRule()); + getSecurityRule(), getName()); } @Override @@ -126,4 +126,10 @@ public class DefaultLocalTransitionConfigurer extends AbstractTransitionCo return this; } + @Override + public LocalTransitionConfigurer name(String name) { + setName(name); + return this; + } + } diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/TransitionConfigurer.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/TransitionConfigurer.java index 8ce094fa..dec07458 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/TransitionConfigurer.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/configurers/TransitionConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -138,4 +138,13 @@ public interface TransitionConfigurer extends */ T secured(String expression); + /** + * Specify a name for this {@link Transition}. + * + * @param name the name + * @return configurer for chaining + * @param name + * @return + */ + T name(String name); } diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/TransitionData.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/TransitionData.java index e6aebf7f..3d2ebfcd 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/TransitionData.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/config/model/TransitionData.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,6 +41,7 @@ public class TransitionData { private final Function, Mono> guard; private final TransitionKind kind; private final SecurityRule securityRule; + private final String name; /** * Instantiates a new transition data. @@ -50,7 +51,7 @@ public class TransitionData { * @param event the event */ public TransitionData(S source, S target, E event) { - this(source, target, null, event, null, null, null, null, TransitionKind.EXTERNAL, null); + this(source, target, null, event, null, null, null, null, TransitionKind.EXTERNAL, null, null); } /** @@ -65,7 +66,23 @@ public class TransitionData { */ public TransitionData(S source, S target, E event, Collection, Mono>> actions, Function, Mono> guard, TransitionKind kind) { - this(source, target, null, event, null, null, actions, guard, kind, null); + this(source, target, null, event, null, null, actions, guard, kind, null, null); + } + + /** + * Instantiates a new transition data. + * + * @param source the source + * @param target the target + * @param event the event + * @param actions the actions + * @param guard the guard + * @param kind the kind + * @param name the name + */ + public TransitionData(S source, S target, E event, Collection, Mono>> actions, + Function, Mono> guard, TransitionKind kind, String name) { + this(source, target, null, event, null, null, actions, guard, kind, null, name); } /** @@ -82,7 +99,25 @@ public class TransitionData { public TransitionData(S source, S target, Long period, Integer count, Collection, Mono>> actions, Function, Mono> guard, TransitionKind kind) { - this(source, target, null, null, period, count, actions, guard, kind, null); + this(source, target, null, null, period, count, actions, guard, kind, null, null); + } + + /** + * Instantiates a new transition data. + * + * @param source the source + * @param target the target + * @param period the period + * @param count the count + * @param actions the actions + * @param guard the guard + * @param kind the kind + * @param name the name + */ + public TransitionData(S source, S target, Long period, Integer count, + Collection, Mono>> actions, + Function, Mono> guard, TransitionKind kind, String name) { + this(source, target, null, null, period, count, actions, guard, kind, null, name); } /** @@ -98,10 +133,11 @@ public class TransitionData { * @param guard the guard * @param kind the kind * @param securityRule the security rule + * @param name the name */ public TransitionData(S source, S target, S state, E event, Long period, Integer count, Collection, Mono>> actions, - Function, Mono> guard, TransitionKind kind, SecurityRule securityRule) { + Function, Mono> guard, TransitionKind kind, SecurityRule securityRule, String name) { this.source = source; this.target = target; this.state = state; @@ -112,6 +148,7 @@ public class TransitionData { this.guard = guard; this.kind = kind; this.securityRule = securityRule; + this.name = (name == null) ? "" : name; } /** @@ -203,4 +240,13 @@ public class TransitionData { public SecurityRule getSecurityRule() { return securityRule; } + + /** + * Gets the name, + * + * @return the name + */ + public String getName() { + return name; + } } diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/AbstractExternalTransition.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/AbstractExternalTransition.java index 44b2d24a..4c397ea9 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/AbstractExternalTransition.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/AbstractExternalTransition.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,24 @@ import reactor.core.publisher.Mono; public abstract class AbstractExternalTransition extends AbstractTransition { + /** + * Instantiates a new abstract external transition. + * + * @param source the source + * @param target the target + * @param actions the actions + * @param event the event + * @param guard the guard + * @param trigger the trigger + * @param securityRule the security rule + * @param name the name + */ + public AbstractExternalTransition(State source, State target, + Collection, Mono>> actions, E event, + Function, Mono> guard, Trigger trigger, SecurityRule securityRule, String name) { + super(source, target, actions, event, TransitionKind.EXTERNAL, guard, trigger, securityRule, name); + } + /** * Instantiates a new abstract external transition. * @@ -41,7 +59,7 @@ public abstract class AbstractExternalTransition extends AbstractTransitio public AbstractExternalTransition(State source, State target, Collection, Mono>> actions, E event, Function, Mono> guard, Trigger trigger, SecurityRule securityRule) { - super(source, target, actions, event, TransitionKind.EXTERNAL, guard, trigger, securityRule); + super(source, target, actions, event, TransitionKind.EXTERNAL, guard, trigger, securityRule, null); } /** diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/AbstractInternalTransition.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/AbstractInternalTransition.java index 2fb48c75..abb032bc 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/AbstractInternalTransition.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/AbstractInternalTransition.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,6 +54,23 @@ public class AbstractInternalTransition extends AbstractTransition { public AbstractInternalTransition(State source, Collection, Mono>> actions, E event, Function, Mono> guard, Trigger trigger, SecurityRule securityRule) { - super(source, source, actions, event, TransitionKind.INTERNAL, guard, trigger, securityRule); + super(source, source, actions, event, TransitionKind.INTERNAL, guard, trigger, securityRule, null); + } + + /** + * Instantiates a new abstract internal transition. + * + * @param source the source + * @param actions the actions + * @param event the event + * @param guard the guard + * @param trigger the trigger + * @param securityRule the security rule + * @param name the name + */ + public AbstractInternalTransition(State source, Collection, Mono>> actions, + E event, Function, Mono> guard, Trigger trigger, + SecurityRule securityRule, String name) { + super(source, source, actions, event, TransitionKind.INTERNAL, guard, trigger, securityRule, name); } } diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/AbstractLocalTransition.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/AbstractLocalTransition.java index 159a63e8..5f09e894 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/AbstractLocalTransition.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/AbstractLocalTransition.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,6 +57,24 @@ public class AbstractLocalTransition extends AbstractTransition { public AbstractLocalTransition(State source, State target, Collection, Mono>> actions, E event, Function, Mono> guard, Trigger trigger, SecurityRule securityRule) { - super(source, target, actions, event, TransitionKind.LOCAL, guard, trigger, securityRule); + super(source, target, actions, event, TransitionKind.LOCAL, guard, trigger, securityRule, null); + } + + /** + * Instantiates a new abstract local transition. + * + * @param source the source + * @param target the target + * @param actions the actions + * @param event the event + * @param guard the guard + * @param trigger the trigger + * @param securityRule the security rule + * @param name the name + */ + public AbstractLocalTransition(State source, State target, + Collection, Mono>> actions, E event, + Function, Mono> guard, Trigger trigger, SecurityRule securityRule, String name) { + super(source, target, actions, event, TransitionKind.LOCAL, guard, trigger, securityRule, name); } } diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/AbstractTransition.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/AbstractTransition.java index a7867f99..c54a2f00 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/AbstractTransition.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/AbstractTransition.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,6 +49,7 @@ public abstract class AbstractTransition implements Transition { private final Function, Mono> guard; private final Trigger trigger; private final SecurityRule securityRule; + private final String name; private CompositeActionListener actionListener; /** @@ -65,7 +66,7 @@ public abstract class AbstractTransition implements Transition { public AbstractTransition(State source, State target, Collection, Mono>> actions, E event, TransitionKind kind, Function, Mono> guard, Trigger trigger) { - this(source, target, actions, event, kind, guard, trigger, null); + this(source, target, actions, event, kind, guard, trigger, null, null); } /** @@ -82,7 +83,7 @@ public abstract class AbstractTransition implements Transition { */ public AbstractTransition(State source, State target, Collection, Mono>> actions, E event, TransitionKind kind, - Function, Mono> guard, Trigger trigger, SecurityRule securityRule) { + Function, Mono> guard, Trigger trigger, SecurityRule securityRule, String name) { Assert.notNull(kind, "Transition type must be set"); this.source = source; this.target = target; @@ -91,6 +92,7 @@ public abstract class AbstractTransition implements Transition { this.guard = guard; this.trigger = trigger; this.securityRule = securityRule; + this.name = (name == null) ? "" : name; } @Override @@ -135,6 +137,11 @@ public abstract class AbstractTransition implements Transition { return target; } + @Override + public String getName() { + return name; + } + @Override public Collection, Mono>> getActions() { return actions; diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/DefaultExternalTransition.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/DefaultExternalTransition.java index a03c631e..78ebeb93 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/DefaultExternalTransition.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/DefaultExternalTransition.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,4 +59,22 @@ public class DefaultExternalTransition extends AbstractExternalTransition< Function, Mono> guard, Trigger trigger, SecurityRule securityRule) { super(source, target, actions, event, guard, trigger, securityRule); } + + /** + * Instantiates a new default external transition. + * + * @param source the source + * @param target the target + * @param actions the actions + * @param event the event + * @param guard the guard + * @param trigger the trigger + * @param securityRule the security rule + * @param name the name + */ + public DefaultExternalTransition(State source, State target, + Collection, Mono>> actions, E event, + Function, Mono> guard, Trigger trigger, SecurityRule securityRule, String name) { + super(source, target, actions, event, guard, trigger, securityRule, name); + } } diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/DefaultInternalTransition.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/DefaultInternalTransition.java index 6aa1ddd4..97aae8bb 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/DefaultInternalTransition.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/DefaultInternalTransition.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,4 +56,21 @@ public class DefaultInternalTransition extends AbstractInternalTransition< SecurityRule securityRule) { super(source, actions, event, guard, trigger, securityRule); } + + /** + * Instantiates a new default internal transition. + * + * @param source the source + * @param actions the actions + * @param event the event + * @param guard the guard + * @param trigger the trigger + * @param securityRule the security rule + * @param name the name + */ + public DefaultInternalTransition(State source, Collection, Mono>> actions, + E event, Function, Mono> guard, Trigger trigger, + SecurityRule securityRule, String name) { + super(source, actions, event, guard, trigger, securityRule, name); + } } diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/DefaultLocalTransition.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/DefaultLocalTransition.java index 8feaa8de..41a13236 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/DefaultLocalTransition.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/DefaultLocalTransition.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,6 +60,24 @@ public class DefaultLocalTransition extends AbstractLocalTransition super(source, target, actions, event, guard, trigger, securityRule); } + /** + * Instantiates a new default local transition. + * + * @param source the source + * @param target the target + * @param actions the actions + * @param event the event + * @param guard the guard + * @param trigger the trigger + * @param securityRule the security rule + * @param name the name + */ + public DefaultLocalTransition(State source, State target, + Collection, Mono>> actions, E event, + Function, Mono> guard, Trigger trigger, SecurityRule securityRule, String name) { + super(source, target, actions, event, guard, trigger, securityRule, name); + } + @Override public String toString() { return "DefaultLocalTransition [getSource()=" + getSource() + ", getTarget()=" + getTarget() + "]"; diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/InitialTransition.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/InitialTransition.java index d9138f1a..51921018 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/InitialTransition.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/InitialTransition.java @@ -40,7 +40,7 @@ public class InitialTransition extends AbstractTransition { * @param target the target */ public InitialTransition(State target) { - super(null, target, null, null, TransitionKind.INITIAL, null, null, null); + super(null, target, null, null, TransitionKind.INITIAL, null, null, null, null); } /** @@ -51,7 +51,7 @@ public class InitialTransition extends AbstractTransition { */ public InitialTransition(State target, Function, Mono> action) { super(null, target, action != null ? Collections.singleton(action) : null, null, TransitionKind.INITIAL, null, - null, null); + null, null, null); } /** @@ -61,7 +61,7 @@ public class InitialTransition extends AbstractTransition { * @param actions the actions */ public InitialTransition(State target, Collection, Mono>> actions) { - super(null, target, actions, null, TransitionKind.INITIAL, null, null, null); + super(null, target, actions, null, TransitionKind.INITIAL, null, null, null, null); } @Override diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/Transition.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/Transition.java index 3a241d4d..17fa2859 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/Transition.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/Transition.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 the original author or authors. + * Copyright 2015-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -102,6 +102,13 @@ public interface Transition { */ SecurityRule getSecurityRule(); + /** + * Gets the name. + * + * @return the name + */ + String getName(); + /** * Adds the action listener. * diff --git a/spring-statemachine-core/src/test/java/org/springframework/statemachine/config/model/StateMachineModelTests.java b/spring-statemachine-core/src/test/java/org/springframework/statemachine/config/model/StateMachineModelTests.java index e95839b4..b994495b 100644 --- a/spring-statemachine-core/src/test/java/org/springframework/statemachine/config/model/StateMachineModelTests.java +++ b/spring-statemachine-core/src/test/java/org/springframework/statemachine/config/model/StateMachineModelTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 the original author or authors. + * Copyright 2016-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ public class StateMachineModelTests { Collection> transitions = new ArrayList<>(); - TransitionData transitionData1 = new TransitionData("S1", "S2", null, "E1", null, null, null, null, TransitionKind.EXTERNAL, null); + TransitionData transitionData1 = new TransitionData("S1", "S2", null, "E1", null, null, null, null, TransitionKind.EXTERNAL, null, ""); transitions.add(transitionData1); Map>> choices = new HashMap<>(); Map>> junctions = new HashMap<>(); diff --git a/spring-statemachine-core/src/test/java/org/springframework/statemachine/support/StateContextExpressionMethodsTests.java b/spring-statemachine-core/src/test/java/org/springframework/statemachine/support/StateContextExpressionMethodsTests.java index 7567b70b..be7064fb 100644 --- a/spring-statemachine-core/src/test/java/org/springframework/statemachine/support/StateContextExpressionMethodsTests.java +++ b/spring-statemachine-core/src/test/java/org/springframework/statemachine/support/StateContextExpressionMethodsTests.java @@ -155,6 +155,11 @@ public class StateContextExpressionMethodsTests { @Override public void removeActionListener(ActionListener listener) { } + + @Override + public String getName() { + return ""; + } } private static class MockStatemachine implements StateMachine { diff --git a/spring-statemachine-uml/src/main/java/org/springframework/statemachine/uml/support/UmlModelParser.java b/spring-statemachine-uml/src/main/java/org/springframework/statemachine/uml/support/UmlModelParser.java index 1077568f..bcb15bde 100644 --- a/spring-statemachine-uml/src/main/java/org/springframework/statemachine/uml/support/UmlModelParser.java +++ b/spring-statemachine-uml/src/main/java/org/springframework/statemachine/uml/support/UmlModelParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 the original author or authors. + * Copyright 2016-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -432,13 +432,13 @@ public class UmlModelParser { addTransitionData(new TransitionData(resolveName(transition.getSource()), cprentries.get(0).getName(), signal.getName(), UmlUtils.resolveTransitionActionFunctions(transition, resolver), Guards.from(guard), - UmlUtils.mapUmlTransitionType(transition))); + UmlUtils.mapUmlTransitionType(transition), transition.getName())); } } else { addTransitionData(new TransitionData(resolveName(transition.getSource()), resolveName(transition.getTarget()), signal.getName(), UmlUtils.resolveTransitionActionFunctions(transition, resolver), Guards.from(guard), - UmlUtils.mapUmlTransitionType(transition))); + UmlUtils.mapUmlTransitionType(transition), transition.getName())); } } } else if (event instanceof TimeEvent) { @@ -451,7 +451,7 @@ public class UmlModelParser { } addTransitionData(new TransitionData(resolveName(transition.getSource()), resolveName(transition.getTarget()), period, count, UmlUtils.resolveTransitionActionFunctions(transition, resolver), - Guards.from(guard), UmlUtils.mapUmlTransitionType(transition))); + Guards.from(guard), UmlUtils.mapUmlTransitionType(transition), transition.getName())); } } } @@ -461,7 +461,7 @@ public class UmlModelParser { addTransitionData(new TransitionData(resolveName(transition.getSource()), resolveName(transition.getTarget()), null, UmlUtils.resolveTransitionActionFunctions(transition, resolver), - Guards.from(resolveGuard(transition)), UmlUtils.mapUmlTransitionType(transition))); + Guards.from(resolveGuard(transition)), UmlUtils.mapUmlTransitionType(transition), transition.getName())); } } }