Skip to content

Commit

Permalink
Merge pull request #1733 from DevFactory/staging/override-annotation-…
Browse files Browse the repository at this point in the history
…should-be-used-where-necessary-fix-1

Fixing squid:S1161 - @OverRide annotation should be used where necessary
  • Loading branch information
wing328 committed Dec 22, 2015
2 parents 7305b9b + 49a6d0e commit 55fece1
Show file tree
Hide file tree
Showing 42 changed files with 143 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public File convert(SupportingFile support) {
*/
private Mustache.TemplateLoader loader(final DefaultGenerator generator) {
return new Mustache.TemplateLoader() {
@Override
public Reader getTemplate(String name) {
return generator.getTemplateReader(TEMPLATE_DIR_CLASSPATH
+ File.separator + name.concat(MUSTACHE_EXTENSION));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ protected void generate(String[] args) {
String template = readTemplate(templateDir + File.separator + support.templateFile);
Template tmpl = Mustache.compiler()
.withLoader(new Mustache.TemplateLoader() {
@Override
public Reader getTemplate(String name) {
return getTemplateReader(templateDir + File.separator + name + ".mustache");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public String apiFileFolder() {
return outputFolder + "/" + apiPackage().replace('.', File.separatorChar);
}

@Override
public String modelFileFolder() {
return outputFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,17 @@ public AkkaScalaClientCodegen() {
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
}

@Override
public CodegenType getTag() {
return CodegenType.CLIENT;
}

@Override
public String getName() {
return "akka-scala";
}

@Override
public String getHelp() {
return "Generates a Scala client library base on Akka/Spray.";
}
Expand All @@ -176,6 +179,7 @@ public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}

@Override
public String modelFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
Expand Down Expand Up @@ -321,6 +325,7 @@ public String toInstantiationType(Property p) {
}
}

@Override
public String toDefaultValue(Property p) {
if (!p.getRequired()) {
return "None";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,17 @@ public AndroidClientCodegen() {
.defaultValue("true"));
}

@Override
public CodegenType getTag() {
return CodegenType.CLIENT;
}

@Override
public String getName() {
return "android";
}

@Override
public String getHelp() {
return "Generates an Android client library.";
}
Expand All @@ -93,6 +96,7 @@ public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}

@Override
public String modelFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,17 @@ public AsyncScalaClientCodegen() {
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
}

@Override
public CodegenType getTag() {
return CodegenType.CLIENT;
}

@Override
public String getName() {
return "async-scala";
}

@Override
public String getHelp() {
return "Generates an Asynchronous Scala client library.";
}
Expand All @@ -133,6 +136,7 @@ public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}

@Override
public String modelFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
Expand Down Expand Up @@ -182,6 +186,7 @@ public String toInstantiationType(Property p) {
}
}

@Override
public String toDefaultValue(Property p) {
if (p instanceof StringProperty) {
return "null";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,17 @@ public void processOpts() {

}

@Override
public CodegenType getTag() {
return CodegenType.CLIENT;
}

@Override
public String getName() {
return "csharp";
}

@Override
public String getHelp() {
return "Generates a CSharp client library.";
}
Expand All @@ -157,6 +160,7 @@ public String apiFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar);
}

@Override
public String modelFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,17 @@ public void setPackageVersion(String packageVersion) {
this.packageVersion = packageVersion;
}

@Override
public CodegenType getTag() {
return CodegenType.CLIENT;
}

@Override
public String getName() {
return "CsharpDotNet2";
}

@Override
public String getHelp() {
return "Generates a C# .Net 2.0 client library.";
}
Expand All @@ -157,6 +160,7 @@ public String apiFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar);
}

@Override
public String modelFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,17 @@ public DartClientCodegen() {
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "source folder for generated code"));
}

@Override
public CodegenType getTag() {
return CodegenType.CLIENT;
}

@Override
public String getName() {
return "dart";
}

@Override
public String getHelp() {
return "Generates a Dart client library.";
}
Expand Down Expand Up @@ -157,6 +160,7 @@ public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}

@Override
public String modelFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,17 @@ private static String dropDots(String str) {
return str.replaceAll("\\.", "_");
}

@Override
public CodegenType getTag() {
return CodegenType.CLIENT;
}

