This commit is contained in:
@@ -220,19 +220,29 @@ public final class EntityCache<T> {
|
|||||||
if (filter != null) stream = stream.filter(filter);
|
if (filter != null) stream = stream.filter(filter);
|
||||||
if (sort != null) stream = stream.sorted(sort);
|
if (sort != null) stream = stream.sorted(sort);
|
||||||
if (selects == null) {
|
if (selects == null) {
|
||||||
stream.forEach(x -> rs.add(needcopy ? reproduce.copy(creator.create(), x) : x));
|
Consumer<? super T> action = x -> rs.add(needcopy ? reproduce.copy(creator.create(), x) : x);
|
||||||
|
if (parallel && sort != null) {
|
||||||
|
stream.forEachOrdered(action);
|
||||||
|
} else {
|
||||||
|
stream.forEach(action);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final List<Attribute<T, Serializable>> attrs = new ArrayList<>();
|
final List<Attribute<T, Serializable>> attrs = new ArrayList<>();
|
||||||
for (Map.Entry<String, Attribute<T, Serializable>> en : this.attributes.entrySet()) {
|
for (Map.Entry<String, Attribute<T, Serializable>> en : this.attributes.entrySet()) {
|
||||||
if (selects.validate(en.getKey())) attrs.add(en.getValue());
|
if (selects.validate(en.getKey())) attrs.add(en.getValue());
|
||||||
}
|
}
|
||||||
stream.forEach(x -> {
|
Consumer<? super T> action = x -> {
|
||||||
final T item = creator.create();
|
final T item = creator.create();
|
||||||
for (Attribute attr : attrs) {
|
for (Attribute attr : attrs) {
|
||||||
attr.set(item, attr.get(x));
|
attr.set(item, attr.get(x));
|
||||||
}
|
}
|
||||||
rs.add(item);
|
rs.add(item);
|
||||||
});
|
};
|
||||||
|
if (parallel && sort != null) {
|
||||||
|
stream.forEachOrdered(action);
|
||||||
|
} else {
|
||||||
|
stream.forEach(action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return parallel ? (set ? new LinkedHashSet<>(rs) : new ArrayList<>(rs)) : rs;
|
return parallel ? (set ? new LinkedHashSet<>(rs) : new ArrayList<>(rs)) : rs;
|
||||||
}
|
}
|
||||||
@@ -259,19 +269,29 @@ public final class EntityCache<T> {
|
|||||||
boolean parallel = isParallel();
|
boolean parallel = isParallel();
|
||||||
final List<T> rs = parallel ? new CopyOnWriteArrayList<>() : new ArrayList<>();
|
final List<T> rs = parallel ? new CopyOnWriteArrayList<>() : new ArrayList<>();
|
||||||
if (selects == null) {
|
if (selects == null) {
|
||||||
stream.forEach(x -> rs.add(needcopy ? reproduce.copy(creator.create(), x) : x));
|
Consumer<? super T> action = x -> rs.add(needcopy ? reproduce.copy(creator.create(), x) : x);
|
||||||
|
if (parallel && sort != null) {
|
||||||
|
stream.forEachOrdered(action);
|
||||||
|
} else {
|
||||||
|
stream.forEach(action);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final List<Attribute<T, Serializable>> attrs = new ArrayList<>();
|
final List<Attribute<T, Serializable>> attrs = new ArrayList<>();
|
||||||
for (Map.Entry<String, Attribute<T, Serializable>> en : this.attributes.entrySet()) {
|
for (Map.Entry<String, Attribute<T, Serializable>> en : this.attributes.entrySet()) {
|
||||||
if (selects.validate(en.getKey())) attrs.add(en.getValue());
|
if (selects.validate(en.getKey())) attrs.add(en.getValue());
|
||||||
}
|
}
|
||||||
stream.forEach(x -> {
|
Consumer<? super T> action = x -> {
|
||||||
final T item = creator.create();
|
final T item = creator.create();
|
||||||
for (Attribute attr : attrs) {
|
for (Attribute attr : attrs) {
|
||||||
attr.set(item, attr.get(x));
|
attr.set(item, attr.get(x));
|
||||||
}
|
}
|
||||||
rs.add(item);
|
rs.add(item);
|
||||||
});
|
};
|
||||||
|
if (parallel && sort != null) {
|
||||||
|
stream.forEachOrdered(action);
|
||||||
|
} else {
|
||||||
|
stream.forEach(action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new Sheet<>(total, parallel ? new ArrayList<>(rs) : rs);
|
return new Sheet<>(total, parallel ? new ArrayList<>(rs) : rs);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user