Skip to content

Commit

Permalink
Merge pull request #262 from umutsahin/patch-1
Browse files Browse the repository at this point in the history
Fixed issue with getter setter match on bean analysis with DeclaredTypes
  • Loading branch information
zapov authored Jul 23, 2023
2 parents ff0f3f3 + dbd984e commit d50d150
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 8 deletions.
2 changes: 1 addition & 1 deletion android/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<description>DSL Platform compatible Java JSON library (https://dsl-platform.com)</description>
<url>https://github.com/ngs-doo/dsl-json</url>
<packaging>jar</packaging>
<version>2.0.1</version>
<version>2.0.2</version>

<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<description>DSL Platform compatible Java JSON library (https://dsl-platform.com)</description>
<url>https://github.com/ngs-doo/dsl-json</url>
<packaging>jar</packaging>
<version>2.0.1</version>
<version>2.0.2</version>

<dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1119,13 +1119,13 @@ static TypeMirror unpackType(TypeMirror type, Types types) {
TypeMirror sb = unpackType(wt.getSuperBound(), types);
return types.getWildcardType(ext, sb);
}
if (type instanceof DeclaredType && type instanceof TypeElement) {
if (type instanceof DeclaredType) {
DeclaredType dt = (DeclaredType) type;
List<TypeMirror> args = new ArrayList<>(2);
for (TypeMirror a : dt.getTypeArguments()) {
args.add(unpackType(a, types));
}
TypeElement te = (TypeElement) dt;
TypeElement te = (TypeElement) dt.asElement();
return types.getDeclaredType(te, args.toArray(new TypeMirror[0]));
}
Element el = types.asElement(type);
Expand Down
2 changes: 1 addition & 1 deletion tests-java8-external-models/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<description>DSL Platform compatible JSON (https://dsl-platform.com)</description>
<url>https://github.com/ngs-doo/dsl-json</url>
<packaging>jar</packaging>
<version>2.0.1</version>
<version>2.0.2</version>

<properties>
<maven.deploy.skip>true</maven.deploy.skip>
Expand Down
2 changes: 1 addition & 1 deletion tests-java8/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<description>DSL Platform compatible JSON (https://dsl-platform.com)</description>
<url>https://github.com/ngs-doo/dsl-json</url>
<packaging>jar</packaging>
<version>2.0.1</version>
<version>2.0.2</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
2 changes: 1 addition & 1 deletion tests-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<description>DSL Platform compatible JSON (https://dsl-platform.com)</description>
<url>https://github.com/ngs-doo/dsl-json</url>
<packaging>jar</packaging>
<version>2.0.1</version>
<version>2.0.2</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
2 changes: 1 addition & 1 deletion tests-processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<description>Embedding compiled time JSON conversion for DSL Platform JSON library (https://dsl-platform.com)</description>
<url>https://github.com/ngs-doo/dsl-json</url>
<packaging>jar</packaging>
<version>2.0.1</version>
<version>2.0.2</version>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -905,4 +905,11 @@ public void warningOnWrongBuilderType() {
compileTestCase(VoidOnBuilderReturn.class),
"Skipping over method 'setS' because its return type is not the expected 'com.dslplatform.json.models.VoidOnBuilderReturn.Builder'");
}

@Test
public void faultyAnalysisModel() {
List<Diagnostic<? extends JavaFileObject>> diagnostics = compileTestCase(FaultyAnalysis.class);

Assert.assertEquals(0, diagnostics.size());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
package com.dslplatform.json.models;

import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.*;
import javax.validation.Valid;

import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;

@JsonTypeName("ServerCapabilities")
@com.dslplatform.json.CompiledJson
public class FaultyAnalysis {
private @Valid List<Long> mandatoryCapability;
private @Valid List<Long> optionalCapability;
private @Valid List<String> serverName;

public FaultyAnalysis mandatoryCapability(List<Long> mandatoryCapability) {
this.mandatoryCapability = mandatoryCapability;
return this;
}

@JsonProperty("mandatoryCapability")
@Size(min=0)
public List<Long> getMandatoryCapability() {
return mandatoryCapability;
}

@JsonProperty("mandatoryCapability")
public void setMandatoryCapability(List<Long> mandatoryCapability) {
this.mandatoryCapability = mandatoryCapability;
}

public FaultyAnalysis addMandatoryCapabilityItem(Long mandatoryCapabilityItem) {
if (this.mandatoryCapability == null) {
this.mandatoryCapability = new ArrayList<>();
}

this.mandatoryCapability.add(mandatoryCapabilityItem);
return this;
}

public FaultyAnalysis removeMandatoryCapabilityItem(Long mandatoryCapabilityItem) {
if (mandatoryCapabilityItem != null && this.mandatoryCapability != null) {
this.mandatoryCapability.remove(mandatoryCapabilityItem);
}

return this;
}

public FaultyAnalysis optionalCapability(List<Long> optionalCapability) {
this.optionalCapability = optionalCapability;
return this;
}

@JsonProperty("optionalCapability")
@Size(min=0)
public List<Long> getOptionalCapability() {
return optionalCapability;
}

@JsonProperty("optionalCapability")
public void setOptionalCapability(List<Long> optionalCapability) {
this.optionalCapability = optionalCapability;
}

public FaultyAnalysis addOptionalCapabilityItem(Long optionalCapabilityItem) {
if (this.optionalCapability == null) {
this.optionalCapability = new ArrayList<>();
}

this.optionalCapability.add(optionalCapabilityItem);
return this;
}

public FaultyAnalysis removeOptionalCapabilityItem(Long optionalCapabilityItem) {
if (optionalCapabilityItem != null && this.optionalCapability != null) {
this.optionalCapability.remove(optionalCapabilityItem);
}

return this;
}

public FaultyAnalysis serverName(List<String> serverName) {
this.serverName = serverName;
return this;
}

@JsonProperty("serverName")
@Size(min=0)
public List<String> getServerName() {
return serverName;
}

@JsonProperty("serverName")
public void setServerName(List<String> serverName) {
this.serverName = serverName;
}

public FaultyAnalysis addServerNameItem(String serverNameItem) {
if (this.serverName == null) {
this.serverName = new ArrayList<>();
}

this.serverName.add(serverNameItem);
return this;
}

public FaultyAnalysis removeServerNameItem(String serverNameItem) {
if (serverNameItem != null && this.serverName != null) {
this.serverName.remove(serverNameItem);
}

return this;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
FaultyAnalysis serverCapabilities = (FaultyAnalysis) o;
return Objects.equals(this.mandatoryCapability, serverCapabilities.mandatoryCapability) &&
Objects.equals(this.optionalCapability, serverCapabilities.optionalCapability) &&
Objects.equals(this.serverName, serverCapabilities.serverName);
}

@Override
public int hashCode() {
return Objects.hash(mandatoryCapability, optionalCapability, serverName);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ServerCapabilities {\n");

sb.append(" mandatoryCapability: ").append(toIndentedString(mandatoryCapability)).append("\n");
sb.append(" optionalCapability: ").append(toIndentedString(optionalCapability)).append("\n");
sb.append(" serverName: ").append(toIndentedString(serverName)).append("\n");
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

0 comments on commit d50d150

Please sign in to comment.