Skip to content

Commit

Permalink
optimize builder
Browse files Browse the repository at this point in the history
  • Loading branch information
jyrimatti committed Dec 10, 2024
1 parent 7dd2570 commit 9e03d89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fi.solita.utils</groupId>
<artifactId>functional-utils</artifactId>
<version>0.12.58</version>
<version>0.12.59</version>
<build>
<resources>
<resource>
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/fi/solita/utils/functional/lens/Builder.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import fi.solita.utils.functional.Apply;
import fi.solita.utils.functional.Apply10;
Expand Down Expand Up @@ -119,25 +118,25 @@ public IncompleteException(Apply<?, ?> member) {
}
}

private final Set<? extends Apply<? super T,? extends Object>> members;
private final Iterable<Pair<? extends Apply<? super T, ? extends Object>, ? extends Object>> values;
private final LinkedHashSet<? extends Apply<? super T,? extends Object>> members;
private final List<Pair<? extends Apply<? super T, ? extends Object>, ? extends Object>> values;
private final Apply<Tuple, T> constructor;
private Class<T> resultTypeCache;

@SuppressWarnings("unchecked")
private Builder(Iterable<Pair<? extends Apply<? super T,? extends Object>,? extends Object>> values, Collection<? extends Apply<? super T, ? extends Object>> members, Apply<? extends Tuple, T> constructor) {
this.members = new LinkedHashSet<Apply<? super T, ? extends Object>>(members);
this.values = values;
private Builder(Iterable<Pair<? extends Apply<? super T,? extends Object>,? extends Object>> values, LinkedHashSet<? extends Apply<? super T, ? extends Object>> members, Apply<? extends Tuple, T> constructor) {
this.members = members;
this.values = newList(values);
this.constructor = (Apply<Tuple, T>) constructor;
}

@SuppressWarnings("unchecked")
private static <T> Builder<T> newBuilder(Collection<? extends Apply<? super T, ? extends Object>> members, Apply<?, T> constructor) {
return new Builder<T>(Collections.<Pair<? extends Apply<? super T, ? extends Object>,? extends Object>>emptyList(), members, (Apply<? extends Tuple, T>) constructor);
return new Builder<T>(Collections.<Pair<? extends Apply<? super T, ? extends Object>,? extends Object>>emptyList(), new LinkedHashSet<Apply<? super T, ? extends Object>>(members), (Apply<? extends Tuple, T>) constructor);
}

private static <T> Builder<T> newBuilder(final ApplyZero<T> constructor) {
return new Builder<T>(Collections.<Pair<? extends Apply<? super T, ? extends Object>,? extends Object>>emptyList(), Collections.<Apply<? super T, ? extends Object>>emptyCollection(), new Apply<Tuple0, T>() {
return new Builder<T>(Collections.<Pair<? extends Apply<? super T, ? extends Object>,? extends Object>>emptyList(), new LinkedHashSet<Apply<? super T, ? extends Object>>(), new Apply<Tuple0, T>() {
public T apply(Tuple0 t) {
return constructor.get();
}
Expand Down

0 comments on commit 9e03d89

Please sign in to comment.