Skip to content

Commit

Permalink
fix gauss factory bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fenix-Lee committed Jul 28, 2022
1 parent ee548e3 commit 8b46881
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ To add a dependency by Maven, use the following:
<dependency>
<groupId>xyz.gaussframework</groupId>
<artifactId>gauss-engine-spring-boot-starter</artifactId>
<version>2.2.5</version>
<version>2.2.6</version>
</dependency>
```
## Learn about Gauss
Expand Down
2 changes: 1 addition & 1 deletion gauss-engine/gauss-engine-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>xyz.gaussframework</groupId>
<artifactId>gauss-engine</artifactId>
<version>2.2.5</version>
<version>2.2.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xyz.gaussframework.engine.factory;

import org.springframework.stereotype.Component;
import xyz.gaussframework.engine.framework.OverrideClone;

import java.lang.annotation.*;

Expand All @@ -15,6 +16,7 @@
@Documented
@Inherited
@Component
@OverrideClone
public @interface Creator {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public List<T> getModules() {
return copyModules();
}

private List<T> copyModules() {
protected List<T> copyModules() {
return modules.stream()
.map(GaussBeanFactory::copyObject)
.collect(Collectors.toList());
Expand All @@ -47,6 +47,10 @@ protected void setModules(List<T> modules) {
this.modules = modules;
}

protected List<T> findModules() {
return modules;
}

protected List<T> sortModule(Map<Integer, T> container) {
return container.entrySet().stream()
.sorted(Comparator.comparingInt(Map.Entry::getKey))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,28 @@ public abstract class GaussFactory<T, R> extends GaussChain<T>

@SuppressWarnings("unused")
public List<T> produce() {
return getModules();
return findModules();
}

@Override
public List<R> produce(@NonNull Function<? super T, ? extends R> mapper) {
return getModules().stream()
return findModules().stream()
.map(mapper)
.collect(Collectors.toList());
}

@Override
public R manufacture(@NonNull Function<List<T>, ? extends R> mapper) {
return mapper.apply(getModules());
return mapper.apply(findModules());
}

@Override
@SuppressWarnings("unchecked")
public GaussFactory<T, R> clone() {
try {
return (GaussFactory<T, R>) super.clone();
GaussFactory<T, R> copy = (GaussFactory<T, R>) super.clone();
copy.setModules(getModules());
return copy;
} catch (CloneNotSupportedException e) {
throw new AssertionError();
}
Expand Down
4 changes: 2 additions & 2 deletions gauss-engine/gauss-engine-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>xyz.gaussframework</groupId>
<artifactId>gauss-engine</artifactId>
<version>2.2.5</version>
<version>2.2.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>xyz.gaussframework</groupId>
<artifactId>gauss-engine-core</artifactId>
<version>2.2.5</version>
<version>2.2.6</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion gauss-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>gauss-engine</artifactId>
<version>2.2.5</version>
<version>2.2.6</version>
<packaging>pom</packaging>
<modules>
<module>gauss-engine-spring-boot-starter</module>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>xyz.gaussframework</groupId>
<artifactId>gauss-parent</artifactId>
<version>2.2.5</version>
<version>2.2.6</version>
<name>gauss-parent</name>
<description>java code engine</description>
<url>https://github.com/fenix-Lee/gauss-framework</url>
Expand Down

0 comments on commit 8b46881

Please sign in to comment.