diff --git a/src/main/java/dev/struchkov/example/debugger/three/Entity.java b/src/main/java/dev/struchkov/example/debugger/three/Entity.java index d924e48..e3d82c8 100644 --- a/src/main/java/dev/struchkov/example/debugger/three/Entity.java +++ b/src/main/java/dev/struchkov/example/debugger/three/Entity.java @@ -20,4 +20,5 @@ public class Entity { public String toString() { return field; } + } diff --git a/src/main/java/dev/struchkov/example/debugger/threenojava/Entity.java b/src/main/java/dev/struchkov/example/debugger/threenojava/Entity.java new file mode 100644 index 0000000..d99b3bd --- /dev/null +++ b/src/main/java/dev/struchkov/example/debugger/threenojava/Entity.java @@ -0,0 +1,15 @@ +package dev.struchkov.example.debugger.threenojava; + +public class Entity { + + public String field; + + public Entity(String field) { + this.field = field; + } + + @Override + public String toString() { + return field; + } +} diff --git a/src/main/java/dev/struchkov/example/debugger/threenojava/ExampleThreeNoJava.java b/src/main/java/dev/struchkov/example/debugger/threenojava/ExampleThreeNoJava.java new file mode 100644 index 0000000..dd7429c --- /dev/null +++ b/src/main/java/dev/struchkov/example/debugger/threenojava/ExampleThreeNoJava.java @@ -0,0 +1,18 @@ +package dev.struchkov.example.debugger.threenojava; + +public class ExampleThreeNoJava { + + public static void main(String[] args) { + final ThirdService thirdService = new ThirdService(); + final SecondService secondService = new SecondService(thirdService); + final FirstService firstService = new FirstService(secondService); + + final Entity entity = new Entity("Dasha"); + firstService.processing(entity); + + System.out.println(); + System.out.println(entity); + System.out.println(); + } + +} diff --git a/src/main/java/dev/struchkov/example/debugger/threenojava/FirstService.java b/src/main/java/dev/struchkov/example/debugger/threenojava/FirstService.java new file mode 100644 index 0000000..db38405 --- /dev/null +++ b/src/main/java/dev/struchkov/example/debugger/threenojava/FirstService.java @@ -0,0 +1,26 @@ +package dev.struchkov.example.debugger.threenojava; + +import dev.struchkov.example.debugger.box.SurpriseException; + +public class FirstService { + + private final SecondService secondService; + + public FirstService(SecondService secondService) { + this.secondService = secondService; + } + + public void processing(Entity entity) { + valid(entity.field); + secondService.processing(entity); + final String newField = entity.field; + entity.field = "\033[31;1;4m" + newField + "!\033[0m"; + } + + private void valid(String field) { + if (field.equals("Masha")) { + throw new SurpriseException("Ошибочка вышла"); + } + } + +} diff --git a/src/main/java/dev/struchkov/example/debugger/threenojava/SecondService.java b/src/main/java/dev/struchkov/example/debugger/threenojava/SecondService.java new file mode 100644 index 0000000..0b1e6b4 --- /dev/null +++ b/src/main/java/dev/struchkov/example/debugger/threenojava/SecondService.java @@ -0,0 +1,17 @@ +package dev.struchkov.example.debugger.threenojava; + +public class SecondService { + + private final ThirdService thirdService; + + public SecondService(ThirdService thirdService) { + this.thirdService = thirdService; + } + + public void processing(Entity entity) { + thirdService.processing(entity); + final String field = entity.field; + entity.field = "Nice to " + field; + } + +} diff --git a/src/main/java/dev/struchkov/example/debugger/threenojava/ThirdService.java b/src/main/java/dev/struchkov/example/debugger/threenojava/ThirdService.java new file mode 100644 index 0000000..494765c --- /dev/null +++ b/src/main/java/dev/struchkov/example/debugger/threenojava/ThirdService.java @@ -0,0 +1,9 @@ +package dev.struchkov.example.debugger.threenojava; + +public class ThirdService { + + public void processing(Entity entity) { + entity.field = "meet you " + entity.field; + } + +} diff --git a/src/main/java/dev/struchkov/example/debugger/two/FooService.java b/src/main/java/dev/struchkov/example/debugger/two/FooService.java index 5898dd0..2f5a351 100644 --- a/src/main/java/dev/struchkov/example/debugger/two/FooService.java +++ b/src/main/java/dev/struchkov/example/debugger/two/FooService.java @@ -7,12 +7,6 @@ public class FooService { public void example() { for (int i = 0; i < 1000; i++) { SurpriseBox.surpriseOne(i); - -// try { -// SurpriseBox.surpriseOne(i); -// } catch (SurpriseException e) { -// System.err.println(e.getMessage()); -// } } }