Добавил примеры для дебага

This commit is contained in:
Struchkov Mark 2022-02-19 08:46:20 +03:00
parent 907f7552e0
commit 1d94d78eda
7 changed files with 86 additions and 6 deletions

View File

@ -20,4 +20,5 @@ public class Entity {
public String toString() {
return field;
}
}

View File

@ -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;
}
}

View File

@ -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();
}
}

View File

@ -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("Ошибочка вышла");
}
}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,9 @@
package dev.struchkov.example.debugger.threenojava;
public class ThirdService {
public void processing(Entity entity) {
entity.field = "meet you " + entity.field;
}
}

View File

@ -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());
// }
}
}