Skip to content

Commit

Permalink
Remove tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
joelittlejohn committed Feb 28, 2021
1 parent e7754e1 commit cab73e7
Show file tree
Hide file tree
Showing 15 changed files with 168 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,33 @@

public abstract class AbstractTypeInfoAwareAnnotator extends AbstractAnnotator
{
public AbstractTypeInfoAwareAnnotator(GenerationConfig generationConfig) {
super(generationConfig);
}
public AbstractTypeInfoAwareAnnotator(GenerationConfig generationConfig) {
super(generationConfig);
}

@Override
public void typeInfo(JDefinedClass clazz, JsonNode node) {
if(getGenerationConfig().isIncludeTypeInfo()) {
// Have per-schema JavaTypeInfo configuration override what is defined in generation config; backward comparability
if (node.has("deserializationClassProperty")) {
String annotationName = node.get("deserializationClassProperty").asText();
addJsonTypeInfoAnnotation(clazz, annotationName);
} else {
addJsonTypeInfoAnnotation(clazz, "@class");
}
} else {
// per-schema JsonTypeInfo configuration
if (node.has("deserializationClassProperty")) {
String annotationName = node.get("deserializationClassProperty").asText();
addJsonTypeInfoAnnotation(clazz, annotationName);
}
}
}
@Override
public void typeInfo(JDefinedClass clazz, JsonNode node) {
if(getGenerationConfig().isIncludeTypeInfo()) {
// Have per-schema JavaTypeInfo configuration override what is defined in generation config; backward comparability
if (node.has("deserializationClassProperty")) {
String annotationName = node.get("deserializationClassProperty").asText();
addJsonTypeInfoAnnotation(clazz, annotationName);
} else {
addJsonTypeInfoAnnotation(clazz, "@class");
}
} else {
// per-schema JsonTypeInfo configuration
if (node.has("deserializationClassProperty")) {
String annotationName = node.get("deserializationClassProperty").asText();
addJsonTypeInfoAnnotation(clazz, annotationName);
}
}
}

@Override
public boolean isPolymorphicDeserializationSupported(JsonNode node) {
return getGenerationConfig().isIncludeTypeInfo() || node.has("deserializationClassProperty");
}
@Override
public boolean isPolymorphicDeserializationSupported(JsonNode node) {
return getGenerationConfig().isIncludeTypeInfo() || node.has("deserializationClassProperty");
}

abstract protected void addJsonTypeInfoAnnotation(JDefinedClass clazz, String propertyName);
abstract protected void addJsonTypeInfoAnnotation(JDefinedClass clazz, String propertyName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,5 @@ public interface Annotator {

void additionalPropertiesField(JFieldVar field, JDefinedClass clazz, String propertyName);

boolean isPolymorphicDeserializationSupported(JsonNode node);
boolean isPolymorphicDeserializationSupported(JsonNode node);
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ public class ContentResolver {
private final ObjectMapper objectMapper;

public ContentResolver() {
this(null);
}
this(null);
}

public ContentResolver(JsonFactory jsonFactory) {
this.objectMapper = new ObjectMapper(jsonFactory)
this.objectMapper = new ObjectMapper(jsonFactory)
.enable(JsonParser.Feature.ALLOW_COMMENTS)
.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
}
}

/**
* Resolve a given URI to read its contents and parse the result as JSON.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public interface GenerationConfig {
*/
boolean isIncludeTypeInfo();

/**
/**
* Gets the 'includeConstructorPropertiesAnnotation' configuration option.
*
* @return whether to include JDK Constructor Properties. Used by serialization libraries to get parameter names of constructors at runtime. (Not Available on Android)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ public static void generate(GenerationConfig config, RuleLogger logger) throws I
}

private static ContentResolver createContentResolver(GenerationConfig config) {
if (config.getSourceType() == SourceType.YAMLSCHEMA || config.getSourceType() == SourceType.YAML) {
return new ContentResolver(new YAMLFactory());
} else {
return new ContentResolver();
}
if (config.getSourceType() == SourceType.YAMLSCHEMA || config.getSourceType() == SourceType.YAML) {
return new ContentResolver(new YAMLFactory());
} else {
return new ContentResolver();
}
}

private static SchemaGenerator createSchemaGenerator(GenerationConfig config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@

public interface RuleLogger
{
void debug(String msg);
void debug(String msg);

void error(String msg);
void error(String msg);

void error(String s, Throwable e);
void error(String s, Throwable e);

void info(String msg);
void info(String msg);

boolean isDebugEnabled();
boolean isDebugEnabled();

boolean isErrorEnabled();
boolean isErrorEnabled();

boolean isInfoEnabled();
boolean isInfoEnabled();

boolean isTraceEnabled();
boolean isTraceEnabled();

boolean isWarnEnabled();
boolean isWarnEnabled();

void trace(String msg);
void trace(String msg);

void warn(String s, Throwable e);
void warn(String s, Throwable e);

void warn(String msg);
void warn(String msg);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public class SchemaStore {
protected final ContentResolver contentResolver;

public SchemaStore() {
this.contentResolver = new ContentResolver();
}
this.contentResolver = new ContentResolver();
}

public SchemaStore(ContentResolver contentResolver) {
this.contentResolver = contentResolver;
}
this.contentResolver = contentResolver;
}

/**
/**
* Create or look up a new schema which has the given ID and read the
* contents of the given ID as a URL. If a schema with the given ID is
* already known, then a reference to the original schema will be returned.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@

public enum EnumDefinitionExtensionType {

/**
* Enum defined just by JSON Schema
*/
NONE,
/**
* Enum defined just by JSON Schema
*/
NONE,

/**
* Enum defined by JSON Schema and javaEnumNames jsonschema2pojo extension.
*/
JAVA_ENUM_NAMES,
/**
* Enum defined by JSON Schema and javaEnumNames jsonschema2pojo extension.
*/
JAVA_ENUM_NAMES,

/**
* Enum defined by JSON Schema and javaEnums jsonschema2pojo extension.
*/
JAVA_ENUMS,
/**
* Enum defined by JSON Schema and javaEnums jsonschema2pojo extension.
*/
JAVA_ENUMS,

/**
* Enum defined by JSON Schema and a custom jsonschema2pojo extension,
/**
* Enum defined by JSON Schema and a custom jsonschema2pojo extension,
* defined by custom {@link org.jsonschema2pojo.rules.EnumRule} implementation provided by custom {@link org.jsonschema2pojo.rules.RuleFactory}.
*/
CUSTOM
*/
CUSTOM
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static Collection<Object[]> data() {
}

public FormatRuleArraysTest(String formatValue, Class<?> expectedType) {
this.formatValue = formatValue;
this.formatValue = formatValue;
this.expectedType = expectedType;

when(config.getFormatTypeMapping()).thenReturn(Collections.singletonMap("test", formatValue));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@

public class MakeUniqueClassNameTest {

@Test
public void testClassNameStrategy() {
assertThat(MakeUniqueClassName.makeUnique("NodeMode"), equalTo("NodeMode__1"));
assertThat(MakeUniqueClassName.makeUnique("NodeMode__5"), equalTo("NodeMode__6"));
assertThat(MakeUniqueClassName.makeUnique("NodeMode__10"), equalTo("NodeMode__11"));
assertThat(MakeUniqueClassName.makeUnique("NodeMode__100"), equalTo("NodeMode__101"));
}
@Test
public void testClassNameStrategy() {
assertThat(MakeUniqueClassName.makeUnique("NodeMode"), equalTo("NodeMode__1"));
assertThat(MakeUniqueClassName.makeUnique("NodeMode__5"), equalTo("NodeMode__6"));
assertThat(MakeUniqueClassName.makeUnique("NodeMode__10"), equalTo("NodeMode__11"));
assertThat(MakeUniqueClassName.makeUnique("NodeMode__100"), equalTo("NodeMode__101"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ public void extendsWithPolymorphicDeserializationWithDefaultAnnotationStyle() th
assertNotNull(supertype.getAnnotation(JsonTypeInfo.class));
}

@Test
public void extendsWithPolymorphicDeserializationWithJackson2() throws ClassNotFoundException {
@Test
public void extendsWithPolymorphicDeserializationWithJackson2() throws ClassNotFoundException {

ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/polymorphic/extendsSchema.json", "com.example",
config("annotationStyle", "JACKSON2"));
ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/polymorphic/extendsSchema.json", "com.example",
config("annotationStyle", "JACKSON2"));

Class<?> subtype = resultsClassLoader.loadClass("com.example.ExtendsSchema");
Class<?> supertype = subtype.getSuperclass();
Class<?> subtype = resultsClassLoader.loadClass("com.example.ExtendsSchema");
Class<?> supertype = subtype.getSuperclass();

assertNotNull(supertype.getAnnotation(JsonTypeInfo.class));
}
assertNotNull(supertype.getAnnotation(JsonTypeInfo.class));
}
}
Loading

0 comments on commit cab73e7

Please sign in to comment.