From 1d94d78eda6527e7fb46e3f0a645dae7e491337a Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Sat, 19 Feb 2022 08:46:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=BC=D0=B5=D1=80=D1=8B=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D0=B4=D0=B5=D0=B1=D0=B0=D0=B3=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/debugger/three/Entity.java | 1 + .../example/debugger/threenojava/Entity.java | 15 +++++++++++ .../threenojava/ExampleThreeNoJava.java | 18 +++++++++++++ .../debugger/threenojava/FirstService.java | 26 +++++++++++++++++++ .../debugger/threenojava/SecondService.java | 17 ++++++++++++ .../debugger/threenojava/ThirdService.java | 9 +++++++ .../example/debugger/two/FooService.java | 6 ----- 7 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 src/main/java/dev/struchkov/example/debugger/threenojava/Entity.java create mode 100644 src/main/java/dev/struchkov/example/debugger/threenojava/ExampleThreeNoJava.java create mode 100644 src/main/java/dev/struchkov/example/debugger/threenojava/FirstService.java create mode 100644 src/main/java/dev/struchkov/example/debugger/threenojava/SecondService.java create mode 100644 src/main/java/dev/struchkov/example/debugger/threenojava/ThirdService.java 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()); -// } } }