Skip to content

Commit

Permalink
[#1970] Test and fix annotation processor issue with nested generics
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed Jan 5, 2025
1 parent 73c2974 commit 6758333
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@ private String importTypeArguments(String typeArguments, int start, int end) {
start = i + 1;
break;
case '<':
currentTypeIdx = 1;
int gtIdx = typeArguments.lastIndexOf('>', i);
sb.append(importType(typeArguments.substring(start, i).trim()));
int gtIdx = typeArguments.lastIndexOf('>', end - 1);
sb.append(importTypeArguments(typeArguments, i, gtIdx));
start = gtIdx + 1;
i = gtIdx;
break;
}
//CHECKSTYLE:ON: MissingSwitchDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public interface AView<X extends Serializable> extends IdHolderView<Integer> {
@MappingSingular
Map<String, String> getMap();

@MappingSingular
List<Map<String, String>> getJsonMap();

class TestFilter extends ViewFilterProvider {

private static final String CONSTANT = "myParam";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public abstract class AViewBuilder<X extends Serializable, BuilderType extends E
protected int age;
protected byte[] bytes;
protected Integer id;
protected List<Map<String, String>> jsonMap;
protected List<Object> listMappingParameter;
protected Map<String, String> map;
protected List<Set<String>> multiNames;
Expand All @@ -45,6 +46,7 @@ public AViewBuilder(Map<String, Object> blazePersistenceOptionalParameters) {
this.age = 0;
this.bytes = null;
this.id = null;
this.jsonMap = null;
this.listMappingParameter = (List<Object>) blazePersistenceOptionalParameters.get("listMappingParameter");
this.map = null;
this.multiNames = (List<Set<String>>) (java.util.List<?>) AView_.multiNames.getCollectionInstantiator().createCollection(0);
Expand Down Expand Up @@ -86,6 +88,16 @@ public BuilderType withId(Integer id) {
this.id = id;
return (BuilderType) this;
}
public List<Map<String, String>> getJsonMap() {
return jsonMap;
}
public void setJsonMap(List<Map<String, String>> jsonMap) {
this.jsonMap = jsonMap;
}
public BuilderType withJsonMap(List<Map<String, String>> jsonMap) {
this.jsonMap = jsonMap;
return (BuilderType) this;
}
public List<Object> getListMappingParameter() {
return listMappingParameter;
}
Expand Down Expand Up @@ -268,6 +280,8 @@ public <ElementType> ElementType get(String attribute) {
return (ElementType) (Object) this.bytes;
case "id":
return (ElementType) (Object) this.id;
case "jsonMap":
return (ElementType) (Object) this.jsonMap;
case "listMappingParameter":
return (ElementType) (Object) this.listMappingParameter;
case "map":
Expand Down Expand Up @@ -310,6 +324,9 @@ public BuilderType with(String attribute, Object value) {
case "id":
this.id = value == null ? null : (Integer) value;
break;
case "jsonMap":
this.jsonMap = value == null ? null : (List<Map<String, String>>) value;
break;
case "listMappingParameter":
this.listMappingParameter = value == null ? null : (List<Object>) value;
break;
Expand Down Expand Up @@ -557,6 +574,7 @@ public AView build() {
this.id,
this.age,
this.bytes,
this.jsonMap,
this.listMappingParameter,
this.map,
this.multiNames,
Expand Down Expand Up @@ -595,6 +613,10 @@ public Init<X> withId(Integer id) {
this.id = id;
return (Init<X>) this;
}
public Init<X> withJsonMap(List<Map<String, String>> jsonMap) {
this.jsonMap = jsonMap;
return (Init<X>) this;
}
public Init<X> withListMappingParameter(List<Object> listMappingParameter) {
this.listMappingParameter = listMappingParameter;
return (Init<X>) this;
Expand Down Expand Up @@ -643,6 +665,9 @@ public Init<X> with(String attribute, Object value) {
case "id":
this.id = value == null ? null : (Integer) value;
break;
case "jsonMap":
this.jsonMap = value == null ? null : (List<Map<String, String>>) value;
break;
case "listMappingParameter":
this.listMappingParameter = value == null ? null: (List<Object>) value;
break;
Expand Down Expand Up @@ -944,6 +969,7 @@ public BuilderResult build() {
this.id,
this.age,
this.bytes,
this.jsonMap,
this.listMappingParameter,
this.map,
this.multiNames,
Expand Down Expand Up @@ -983,6 +1009,10 @@ public Nested<X, BuilderResult> withId(Integer id) {
this.id = id;
return (Nested<X, BuilderResult>) this;
}
public Nested<X, BuilderResult> withJsonMap(List<Map<String, String>> jsonMap) {
this.jsonMap = jsonMap;
return (Nested<X, BuilderResult>) this;
}
public Nested<X, BuilderResult> withListMappingParameter(List<Object> listMappingParameter) {
this.listMappingParameter = listMappingParameter;
return (Nested<X, BuilderResult>) this;
Expand Down Expand Up @@ -1031,6 +1061,9 @@ public Nested<X, BuilderResult> with(String attribute, Object value) {
case "id":
this.id = value == null ? null : (Integer) value;
break;
case "jsonMap":
this.jsonMap = value == null ? null : (List<Map<String, String>>) value;
break;
case "listMappingParameter":
this.listMappingParameter = value == null ? null : (List<Object>) value;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class AViewImpl<X extends Serializable> implements AView<X>, EntityViewPr
private final int age;
private final byte[] bytes;
private final Integer id;
private final List<Map<String, String>> jsonMap;
private final List<Object> listMappingParameter;
private final Map<String, String> map;
private final List<Set<String>> multiNames;
Expand All @@ -36,6 +37,7 @@ public AViewImpl(AViewImpl noop, Map<String, Object> blazePersistenceOptionalPar
this.age = 0;
this.bytes = null;
this.id = null;
this.jsonMap = null;
this.listMappingParameter = (List<Object>) blazePersistenceOptionalParameters.get("listMappingParameter");
this.map = null;
this.multiNames = (List<Set<String>>) (java.util.List<?>) AView_.multiNames.getCollectionInstantiator().createCollection(0);
Expand All @@ -51,6 +53,7 @@ public AViewImpl(Integer id) {
this.age = 0;
this.bytes = null;
this.id = id;
this.jsonMap = null;
this.listMappingParameter = null;
this.map = null;
this.multiNames = (List<Set<String>>) (java.util.List<?>) AView_.multiNames.getCollectionInstantiator().createCollection(0);
Expand All @@ -61,11 +64,12 @@ public AViewImpl(Integer id) {
this.test2 = null;
}

public AViewImpl(Integer id, int age, byte[] bytes, List<Object> listMappingParameter, Map<String, String> map, List<Set<String>> multiNames, String name, List<String> names, Optional<BView> optionalValue, List<X> test, X test2) {
public AViewImpl(Integer id, int age, byte[] bytes, List<Map<String, String>> jsonMap, List<Object> listMappingParameter, Map<String, String> map, List<Set<String>> multiNames, String name, List<String> names, Optional<BView> optionalValue, List<X> test, X test2) {
super();
this.age = age;
this.bytes = bytes;
this.id = id;
this.jsonMap = jsonMap;
this.listMappingParameter = listMappingParameter;
this.map = map;
this.multiNames = multiNames;
Expand All @@ -81,29 +85,31 @@ public AViewImpl(AViewImpl noop, int offset, Object[] tuple) {
this.age = (int) tuple[offset + 1];
this.bytes = (byte[]) tuple[offset + 2];
this.id = (Integer) tuple[offset + 0];
this.listMappingParameter = (List<Object>) tuple[offset + 3];
this.map = (Map<String, String>) tuple[offset + 4];
this.multiNames = (List<Set<String>>) tuple[offset + 5];
this.name = (String) tuple[offset + 6];
this.names = (List<String>) tuple[offset + 7];
this.optionalValue = (Optional<BView>) tuple[offset + 8];
this.test = (List<X>) tuple[offset + 9];
this.test2 = (X) tuple[offset + 10];
this.jsonMap = (List<Map<String, String>>) tuple[offset + 3];
this.listMappingParameter = (List<Object>) tuple[offset + 4];
this.map = (Map<String, String>) tuple[offset + 5];
this.multiNames = (List<Set<String>>) tuple[offset + 6];
this.name = (String) tuple[offset + 7];
this.names = (List<String>) tuple[offset + 8];
this.optionalValue = (Optional<BView>) tuple[offset + 9];
this.test = (List<X>) tuple[offset + 10];
this.test2 = (X) tuple[offset + 11];
}

public AViewImpl(AViewImpl noop, int offset, int[] assignment, Object[] tuple) {
super();
this.age = (int) tuple[offset + assignment[1]];
this.bytes = (byte[]) tuple[offset + assignment[2]];
this.id = (Integer) tuple[offset + assignment[0]];
this.listMappingParameter = (List<Object>) tuple[offset + assignment[3]];
this.map = (Map<String, String>) tuple[offset + assignment[4]];
this.multiNames = (List<Set<String>>) tuple[offset + assignment[5]];
this.name = (String) tuple[offset + assignment[6]];
this.names = (List<String>) tuple[offset + assignment[7]];
this.optionalValue = (Optional<BView>) tuple[offset + assignment[8]];
this.test = (List<X>) tuple[offset + assignment[9]];
this.test2 = (X) tuple[offset + assignment[10]];
this.jsonMap = (List<Map<String, String>>) tuple[offset + assignment[3]];
this.listMappingParameter = (List<Object>) tuple[offset + assignment[4]];
this.map = (Map<String, String>) tuple[offset + assignment[5]];
this.multiNames = (List<Set<String>>) tuple[offset + assignment[6]];
this.name = (String) tuple[offset + assignment[7]];
this.names = (List<String>) tuple[offset + assignment[8]];
this.optionalValue = (Optional<BView>) tuple[offset + assignment[9]];
this.test = (List<X>) tuple[offset + assignment[10]];
this.test2 = (X) tuple[offset + assignment[11]];
}

@Override
Expand All @@ -121,6 +127,11 @@ public Integer getId() {
return id;
}

@Override
public List<Map<String, String>> getJsonMap() {
return jsonMap;
}

@Override
public List<Object> getListMappingParameter() {
return listMappingParameter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public AttributePath<T, Integer, Integer> id() {
return attribute == null ? getWrapped().<Integer>get("id") : getWrapped().get(attribute);
}

public AttributePath<T, List<Map<String, String>>, List<Map<String, String>>> jsonMap() {
MethodSingularAttribute<AView, List<Map<String, String>>> attribute = AView_.jsonMap;
return attribute == null ? getWrapped().<List<Map<String, String>>>get("jsonMap") : getWrapped().get(attribute);
}

public AttributePath<T, List<Object>, List<Object>> listMappingParameter() {
MethodSingularAttribute<AView, List<Object>> attribute = AView_.listMappingParameter;
return attribute == null ? getWrapped().<List<Object>>get("listMappingParameter") : getWrapped().get(attribute);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public AttributePath<T, Integer, Integer> id() {
return attribute == null ? getWrapped().<Integer>get("id") : getWrapped().get(attribute);
}

public AttributePath<T, List<Map<String, String>>, List<Map<String, String>>> jsonMap() {
MethodSingularAttribute<AView, List<Map<String, String>>> attribute = AView_.jsonMap;
return attribute == null ? getWrapped().<List<Map<String, String>>>get("jsonMap") : getWrapped().get(attribute);
}

public AttributePath<T, List<Object>, List<Object>> listMappingParameter() {
MethodSingularAttribute<AView, List<Object>> attribute = AView_.listMappingParameter;
return attribute == null ? getWrapped().<List<Object>>get("listMappingParameter") : getWrapped().get(attribute);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public abstract class AView_ {
public static volatile MethodSingularAttribute<AView, Integer> age;
public static volatile MethodSingularAttribute<AView, byte[]> bytes;
public static volatile MethodSingularAttribute<AView, Integer> id;
public static volatile MethodSingularAttribute<AView, List<Map<String, String>>> jsonMap;
public static volatile MethodSingularAttribute<AView, List<Object>> listMappingParameter;
public static volatile MethodSingularAttribute<AView, Map<String, String>> map;
public static volatile MethodMultiListAttribute<AView, String, Set<String>> multiNames;
Expand All @@ -36,6 +37,7 @@ public abstract class AView_ {
public static final String AGE = "age";
public static final String BYTES = "bytes";
public static final String ID = "id";
public static final String JSON_MAP = "jsonMap";
public static final String LIST_MAPPING_PARAMETER = "listMappingParameter";
public static final String MAP = "map";
public static final String MULTI_NAMES = "multiNames";
Expand Down

0 comments on commit 6758333

Please sign in to comment.