@Override
public String getName() {
return "flash";
}

@Override
public String getHelp() {
return "Generates a Flash client library.";
}
Expand All @@ -179,6 +182,7 @@ public String apiFileFolder() {
+ apiPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar);
}

@Override
public String modelFileFolder() {
return (outputFolder + File.separatorChar + sourceFolder + File.separatorChar
+ modelPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar);
Expand Down Expand Up @@ -214,6 +218,7 @@ public String getSwaggerType(Property p) {
return type;
}

@Override
public String toDefaultValue(Property p) {
if (p instanceof StringProperty) {
return "null";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public void processOpts() {
}
}

@Override
public String apiPackage() {
return controllerPackage;
}
Expand All @@ -142,6 +143,7 @@ public String apiPackage() {
* @return the CodegenType for this generator
* @see io.swagger.codegen.CodegenType
*/
@Override
public CodegenType getTag() {
return CodegenType.SERVER;
}
Expand All @@ -152,6 +154,7 @@ public CodegenType getTag() {
*
* @return the friendly name for the generator
*/
@Override
public String getName() {
return "python-flask";
}
Expand All @@ -162,6 +165,7 @@ public String getName() {
*
* @return A string value for the help message
*/
@Override
public String getHelp() {
return "Generates a python server library using the connexion project. By default, " +
"it will also generate service classes--which you can disable with the `-Dnoservice` environment variable.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class JMeterCodegen extends DefaultCodegen implements CodegenConfig {
* @return the CodegenType for this generator
* @see io.swagger.codegen.CodegenType
*/
@Override
public CodegenType getTag() {
return CodegenType.CLIENT;
}
Expand All @@ -32,6 +33,7 @@ public CodegenType getTag() {
*
* @return the friendly name for the generator
*/
@Override
public String getName() {
return "jmeter";
}
Expand All @@ -42,6 +44,7 @@ public String getName() {
*
* @return A string value for the help message
*/
@Override
public String getHelp() {
return "Generates a JMeter .jmx file.";
}
Expand Down Expand Up @@ -97,6 +100,7 @@ public JMeterCodegen() {
// supportingFiles.add(new SupportingFile("testdata-localhost.mustache", "input", "testdata-localhost.csv"));
}

@Override
public void preprocessSwagger(Swagger swagger) {
if (swagger != null && swagger.getPaths() != null) {
for (String pathname : swagger.getPaths().keySet()) {
Expand Down Expand Up @@ -126,6 +130,7 @@ public String escapeReservedWord(String name) {
* Location to write model files. You can use the modelPackage() as defined when the class is
* instantiated
*/
@Override
public String modelFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
return objs;
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
if("retrofit".equals(getLibrary()) || "retrofit2".equals(getLibrary())) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
Expand All @@ -555,6 +556,7 @@ public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
return objs;
}

@Override
public void preprocessSwagger(Swagger swagger) {
if (swagger != null && swagger.getPaths() != null) {
for (String pathname : swagger.getPaths().keySet()) {
Expand Down Expand Up @@ -606,6 +608,7 @@ private String getAccept(Operation operation) {
return accepts;
}

@Override
protected boolean needToImport(String type) {
return super.needToImport(type) && type.indexOf(".") < 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ public JavaInflectorServerCodegen() {
);
}

@Override
public CodegenType getTag() {
return CodegenType.SERVER;
}

@Override
public String getName() {
return "inflector";
}

@Override
public String getHelp() {
return "Generates a Java Inflector Server application.";
}
Expand Down Expand Up @@ -131,6 +134,7 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
return objs;
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
if (operations != null) {
Expand Down Expand Up @@ -188,6 +192,7 @@ public String toApiName(String name) {
return camelize(name)+ "Controller";
}

@Override
public boolean shouldOverwrite(String filename) {
return super.shouldOverwrite(filename);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
return objs;
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
if("retrofit".equals(getLibrary())) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
Expand All @@ -458,6 +459,7 @@ public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
return objs;
}

@Override
protected boolean needToImport(String type) {
return !defaultIncludes.contains(type)
&& !languageSpecificPrimitives.contains(type);
Expand Down
Loading

0 comments on commit 55fece1

Please sign in to comment.