remove reformat

This commit is contained in:
tao 2016-06-19 21:39:06 -07:00
parent 6ac27fcafc
commit 90d61578d0
2 changed files with 154 additions and 154 deletions

View File

@ -135,18 +135,18 @@ public class DefaultCodegen {
.get(CodegenConstants.ENSURE_UNIQUE_PARAMS).toString()));
}
if (additionalProperties.containsKey(CodegenConstants.MODEL_NAME_PREFIX)) {
if(additionalProperties.containsKey(CodegenConstants.MODEL_NAME_PREFIX)){
this.setModelNamePrefix((String) additionalProperties.get(CodegenConstants.MODEL_NAME_PREFIX));
}
if (additionalProperties.containsKey(CodegenConstants.MODEL_NAME_SUFFIX)) {
if(additionalProperties.containsKey(CodegenConstants.MODEL_NAME_SUFFIX)){
this.setModelNameSuffix((String) additionalProperties.get(CodegenConstants.MODEL_NAME_SUFFIX));
}
}
// override with any special post-processing for all models
@SuppressWarnings({"static-method", "unchecked"})
@SuppressWarnings({ "static-method", "unchecked" })
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
if (supportsInheritance) {
// Index all CodegenModels by model name.
@ -355,12 +355,12 @@ public class DefaultCodegen {
// override to post-process any model properties
@SuppressWarnings("unused")
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
public void postProcessModelProperty(CodegenModel model, CodegenProperty property){
}
// override to post-process any parameters
@SuppressWarnings("unused")
public void postProcessParameter(CodegenParameter parameter) {
public void postProcessParameter(CodegenParameter parameter){
}
//override with any special handling of the entire swagger spec
@ -381,7 +381,7 @@ public class DefaultCodegen {
// repalce \ with \\
// repalce " with \"
// outter unescape to retain the original multi-byte characters
return StringEscapeUtils.unescapeJava(StringEscapeUtils.escapeJava(input).replace("\\/", "/")).replaceAll("[\\t\\n\\r]", " ").replace("\\", "\\\\").replace("\"", "\\\"");
return StringEscapeUtils.unescapeJava(StringEscapeUtils.escapeJava(input).replace("\\/", "/")).replaceAll("[\\t\\n\\r]"," ").replace("\\", "\\\\").replace("\"", "\\\"");
}
return input;
}
@ -526,11 +526,11 @@ public class DefaultCodegen {
this.modelPackage = modelPackage;
}
public void setModelNamePrefix(String modelNamePrefix) {
public void setModelNamePrefix(String modelNamePrefix){
this.modelNamePrefix = modelNamePrefix;
}
public void setModelNameSuffix(String modelNameSuffix) {
public void setModelNameSuffix(String modelNameSuffix){
this.modelNameSuffix = modelNameSuffix;
}
@ -688,7 +688,7 @@ public class DefaultCodegen {
*
* @param name the name to be escaped
* @return the escaped reserved word
* <p>
*
* throws Runtime exception as reserved word is not allowed (default behavior)
*/
@SuppressWarnings("static-method")
@ -725,8 +725,8 @@ public class DefaultCodegen {
* This method will map between Swagger type and language-specified type, as well as mapping
* between Swagger type and the corresponding import statement for the language. This will
* also add some language specified CLI options, if any.
* <p>
* <p>
*
*
* returns string presentation of the example path (it's a constructor)
*/
public DefaultCodegen() {
@ -921,7 +921,7 @@ public class DefaultCodegen {
* @return string presentation of the example value of the property
*/
public String toExampleValue(Property p) {
if (p.getExample() != null) {
if(p.getExample() != null) {
return p.getExample().toString();
}
if (p instanceof StringProperty) {
@ -1021,7 +1021,6 @@ public class DefaultCodegen {
/**
* returns the swagger type for the property
*
* @param p Swagger property object
* @return string presentation of the type
**/
@ -1054,7 +1053,7 @@ public class DefaultCodegen {
datatype = "map";
} else if (p instanceof DecimalProperty) {
datatype = "number";
} else if (p instanceof UUIDProperty) {
} else if ( p instanceof UUIDProperty) {
datatype = "UUID";
} else if (p instanceof RefProperty) {
try {
@ -1257,7 +1256,7 @@ public class DefaultCodegen {
addVars(m, properties, required, allProperties, allRequired);
} else {
ModelImpl impl = (ModelImpl) model;
if (impl.getEnum() != null && impl.getEnum().size() > 0) {
if(impl.getEnum() != null && impl.getEnum().size() > 0) {
m.isEnum = true;
// comment out below as allowableValues is not set in post processing model enum
m.allowableValues = new HashMap<String, Object>();
@ -1272,7 +1271,7 @@ public class DefaultCodegen {
}
if (m.vars != null) {
for (CodegenProperty prop : m.vars) {
for(CodegenProperty prop : m.vars) {
postProcessModelProperty(m, prop);
}
}
@ -1299,7 +1298,7 @@ public class DefaultCodegen {
Model interfaceModel = allDefinitions.get(interfaceRef);
addProperties(properties, required, interfaceModel, allDefinitions);
} else if (model instanceof ComposedModel) {
for (Model component : ((ComposedModel) model).getAllOf()) {
for (Model component :((ComposedModel) model).getAllOf()) {
addProperties(properties, required, component, allDefinitions);
}
}
@ -1368,7 +1367,7 @@ public class DefaultCodegen {
if (np.getMaximum() != null) {
allowableValues.put("max", np.getMaximum());
}
if (allowableValues.size() > 0) {
if(allowableValues.size() > 0) {
property.allowableValues = allowableValues;
}
}
@ -1421,7 +1420,7 @@ public class DefaultCodegen {
if (sp.getEnum() != null) {
List<Integer> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
for (Integer i : _enum) {
for(Integer i : _enum) {
property._enum.add(i.toString());
}
property.isEnum = true;
@ -1439,7 +1438,7 @@ public class DefaultCodegen {
if (sp.getEnum() != null) {
List<Long> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
for (Long i : _enum) {
for(Long i : _enum) {
property._enum.add(i.toString());
}
property.isEnum = true;
@ -1488,7 +1487,7 @@ public class DefaultCodegen {
if (sp.getEnum() != null) {
List<Double> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
for (Double i : _enum) {
for(Double i : _enum) {
property._enum.add(i.toString());
}
property.isEnum = true;
@ -1506,7 +1505,7 @@ public class DefaultCodegen {
if (sp.getEnum() != null) {
List<Float> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
for (Float i : _enum) {
for(Float i : _enum) {
property._enum.add(i.toString());
}
property.isEnum = true;
@ -1524,7 +1523,7 @@ public class DefaultCodegen {
if (sp.getEnum() != null) {
List<String> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
for (String i : _enum) {
for(String i : _enum) {
property._enum.add(i.toString());
}
property.isEnum = true;
@ -1542,7 +1541,7 @@ public class DefaultCodegen {
if (sp.getEnum() != null) {
List<String> _enum = sp.getEnum();
property._enum = new ArrayList<String>();
for (String i : _enum) {
for(String i : _enum) {
property._enum.add(i.toString());
}
property.isEnum = true;
@ -1583,7 +1582,7 @@ public class DefaultCodegen {
if (property.items.isEnum) {
property.datatypeWithEnum = property.datatypeWithEnum.replace(property.items.baseType,
property.items.datatypeWithEnum);
if (property.defaultValue != null)
if(property.defaultValue != null)
property.defaultValue = property.defaultValue.replace(property.items.baseType, property.items.datatypeWithEnum);
}
}
@ -1618,7 +1617,6 @@ public class DefaultCodegen {
/**
* Override with any special handling of response codes
*
* @param responses Swagger Operation's responses
* @return default method response or <tt>null</tt> if not found
*/
@ -1757,7 +1755,7 @@ public class DefaultCodegen {
}
r.isDefault = response == methodResponse;
op.responses.add(r);
if (r.isBinary && r.isDefault) {
if (r.isBinary && r.isDefault){
op.isResponseBinary = Boolean.TRUE;
}
}
@ -2065,18 +2063,18 @@ public class DefaultCodegen {
setParameterBooleanFlagWithCodegenProperty(p, model);
p.dataType = model.datatype;
if (model.isEnum) {
if(model.isEnum) {
p.datatypeWithEnum = model.datatypeWithEnum;
}
p.isEnum = model.isEnum;
p._enum = model._enum;
p.allowableValues = model.allowableValues;
if (model.items != null && model.items.isEnum) {
if(model.items != null && model.items.isEnum) {
p.datatypeWithEnum = model.datatypeWithEnum;
p.items = model.items;
}
p.collectionFormat = collectionFormat;
if (collectionFormat != null && collectionFormat.equals("multi")) {
if(collectionFormat != null && collectionFormat.equals("multi")) {
p.isCollectionFormatMulti = true;
}
p.paramName = toParamName(qp.getName());
@ -2228,7 +2226,7 @@ public class DefaultCodegen {
} else if (param instanceof FormParameter) {
if ("file".equalsIgnoreCase(((FormParameter) param).getType())) {
p.isFile = true;
} else if ("file".equals(p.baseType)) {
} else if("file".equals(p.baseType)){
p.isFile = true;
} else {
p.notFile = true;
@ -2268,7 +2266,7 @@ public class DefaultCodegen {
sec.keyParamName = apiKeyDefinition.getName();
sec.isKeyInHeader = apiKeyDefinition.getIn() == In.HEADER;
sec.isKeyInQuery = !sec.isKeyInHeader;
} else if (schemeDefinition instanceof BasicAuthDefinition) {
} else if(schemeDefinition instanceof BasicAuthDefinition) {
sec.isKeyInHeader = sec.isKeyInQuery = sec.isApiKey = sec.isOAuth = false;
sec.isBasic = true;
} else {
@ -2281,7 +2279,7 @@ public class DefaultCodegen {
if (oauth2Definition.getScopes() != null) {
List<Map<String, Object>> scopes = new ArrayList<Map<String, Object>>();
int count = 0, numScopes = oauth2Definition.getScopes().size();
for (Map.Entry<String, String> scopeEntry : oauth2Definition.getScopes().entrySet()) {
for(Map.Entry<String, String> scopeEntry : oauth2Definition.getScopes().entrySet()) {
Map<String, Object> scope = new HashMap<String, Object>();
scope.put("scope", scopeEntry.getKey());
scope.put("description", scopeEntry.getValue());
@ -2436,13 +2434,13 @@ public class DefaultCodegen {
String uniqueName = co.operationId;
int counter = 0;
for (CodegenOperation op : opList) {
if (uniqueName.equals(op.operationId)) {
for(CodegenOperation op : opList) {
if(uniqueName.equals(op.operationId)) {
uniqueName = co.operationId + "_" + counter;
counter++;
counter ++;
}
}
if (!co.operationId.equals(uniqueName)) {
if(!co.operationId.equals(uniqueName)) {
LOGGER.warn("generated unique operationId `" + uniqueName + "`");
}
co.operationId = uniqueName;
@ -2542,7 +2540,7 @@ public class DefaultCodegen {
m.hasEnums = false;
Set<String> mandatory = required == null ? Collections.<String>emptySet()
Set<String> mandatory = required == null ? Collections.<String> emptySet()
: new TreeSet<String>(required);
addVars(m, m.vars, properties, mandatory);
m.allMandatory = m.mandatory = mandatory;
@ -2553,7 +2551,7 @@ public class DefaultCodegen {
}
if (allProperties != null) {
Set<String> allMandatory = allRequired == null ? Collections.<String>emptySet()
Set<String> allMandatory = allRequired == null ? Collections.<String> emptySet()
: new TreeSet<String>(allRequired);
addVars(m, m.allVars, allProperties, allMandatory);
m.allMandatory = allMandatory;
@ -2582,10 +2580,10 @@ public class DefaultCodegen {
m.hasEnums = true;
}
if (i + 1 != totalCount) {
if (i+1 != totalCount) {
cp.hasMore = true;
// check the next entry to see if it's read only
if (!Boolean.TRUE.equals(propertyList.get(i + 1).getValue().getReadOnly())) {
if (!Boolean.TRUE.equals(propertyList.get(i+1).getValue().getReadOnly())) {
cp.hasMoreNonReadOnly = true; // next entry is not ready only
}
}
@ -2596,7 +2594,7 @@ public class DefaultCodegen {
addImport(m, cp.baseType);
CodegenProperty innerCp = cp;
while (innerCp != null) {
while(innerCp != null) {
addImport(m, innerCp.complexType);
innerCp = innerCp.items;
}
@ -2729,6 +2727,7 @@ public class DefaultCodegen {
*
* @param templateName template name
* @param tag tag
*
* @return the API documentation file name with full path
*/
public String apiDocFilename(String templateName, String tag) {
@ -2741,6 +2740,7 @@ public class DefaultCodegen {
*
* @param templateName template name
* @param tag tag
*
* @return the API test file name with full path
*/
public String apiTestFilename(String templateName, String tag) {
@ -2763,7 +2763,6 @@ public class DefaultCodegen {
/**
* All library templates supported.
* (key: library name, value: library description)
*
* @return the supported libraries
*/
public Map<String, String> supportedLibraries() {
@ -2942,16 +2941,17 @@ public class DefaultCodegen {
public void writeOptional(String outputFolder, SupportingFile supportingFile) {
String folder = "";
if (outputFolder != null && !"".equals(outputFolder)) {
if(outputFolder != null && !"".equals(outputFolder)) {
folder += outputFolder + File.separator;
}
folder += supportingFile.folder;
if (!"".equals(folder)) {
if(!"".equals(folder)) {
folder += File.separator + supportingFile.destinationFilename;
} else {
}
else {
folder = supportingFile.destinationFilename;
}
if (!new File(folder).exists()) {
if(!new File(folder).exists()) {
supportingFiles.add(supportingFile);
} else {
LOGGER.info("Skipped overwriting " + supportingFile.destinationFilename + " as the file already exists in " + folder);

View File

@ -475,7 +475,7 @@ public class JavaModelTest {
@DataProvider(name = "modelNames")
public static Object[][] primeNumbers() {
return new Object[][]{
return new Object[][] {
{"sample", "Sample"},
{"sample_name", "SampleName"},
{"sample__name", "SampleName"},