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 a8fc99af..52105b73 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. @@ -886,7 +886,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) { @@ -896,12 +896,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 168c5a90..47cb4bb7 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-2016 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,14 +176,14 @@ public class StateMachineTransitionBuilder * @param securityRule the security rule */ public void addTransition(S source, S target, S state, E event, Long period, Integer count, Collection> actions, - Guard guard, TransitionKind kind, SecurityRule securityRule) { + Guard 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 2f5580ba..7f809558 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-2016 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. @@ -48,6 +48,7 @@ public abstract class AbstractTransitionConfigurer extends private final Collection> actions = new ArrayList<>(); private Guard guard; private SecurityRule securityRule; + private String name; protected S getSource() { return source; @@ -88,6 +89,10 @@ public abstract class AbstractTransitionConfigurer extends protected SecurityRule getSecurityRule() { return securityRule; } + + protected String getName() { + return name; + } protected void setSource(S source) { this.source = source; @@ -142,5 +147,9 @@ 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 0fd1a36d..52a091c7 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 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. @@ -39,7 +39,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 @@ -116,4 +116,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 d9a4d354..053832ae 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 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. @@ -39,7 +39,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 @@ -110,4 +110,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 27e0f6b9..67409587 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 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. @@ -38,7 +38,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 @@ -114,5 +114,11 @@ public class DefaultLocalTransitionConfigurer extends AbstractTransitionCo setSecurityRule(expression); 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 efdaf599..46d2ae4d 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-2016 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. @@ -126,4 +126,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 1e09f88e..b7e5e7e2 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-2016 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. @@ -39,6 +39,7 @@ public class TransitionData { private final Guard guard; private final TransitionKind kind; private final SecurityRule securityRule; + private final String name; /** * Instantiates a new transition data. @@ -48,7 +49,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); } /** @@ -63,7 +64,23 @@ public class TransitionData { */ public TransitionData(S source, S target, E event, Collection> actions, Guard 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> actions, + Guard guard, TransitionKind kind, String name) { + this(source, target, null, event, null, null, actions, guard, kind, null, name); } /** @@ -79,7 +96,41 @@ public class TransitionData { */ public TransitionData(S source, S target, Long period, Integer count, Collection> actions, Guard 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> actions, + Guard guard, TransitionKind kind, String name) { + this(source, target, null, null, period, count, actions, guard, kind, null, name); + } + + /** + * 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 securityRule the security rule + */ + public TransitionData(S source, S target, Long period, Integer count, Collection> actions, + Guard guard, TransitionKind kind, SecurityRule securityRule) { + this(source, target, null, null, period, count, actions, guard, kind, securityRule, null); } /** @@ -95,9 +146,10 @@ 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> actions, - Guard guard, TransitionKind kind, SecurityRule securityRule) { + Guard guard, TransitionKind kind, SecurityRule securityRule, String name) { this.source = source; this.target = target; this.state = state; @@ -108,6 +160,7 @@ public class TransitionData { this.guard = guard; this.kind = kind; this.securityRule = securityRule; + this.name = (name == null) ? "" : name; } /** @@ -199,4 +252,8 @@ public class TransitionData { public SecurityRule getSecurityRule() { return securityRule; } + + 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 4e349bc7..89254a30 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 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. @@ -25,6 +25,23 @@ import java.util.Collection; public abstract class AbstractExternalTransition extends AbstractTransition implements Transition { + /** + * 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> actions, + E event, Guard guard, Trigger trigger, SecurityRule securityRule, String name) { + super(source, target, actions, event, TransitionKind.EXTERNAL, guard, trigger, securityRule, name); + } + /** * Instantiates a new abstract external transition. * 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 a8d141f4..113f8c3a 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 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,4 +53,20 @@ public class AbstractInternalTransition extends AbstractTransition i Trigger trigger, SecurityRule securityRule) { super(source, source, actions, event, TransitionKind.INTERNAL, guard, trigger, securityRule); } + + /** + * 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> actions, E event, Guard 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 65449099..ffe9bd94 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 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. @@ -55,4 +55,21 @@ public class AbstractLocalTransition extends AbstractTransition impl Guard guard, Trigger trigger, SecurityRule securityRule) { super(source, target, actions, event, TransitionKind.LOCAL, guard, trigger, securityRule); } + + /** + * 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> actions, E event, + Guard 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 50f386c9..e26fb90c 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-2018 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. @@ -47,6 +47,7 @@ public abstract class AbstractTransition implements Transition { private final Guard guard; private final Trigger trigger; private final SecurityRule securityRule; + private final String name; private CompositeActionListener actionListener; /** @@ -62,7 +63,23 @@ public abstract class AbstractTransition implements Transition { */ public AbstractTransition(State source, State target, Collection> actions, E event, TransitionKind kind, Guard guard, Trigger trigger) { - this(source, target, actions, event, kind, guard, trigger, null); + this(source, target, actions, event, kind, guard, trigger, null, null); + } + + /** + * Instantiates a new abstract transition. + * + * @param source the source + * @param target the target + * @param actions the actions + * @param event the event + * @param kind the kind + * @param guard the guard + * @param trigger the trigger + */ + public AbstractTransition(State source, State target, Collection> actions, E event, TransitionKind kind, + Guard guard, Trigger trigger, SecurityRule securityRule) { + this(source, target, actions, event, kind, guard, trigger, securityRule, null); } /** @@ -78,7 +95,7 @@ public abstract class AbstractTransition implements Transition { * @param securityRule the security rule */ public AbstractTransition(State source, State target, Collection> actions, E event, TransitionKind kind, - Guard guard, Trigger trigger, SecurityRule securityRule) { + Guard guard, Trigger trigger, SecurityRule securityRule, String name) { Assert.notNull(kind, "Transition type must be set"); this.source = source; this.target = target; @@ -87,6 +104,7 @@ public abstract class AbstractTransition implements Transition { this.guard = guard; this.trigger = trigger; this.securityRule = securityRule; + this.name = (name == null) ? "" : name; } @Override @@ -134,6 +152,11 @@ public abstract class AbstractTransition implements Transition { public State getTarget() { return target; } + + @Override + public String getName() { + return name; + } @Override public Collection> getActions() { 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 2d1f6bc6..997584e2 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 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. @@ -39,7 +39,7 @@ public class DefaultExternalTransition extends AbstractExternalTransition< Guard guard, Trigger trigger) { super(source, target, actions, event, guard, trigger); } - + /** * Instantiates a new default external transition. * @@ -55,4 +55,21 @@ public class DefaultExternalTransition extends AbstractExternalTransition< Guard 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> actions, E event, + Guard 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 a481e5f7..bbdd5cfc 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 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,4 +53,20 @@ public class DefaultInternalTransition extends AbstractInternalTransition< Trigger trigger, 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> actions, E event, Guard 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 3c059e2a..f7dfed7c 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-2016 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,6 +56,23 @@ 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> actions, E event, + Guard 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/Transition.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/transition/Transition.java index 82d9eb50..fed12878 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-2018 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. @@ -99,6 +99,13 @@ public interface Transition { * @return the security rule */ 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 153f5e3d..513a1df4 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 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. @@ -68,7 +68,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 2c3f3105..178a542a 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 @@ -1,5 +1,5 @@ /* - * Copyright 2015-2018 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. @@ -151,6 +151,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 bec2a46c..45c059d7 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. @@ -425,12 +425,12 @@ public class UmlModelParser { if (cprentries != null && cprentries.size() == 1) { addTransitionData(new TransitionData(resolveName(transition.getSource()), cprentries.get(0).getName(), signal.getName(), UmlUtils.resolveTransitionActions(transition, resolver), - guard, UmlUtils.mapUmlTransitionType(transition))); + guard, UmlUtils.mapUmlTransitionType(transition), transition.getName())); } } else { addTransitionData(new TransitionData(resolveName(transition.getSource()), resolveName(transition.getTarget()), signal.getName(), UmlUtils.resolveTransitionActions(transition, resolver), - guard, UmlUtils.mapUmlTransitionType(transition))); + guard, UmlUtils.mapUmlTransitionType(transition), transition.getName())); } } } else if (event instanceof TimeEvent) { @@ -443,7 +443,7 @@ public class UmlModelParser { } addTransitionData(new TransitionData(resolveName(transition.getSource()), resolveName(transition.getTarget()), period, count, UmlUtils.resolveTransitionActions(transition, resolver), - guard, UmlUtils.mapUmlTransitionType(transition))); + guard, UmlUtils.mapUmlTransitionType(transition), transition.getName())); } } } @@ -452,7 +452,7 @@ public class UmlModelParser { if (shouldCreateAnonymousTransition(transition)) { addTransitionData(new TransitionData(resolveName(transition.getSource()), resolveName(transition.getTarget()), null, UmlUtils.resolveTransitionActions(transition, resolver), resolveGuard(transition), - UmlUtils.mapUmlTransitionType(transition))); + UmlUtils.mapUmlTransitionType(transition), transition.getName())); } } }