Skip to content

Commit

Permalink
fixes following the rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
wigbam committed Mar 16, 2023
1 parent d175416 commit 2b82ee0
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.Map;
import java.util.Set;

import com.sun.codemodel.*;
import org.jsonschema2pojo.AnnotationStyle;
import org.jsonschema2pojo.Annotator;
import org.jsonschema2pojo.Schema;
Expand All @@ -39,6 +38,22 @@
import org.jsonschema2pojo.util.SerializableHelper;

import com.fasterxml.jackson.databind.JsonNode;
import com.sun.codemodel.ClassType;
import com.sun.codemodel.JBlock;
import com.sun.codemodel.JClass;
import com.sun.codemodel.JClassAlreadyExistsException;
import com.sun.codemodel.JClassContainer;
import com.sun.codemodel.JConditional;
import com.sun.codemodel.JDefinedClass;
import com.sun.codemodel.JExpr;
import com.sun.codemodel.JExpression;
import com.sun.codemodel.JFieldRef;
import com.sun.codemodel.JFieldVar;
import com.sun.codemodel.JMethod;
import com.sun.codemodel.JMod;
import com.sun.codemodel.JOp;
import com.sun.codemodel.JType;
import com.sun.codemodel.JVar;

/**
* Applies the generation steps required for schemas of type "object".
Expand Down Expand Up @@ -185,7 +200,6 @@ private JDefinedClass createClass(String nodeName, JsonNode node, JClassContaine

Annotator annotator = ruleFactory.getAnnotator();


try {
if (node.has("existingJavaType")) {
String fqn = substringBefore(node.get("existingJavaType").asText(), "<");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.sun.codemodel.JClassAlreadyExistsException;
import com.sun.codemodel.JClassContainer;
import com.sun.codemodel.JDefinedClass;
import com.sun.codemodel.JPackage;
import com.sun.codemodel.JType;

public class NameHelper {
Expand Down Expand Up @@ -291,10 +292,14 @@ private String createFullFieldName(String nodeName, String prefix, String suffix
private String makeUnique(String className, JClassContainer container) {
try {
JDefinedClass _class = container._class(className);
Iterator<JDefinedClass> iter = container.classes();
while (iter.hasNext()) {
if (iter.next().equals(_class)) {
iter.remove();
if (container instanceof JPackage) {
((JPackage) container).remove(_class);
} else {
Iterator<JDefinedClass> iter = container.classes();
while (iter.hasNext()) {
if (iter.next().equals(_class)) {
iter.remove();
}
}
}
return className;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.sun.codemodel.JType;
import org.jsonschema2pojo.Annotator;
import org.jsonschema2pojo.GenerationConfig;
import org.jsonschema2pojo.RuleLogger;
import org.jsonschema2pojo.Schema;
import org.jsonschema2pojo.util.NameHelper;
import org.jsonschema2pojo.util.ParcelableHelper;
Expand All @@ -42,6 +43,7 @@ public class ObjectRuleTest {
protected final RuleFactory ruleFactory = mock(RuleFactory.class);
protected final Annotator annotator = mock(Annotator.class);
protected final NameHelper nameHelper = mock(NameHelper.class);
protected final RuleLogger ruleLogger = mock(RuleLogger.class);
protected final ParcelableHelper parcelableHelper = mock(ParcelableHelper.class);
protected final ReflectionHelper reflectionHelper = mock(ReflectionHelper.class);
protected final AdditionalPropertiesRule additionalPropertiesRule = mock(AdditionalPropertiesRule.class);
Expand All @@ -63,6 +65,7 @@ public void setUp() {
lenient().when(ruleFactory.getReflectionHelper()).thenReturn(reflectionHelper);
lenient().when(ruleFactory.getPropertiesRule()).thenReturn(propertiesRule);
lenient().when(ruleFactory.getGenerationConfig()).thenReturn(generationConfig);
lenient().when(ruleFactory.getLogger()).thenReturn(ruleLogger);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testClassNameCorrectly() {
}

@Test
public void testGetUniqueClassNamePackageNewClass() throws Exception {
public void testGetUniqueClassNamePackageNewClass() {
JCodeModel codeModel = new JCodeModel();
JPackage _package = codeModel._package("pkg");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright © 2010-2020 Nokia
* <p>
*
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
*
* 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.
Expand Down

0 comments on commit 2b82ee0

Please sign in to comment.