mirror of
https://github.com/Example-uPagge/debugger.git
synced 2024-06-14 11:22:32 +03:00
Добавил примеры для дебага
This commit is contained in:
@@ -20,4 +20,5 @@ public class Entity {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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("Ошибочка вышла");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package dev.struchkov.example.debugger.threenojava;
|
||||||
|
|
||||||
|
public class ThirdService {
|
||||||
|
|
||||||
|
public void processing(Entity entity) {
|
||||||
|
entity.field = "meet you " + entity.field;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,12 +7,6 @@ public class FooService {
|
|||||||
public void example() {
|
public void example() {
|
||||||
for (int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
SurpriseBox.surpriseOne(i);
|
SurpriseBox.surpriseOne(i);
|
||||||
|
|
||||||
// try {
|
|
||||||
// SurpriseBox.surpriseOne(i);
|
|
||||||
// } catch (SurpriseException e) {
|
|
||||||
// System.err.println(e.getMessage());
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user