Skip to content

Commit

Permalink
domain 2.1.0 unpublished
Browse files Browse the repository at this point in the history
DomainFactory Supplier 修改返回值类型
  • Loading branch information
tanghanzheng committed Aug 21, 2023
1 parent 6e7e04c commit 1caa40e
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public interface DomainFactory {
/**
* 创建延迟调用的领域集合
*/
<T extends DomainObject, C extends DomainCollection<T>> C createCollection(Class<C> cls, Supplier<Collection<T>> supplier);
<T extends DomainObject, C extends DomainCollection<T>> C createCollection(Class<C> cls, Supplier<C> supplier);

/**
* 创建在指定集合中指定 ids 的领域集合
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ public <T extends DomainObject, C extends DomainCollection<T>> Map<String, T> cr
C collection = createCollection(cCls, () -> {
Set<String> ids = new HashSet<>(function.apply(ownerIds).values());
C c = createCollection(cCls, ids);
return ids.stream()
List<T> list = ids.stream()
.map(it -> createObject(dCls, c, it))
.collect(Collectors.toList());
return wrapCollection(cCls, list);
});

Map<String, T> map = new LinkedHashMap<>();
Expand Down Expand Up @@ -151,7 +152,7 @@ public <C extends DomainCollection<?>> C createCollection(Class<C> cls, Conditio
}

@Override
public <T extends DomainObject, C extends DomainCollection<T>> C createCollection(Class<C> cls, Supplier<Collection<T>> supplier) {
public <T extends DomainObject, C extends DomainCollection<T>> C createCollection(Class<C> cls, Supplier<C> supplier) {
return obtain(ProxySchrodingerDeferredDomainCollection.class,
ProxySchrodingerDeferredDomainCollection::new, cls,
create -> {
Expand Down Expand Up @@ -216,19 +217,21 @@ public <T extends DomainObject, C extends DomainCollection<T>> Map<String, C> cr
.flatMap(Collection::stream)
.collect(Collectors.toSet());
C c = createCollection(cCls, ids);
return ids.stream()
List<T> list = ids.stream()
.map(it -> createObject(dCls, c, it))
.collect(Collectors.toList());
return wrapCollection(cCls, list);
});

Map<String, C> map = new LinkedHashMap<>();
for (String ownerId : ownerIds) {
C c = createCollection(cCls, () -> {
Map<String, ? extends Collection<String>> apply = function.apply(ownerIds);
Collection<String> ids = apply.get(ownerId);
return ids.stream()
List<T> list = ids.stream()
.map(collection::get)
.collect(Collectors.toList());
return wrapCollection(cCls, list);
});
map.put(ownerId, c);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import lombok.Setter;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
Expand Down Expand Up @@ -37,7 +36,7 @@ public Map<String, T> getTarget() {
return this.target;
}

protected abstract Collection<T> doGetTarget();
protected abstract DomainCollection<T> doGetTarget();

/**
* 根据 id 获得领域模型
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import lombok.Getter;
import lombok.Setter;

import java.util.*;

/**
* 薛定谔的集合模型
*/
Expand All @@ -18,8 +16,8 @@ public class SchrodingerConditionsDomainCollection<T extends DomainObject>
protected Conditions conditions;

@Override
protected Collection<T> doGetTarget() {
return getRepository().select(conditions).list();
protected DomainCollection<T> doGetTarget() {
return getRepository().select(conditions);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import lombok.Getter;
import lombok.Setter;

import java.util.Collection;
import java.util.Collections;
import java.util.function.Supplier;

/**
Expand All @@ -17,15 +15,11 @@
public class SchrodingerDeferredDomainCollection<T extends DomainObject>
extends AbstractSchrodingerDomainCollection<T> implements DomainCollection<T> {

protected Supplier<Collection<T>> supplier;
protected Supplier<DomainCollection<T>> supplier;

@Override
protected Collection<T> doGetTarget() {
Collection<T> collection = supplier.get();
if (collection == null) {
return Collections.emptyList();
}
return collection;
protected DomainCollection<T> doGetTarget() {
return supplier.get();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class SchrodingerIdentifiedDomainCollection<T extends DomainObject>
protected Collection<String> ids;

@Override
protected Collection<T> doGetTarget() {
return getRepository().select(ids).list();
protected DomainCollection<T> doGetTarget() {
return getRepository().select(ids);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion concept-domain/version.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ext.'ConceptDomainVersion' = '2.0.2'
ext.'ConceptDomainVersion' = '2.1.0' //unpublished

0 comments on commit 1caa40e

Please sign in to comment.