From 2a9413ab460d05eda486df06a500c28e9308b52e Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Fri, 15 Jul 2022 08:13:34 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=B4=20=D0=BF=D0=B5=D1=80=D0=B2=D0=BE=D0=B9=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BF=D1=8B=D1=82=D0=BA=D0=B8=20=D0=BB=D0=B8=D0=BD=D0=B8?= =?UTF-8?q?=D0=B2=D0=BE=D0=B9=20=D0=B8=D0=BD=D0=B8=D1=86=D0=B8=D0=B0=D0=BB?= =?UTF-8?q?=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot-context/pom.xml | 2 +- .../context/domain/UnitDefinition.java | 9 ------ .../context/domain/annotation/Unit.java | 2 -- bot-core/pom.xml | 2 +- .../godfather/core/StorylineMaker.java | 32 ------------------- pom.xml | 4 +-- 6 files changed, 4 insertions(+), 47 deletions(-) diff --git a/bot-context/pom.xml b/bot-context/pom.xml index 34d02fa..ca43f67 100644 --- a/bot-context/pom.xml +++ b/bot-context/pom.xml @@ -6,7 +6,7 @@ dev.struchkov.godfather godfather-bot - 0.0.10 + 0.0.11 bot-context diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/UnitDefinition.java b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/UnitDefinition.java index e933d3d..a361bbc 100644 --- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/UnitDefinition.java +++ b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/UnitDefinition.java @@ -12,7 +12,6 @@ public class UnitDefinition { private String name; private Object objectConfig; private Method method; - private boolean lazy; public String getName() { return name; @@ -66,12 +65,4 @@ public class UnitDefinition { this.dependentUnits.addAll(dependentUnitNames); } - public boolean isLazy() { - return lazy; - } - - public void setLazy(boolean lazy) { - this.lazy = lazy; - } - } diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/annotation/Unit.java b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/annotation/Unit.java index 06dcc80..3a1143b 100644 --- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/annotation/Unit.java +++ b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/annotation/Unit.java @@ -13,8 +13,6 @@ public @interface Unit { String value() default ""; - boolean lazy() default false; - boolean mainUnit() default false; } diff --git a/bot-core/pom.xml b/bot-core/pom.xml index 4e919e4..6cb70bb 100644 --- a/bot-core/pom.xml +++ b/bot-core/pom.xml @@ -6,7 +6,7 @@ dev.struchkov.godfather godfather-bot - 0.0.10 + 0.0.11 bot-core diff --git a/bot-core/src/main/java/dev/struchkov/godfather/core/StorylineMaker.java b/bot-core/src/main/java/dev/struchkov/godfather/core/StorylineMaker.java index d35afb8..b0b59ef 100644 --- a/bot-core/src/main/java/dev/struchkov/godfather/core/StorylineMaker.java +++ b/bot-core/src/main/java/dev/struchkov/godfather/core/StorylineMaker.java @@ -31,7 +31,6 @@ public class StorylineMaker { private final Map unitDefinitions = new HashMap<>(); private final Map unitMap = new HashMap<>(); - private final Set lazyUnits = new HashSet<>(); private final Set mainUnits = new HashSet<>(); public StorylineMaker(List unitConfigurations) { @@ -50,7 +49,6 @@ public class StorylineMaker { generateUnitDefinitions(); try { createUnitMap(); - createLazy(); final Set mainUnit = getMainUnit(); return new Storyline(mainUnit, unitMap); } catch (IllegalAccessException | InvocationTargetException e) { @@ -66,43 +64,18 @@ public class StorylineMaker { .collect(Collectors.toSet()); } - private void createLazy() throws IllegalAccessException, InvocationTargetException { - final List lazyDefinitions = unitDefinitions.values().stream() - .filter(UnitDefinition::isLazy) - .toList(); - for (UnitDefinition lazyDefinition : lazyDefinitions) { - final MainUnit lazyUnit = createUnit(lazyDefinition); - unitMap.put(lazyDefinition.getName(), lazyUnit); - for (String dependentUnit : lazyDefinition.getDependentUnits()) { - final MainUnit mainUnit = unitMap.get(dependentUnit); - final Set nextUnits = mainUnit.getNextUnits(); - if (nextUnits != null) { - nextUnits.add(lazyUnit); - } - } - } - } - private void createUnitMap() throws IllegalAccessException, InvocationTargetException { for (UnitDefinition unitDefinition : unitDefinitions.values()) { if (!unitMap.containsKey(unitDefinition.getName())) { final Set nextUnitNames = unitDefinition.getNextUnitNames(); if (nextUnitNames.isEmpty() || unitMap.keySet().containsAll(nextUnitNames)) { createUnit(unitDefinition); - } else if (unitDefinition.isLazy()) { - createLazyUnit(unitDefinition); } } } } - private void createLazyUnit(UnitDefinition unitDefinition) { - final String unitName = unitDefinition.getName(); - unitMap.put(unitName, LazyUnit.create(unitName, unitDefinition)); - } - private MainUnit createUnit(UnitDefinition unitDefinition) throws IllegalAccessException, InvocationTargetException { - final Object objectConfig = unitDefinition.getObjectConfig(); final String currentUnitName = unitDefinition.getName(); final Method method = unitDefinition.getMethod(); @@ -118,7 +91,6 @@ public class StorylineMaker { unitMap.put(currentUnitName, newUnit); final Set dependentUnitsName = unitDefinition.getDependentUnits(); - dependentUnitsName.removeAll(lazyUnits); for (String dependentUnitName : dependentUnitsName) { final Set dependentNextUnitNames = unitDefinitions.get(dependentUnitName).getNextUnitNames(); if (unitMap.keySet().containsAll(dependentNextUnitNames)) { @@ -145,11 +117,7 @@ public class StorylineMaker { unitDefinition.setName(unitName); unitDefinition.setMethod(method); unitDefinition.setObjectConfig(config); - unitDefinition.setLazy(unitConfig.lazy()); - if (unitConfig.lazy()) { - lazyUnits.add(unitName); - } if (unitConfig.mainUnit()) { mainUnits.add(unitName); } diff --git a/pom.xml b/pom.xml index bf9c914..4ff8941 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ dev.struchkov.godfather godfather-bot - 0.0.10 + 0.0.11 pom @@ -32,7 +32,7 @@ UTF-8 UTF-8 - 0.0.10 + 0.0.11 ${godfather.ver} ${godfather.ver}