Add support for parametrized types
Currently polymorphic target are not supported. I think the following:
@Goal(name = "entry")
static <K, V> Map.Entry<K, V> entry(K key, V value) {
return new AbstractMap.SimpleEntry<K, V>(key, value);
}
should generate something like:
[...]
public static EntryBuilder.Key entryBuilder() {
return INSTANCE.get().entryBuilderImpl;
}
private static final class EntryBuilderImpl implements EntryBuilder.Key,
EntryBuilder.Value<Object> {
private Object key;
EntryBuilderImpl() { }
@Override
public <K> EntryBuilder.Value<K> key(K key) {
this.key = key;
return (EntryBuilder.Value<K>) this;
}
@Override
public <V> Map.Entry<Object, V> value(V value) {
Object key = this.key;
this.key = null;
return Request.entry(key, value);
}
}
public static final class EntryBuilder {
private EntryBuilder() {
throw new UnsupportedOperationException("no instances");
}
public interface Key {
<K> Value<K> key(K key);
}
public interface Value<K> {
<V> Map.Entry<K, V> value(V value);
}
}
if recycling is activated.
Thanks @jbgi this looks natural. After modularisation of the API is complete, this will go in the builder module. It seems like the other module, updater, will not be affected.
First attempt: https://github.com/h908714124/zerobuilder/blob/9b235bdbd36ddfe8513c2075ebe962b2934b70b5/examples/basic/src/test/java/net/zerobuilder/examples/generics/MapEntryTest.java
recycle, @Step and non-static goal methods don't work yet.
Release 1.522 supports type variables. In goals with typevars, recycle is currently ignored, and update is forbidden.
1.523 finally also generates a generic updater, see GenericConstructor.java.