Skip to content

Commit

Permalink
Improve READMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanQed committed Feb 10, 2024
1 parent 935a9e7 commit b5a3308
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 60 deletions.
54 changes: 29 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,31 +375,35 @@ Now, having the above set, the framework creates the "schemes" of the injection.
For example, for the example above, it would look like this:

```Java
var service1=Artifact.of(Service1.class);
var service2=Artifact.of(Service2.class);
var app=Artifact.of(App.class);
var service1Scheme=new ClassScheme(
Service1.class,
new ConstructorScheme(Service1.class.getConstructor(),Set.of(),new Artifact[0]),
Set.of(),
Set.of()
);
var service2Scheme=new ClassScheme(
Service2.class,
new ConstructorScheme(Service2.class.getConstructor(),Set.of(),new Artifact[0]),
Set.of(),
Set.of()
);
var appScheme=new ClassScheme(
App.class,
new ConstructorScheme(
App.class.getConstructor(Service1.class,Service2.class),
Set.of(service1,service2),
new Artifact[]{service1,service2}
),
Set.of(),
Set.of()
);
public class Main {
public static void main(String[] args) {
var service1 = Artifact.of(Service1.class);
var service2 = Artifact.of(Service2.class);
var app = Artifact.of(App.class);
var service1Scheme = new ClassScheme(
Service1.class,
new ConstructorScheme(Service1.class.getConstructor(), Set.of(), new Artifact[0]),
Set.of(),
Set.of()
);
var service2Scheme = new ClassScheme(
Service2.class,
new ConstructorScheme(Service2.class.getConstructor(), Set.of(), new Artifact[0]),
Set.of(),
Set.of()
);
var appScheme = new ClassScheme(
App.class,
new ConstructorScheme(
App.class.getConstructor(Service1.class, Service2.class),
Set.of(service1, service2),
new Artifact[]{service1, service2}
),
Set.of(),
Set.of()
);
}
}
```

In the framework, the SchemeFactory is responsible for creating the schema,
Expand Down
87 changes: 52 additions & 35 deletions README_RUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,25 @@ public class Main {
System.out.println(provider.instantiate(App.class));
System.out.println(provider.instantiate(App.class));
}

public static final class Service1 {
@Override
public String toString() {
return "Service1, " + hashCode();
}
}

public static final class Service2 {
@Override
public String toString() {
return "Service2, " + hashCode();
}
}

public static final class App {
final Service1 s1;
final Service2 s2;

public App(Service1 s1, Service2 s2) {
this.s1 = s1;
this.s2 = s2;
Expand Down Expand Up @@ -132,6 +132,7 @@ s2=Service2, 377478451

```Java
import io.github.amayaframework.di.CheckedProviderBuilder;

import java.util.List;

public class Main {
Expand Down Expand Up @@ -188,13 +189,17 @@ public class Main {
System.out.println(provider.instantiate(App.class).s1);
}

public static final class Service1 {}
public static final class Service1 {
}

public static final class Service2 {}
public static final class Service2 {
}

public static final class Service3 {}
public static final class Service3 {
}

public static final class Service4 {}
public static final class Service4 {
}

public static final class App {
@Inject
Expand Down Expand Up @@ -236,6 +241,7 @@ io.github.amayaframework.di.Main$Service1@1d29cf23

```Java
import io.github.amayaframework.di.CheckedProviderBuilder;

import java.util.List;

public class Main {
Expand Down Expand Up @@ -294,11 +300,13 @@ public class Main {
}

public static final class Service {
public Service(App app) {}
public Service(App app) {
}
}

public static final class App {
public App(Service s) {}
public App(Service s) {
}
}
}
```
Expand Down Expand Up @@ -343,13 +351,18 @@ ServiceProviderBenchmark.benchManualInjection avgt 25 11,586 ± 0,085 ns/op

```Java
class Service1 {
public Service1() {}
public Service1() {
}
}

class Service2 {
public Service2() {}
public Service2() {
}
}

class App {
public App(Service1 s1, Service2 s2) {}
public App(Service1 s1, Service2 s2) {
}
}
```

Expand All @@ -362,31 +375,35 @@ Service1 и Service2 будут одновременно и артефактам
Например, для рассмотренного выше примера, это будет выглядеть так:

```Java
var service1=Artifact.of(Service1.class);
var service2=Artifact.of(Service2.class);
var app=Artifact.of(App.class);
var service1Scheme=new ClassScheme(
Service1.class,
new ConstructorScheme(Service1.class.getConstructor(),Set.of(),new Artifact[0]),
Set.of(),
Set.of()
public class Main {
public static void main(String[] args) {
var service1 = Artifact.of(Service1.class);
var service2 = Artifact.of(Service2.class);
var app = Artifact.of(App.class);
var service1Scheme = new ClassScheme(
Service1.class,
new ConstructorScheme(Service1.class.getConstructor(), Set.of(), new Artifact[0]),
Set.of(),
Set.of()
);
var service2Scheme=new ClassScheme(
Service2.class,
new ConstructorScheme(Service2.class.getConstructor(),Set.of(),new Artifact[0]),
Set.of(),
Set.of()
var service2Scheme = new ClassScheme(
Service2.class,
new ConstructorScheme(Service2.class.getConstructor(), Set.of(), new Artifact[0]),
Set.of(),
Set.of()
);
var appScheme=new ClassScheme(
App.class,
new ConstructorScheme(
App.class.getConstructor(Service1.class,Service2.class),
Set.of(service1,service2),
new Artifact[]{service1,service2}
),
Set.of(),
Set.of()
var appScheme = new ClassScheme(
App.class,
new ConstructorScheme(
App.class.getConstructor(Service1.class, Service2.class),
Set.of(service1, service2),
new Artifact[]{service1, service2}
),
Set.of(),
Set.of()
);
}
}
```

В фреймворке за создание схемы отвечает SchemeFactory, по умолчанию реализованная с помощью рефлективного апи.
Expand Down

0 comments on commit b5a3308

Please sign in to comment.