-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #70 Compilation error in case of recursive class structures
- Loading branch information
Showing
18 changed files
with
306 additions
and
30 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...son-processor/src/main/java/org/dominokit/jackson/processor/GeneratedMappersRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright © 2019 Dominokit | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.dominokit.jackson.processor; | ||
|
||
import com.google.auto.common.MoreTypes; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import javax.lang.model.type.TypeMirror; | ||
|
||
public class GeneratedMappersRegistry { | ||
|
||
public static final GeneratedMappersRegistry INSTANCE = new GeneratedMappersRegistry(); | ||
private final Map<Category, Set<GeneratedTypeToken>> typeTokens = new HashMap<>(); | ||
|
||
private GeneratedMappersRegistry() {} | ||
|
||
public void addTypeToken(Category category, TypeMirror typeMirror) { | ||
if (!typeTokens.containsKey(category)) { | ||
typeTokens.put(category, new HashSet<>()); | ||
} | ||
typeTokens.get(category).add(new GeneratedTypeToken(typeMirror)); | ||
} | ||
|
||
public boolean hasTypeToken(Category category, TypeMirror typeMirror) { | ||
if (typeTokens.containsKey(category)) { | ||
return typeTokens.get(category).contains(new GeneratedTypeToken(typeMirror)); | ||
} | ||
return false; | ||
|
||
// return false; | ||
} | ||
|
||
public enum Category { | ||
MAPPER, | ||
READER, | ||
WRITER, | ||
SERIALIZER, | ||
DESERIALIZER | ||
} | ||
|
||
public static class GeneratedTypeToken { | ||
TypeMirror typeMirror; | ||
|
||
public GeneratedTypeToken(TypeMirror typeMirror) { | ||
this.typeMirror = typeMirror; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
GeneratedTypeToken that = (GeneratedTypeToken) o; | ||
return MoreTypes.equivalence().equivalent(typeMirror, that.typeMirror); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return typeMirror.hashCode(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
domino-jackson-processor/src/test/java/org/dominokit/jackson/processor/recursive/A.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright © 2019 Dominokit | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.dominokit.jackson.processor.recursive; | ||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonSubTypes.Type; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo.As; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; | ||
import org.dominokit.jackson.annotation.JSONMapper; | ||
|
||
@JSONMapper | ||
@JsonTypeInfo(use = Id.NAME, include = As.PROPERTY, visible = true) | ||
@JsonSubTypes({ | ||
@Type(value = D.class, name = "dominokit.recursive.D"), | ||
@Type(value = E.class, name = "dominokit.recursive.E"), | ||
@Type(value = F.class, name = "dominokit.recursive.F") | ||
}) | ||
public interface A {} |
29 changes: 29 additions & 0 deletions
29
domino-jackson-processor/src/test/java/org/dominokit/jackson/processor/recursive/B.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright © 2019 Dominokit | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.dominokit.jackson.processor.recursive; | ||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonSubTypes.Type; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo.As; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; | ||
|
||
@JsonTypeInfo(use = Id.NAME, include = As.PROPERTY, visible = true) | ||
@JsonSubTypes({ | ||
@Type(value = D.class, name = "dominokit.recursive.D"), | ||
@Type(value = E.class, name = "dominokit.recursive.E") | ||
}) | ||
public interface B extends A {} |
18 changes: 18 additions & 0 deletions
18
domino-jackson-processor/src/test/java/org/dominokit/jackson/processor/recursive/C.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright © 2019 Dominokit | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.dominokit.jackson.processor.recursive; | ||
|
||
public interface C extends B {} |
21 changes: 21 additions & 0 deletions
21
domino-jackson-processor/src/test/java/org/dominokit/jackson/processor/recursive/D.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright © 2019 Dominokit | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.dominokit.jackson.processor.recursive; | ||
|
||
public class D implements B { | ||
|
||
public D() {} | ||
} |
27 changes: 27 additions & 0 deletions
27
domino-jackson-processor/src/test/java/org/dominokit/jackson/processor/recursive/E.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright © 2019 Dominokit | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.dominokit.jackson.processor.recursive; | ||
|
||
public class E implements C { | ||
|
||
public B b; | ||
|
||
public E() {} | ||
|
||
public E(B b) { | ||
this.b = b; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
domino-jackson-processor/src/test/java/org/dominokit/jackson/processor/recursive/F.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright © 2019 Dominokit | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.dominokit.jackson.processor.recursive; | ||
|
||
public class F implements A {} |
Oops, something went wrong.