[Java Play Framework] Remove most warnings + bug fixes (#6275)

* Removals of most of the warnings found by lint

* Removals of most of the warnings found by lint (PART 2)

* Removals of most of the warnings found by lint (PART 3)

* Removals of most of the warnings found by lint (PART 4)

* Removals of most of the warnings found by lint (PART 5)

* Fix conversion error

* Removal of unnecessary import. Other will need more complex login in the generator itself (not in the mustache files)

* Add missing imports + fix to the regex. Generation of the samples
This commit is contained in:
Jean-François Côté
2017-08-11 03:38:18 -04:00
committed by wing328
parent b0333af8bd
commit ab28c7c825
140 changed files with 849 additions and 874 deletions

View File

@@ -1,14 +1,15 @@
package apimodels;
import java.util.Objects;
import com.fasterxml.jackson.annotation.*;
import java.util.Set;
import javax.validation.*;
import java.util.Objects;
import javax.validation.constraints.*;
/**
* A category for a pet
*/
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
public class Category {
@JsonProperty("id")
private Long id = null;
@@ -60,8 +61,8 @@ public class Category {
return false;
}
Category category = (Category) o;
return Objects.equals(this.id, category.id) &&
Objects.equals(this.name, category.name);
return Objects.equals(id, category.id) &&
Objects.equals(name, category.name);
}
@Override
@@ -69,6 +70,7 @@ public class Category {
return Objects.hash(id, name);
}
@SuppressWarnings("StringBufferReplaceableByString")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();

View File

@@ -1,14 +1,15 @@
package apimodels;
import java.util.Objects;
import com.fasterxml.jackson.annotation.*;
import java.util.Set;
import javax.validation.*;
import java.util.Objects;
import javax.validation.constraints.*;
/**
* Describes the result of uploading an image resource
*/
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
public class ModelApiResponse {
@JsonProperty("code")
private Integer code = null;
@@ -80,9 +81,9 @@ public class ModelApiResponse {
return false;
}
ModelApiResponse _apiResponse = (ModelApiResponse) o;
return Objects.equals(this.code, _apiResponse.code) &&
Objects.equals(this.type, _apiResponse.type) &&
Objects.equals(this.message, _apiResponse.message);
return Objects.equals(code, _apiResponse.code) &&
Objects.equals(type, _apiResponse.type) &&
Objects.equals(message, _apiResponse.message);
}
@Override
@@ -90,6 +91,7 @@ public class ModelApiResponse {
return Objects.hash(code, type, message);
}
@SuppressWarnings("StringBufferReplaceableByString")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();

View File

@@ -1,15 +1,16 @@
package apimodels;
import java.util.Objects;
import java.time.OffsetDateTime;
import com.fasterxml.jackson.annotation.*;
import java.util.Set;
import javax.validation.*;
import java.util.Objects;
import javax.validation.constraints.*;
/**
* An order for a pets from the pet store
*/
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
public class Order {
@JsonProperty("id")
private Long id = null;
@@ -33,7 +34,7 @@ public class Order {
DELIVERED("delivered");
private String value;
private final String value;
StatusEnum(String value) {
this.value = value;
@@ -175,12 +176,12 @@ public class Order {
return false;
}
Order order = (Order) o;
return Objects.equals(this.id, order.id) &&
Objects.equals(this.petId, order.petId) &&
Objects.equals(this.quantity, order.quantity) &&
Objects.equals(this.shipDate, order.shipDate) &&
Objects.equals(this.status, order.status) &&
Objects.equals(this.complete, order.complete);
return Objects.equals(id, order.id) &&
Objects.equals(petId, order.petId) &&
Objects.equals(quantity, order.quantity) &&
Objects.equals(shipDate, order.shipDate) &&
Objects.equals(status, order.status) &&
Objects.equals(complete, order.complete);
}
@Override
@@ -188,6 +189,7 @@ public class Order {
return Objects.hash(id, petId, quantity, shipDate, status, complete);
}
@SuppressWarnings("StringBufferReplaceableByString")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();

View File

@@ -1,6 +1,5 @@
package apimodels;
import java.util.Objects;
import apimodels.Category;
import apimodels.Tag;
import java.util.ArrayList;
@@ -8,11 +7,13 @@ import java.util.List;
import com.fasterxml.jackson.annotation.*;
import java.util.Set;
import javax.validation.*;
import java.util.Objects;
import javax.validation.constraints.*;
/**
* A pet for sale in the pet store
*/
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
public class Pet {
@JsonProperty("id")
private Long id = null;
@@ -24,7 +25,7 @@ public class Pet {
private String name = null;
@JsonProperty("photoUrls")
private List<String> photoUrls = new ArrayList<String>();
private List<String> photoUrls = new ArrayList<>();
@JsonProperty("tags")
private List<Tag> tags = null;
@@ -39,7 +40,7 @@ public class Pet {
SOLD("sold");
private String value;
private final String value;
StatusEnum(String value) {
this.value = value;
@@ -124,7 +125,7 @@ public class Pet {
}
public Pet addPhotoUrlsItem(String photoUrlsItem) {
this.photoUrls.add(photoUrlsItem);
photoUrls.add(photoUrlsItem);
return this;
}
@@ -147,10 +148,10 @@ public class Pet {
}
public Pet addTagsItem(Tag tagsItem) {
if (this.tags == null) {
this.tags = new ArrayList<Tag>();
if (tags == null) {
tags = new ArrayList<>();
}
this.tags.add(tagsItem);
tags.add(tagsItem);
return this;
}
@@ -194,12 +195,12 @@ public class Pet {
return false;
}
Pet pet = (Pet) o;
return Objects.equals(this.id, pet.id) &&
Objects.equals(this.category, pet.category) &&
Objects.equals(this.name, pet.name) &&
Objects.equals(this.photoUrls, pet.photoUrls) &&
Objects.equals(this.tags, pet.tags) &&
Objects.equals(this.status, pet.status);
return Objects.equals(id, pet.id) &&
Objects.equals(category, pet.category) &&
Objects.equals(name, pet.name) &&
Objects.equals(photoUrls, pet.photoUrls) &&
Objects.equals(tags, pet.tags) &&
Objects.equals(status, pet.status);
}
@Override
@@ -207,6 +208,7 @@ public class Pet {
return Objects.hash(id, category, name, photoUrls, tags, status);
}
@SuppressWarnings("StringBufferReplaceableByString")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();

View File

@@ -1,14 +1,15 @@
package apimodels;
import java.util.Objects;
import com.fasterxml.jackson.annotation.*;
import java.util.Set;
import javax.validation.*;
import java.util.Objects;
import javax.validation.constraints.*;
/**
* A tag for a pet
*/
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
public class Tag {
@JsonProperty("id")
private Long id = null;
@@ -60,8 +61,8 @@ public class Tag {
return false;
}
Tag tag = (Tag) o;
return Objects.equals(this.id, tag.id) &&
Objects.equals(this.name, tag.name);
return Objects.equals(id, tag.id) &&
Objects.equals(name, tag.name);
}
@Override
@@ -69,6 +70,7 @@ public class Tag {
return Objects.hash(id, name);
}
@SuppressWarnings("StringBufferReplaceableByString")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();

View File

@@ -1,14 +1,15 @@
package apimodels;
import java.util.Objects;
import com.fasterxml.jackson.annotation.*;
import java.util.Set;
import javax.validation.*;
import java.util.Objects;
import javax.validation.constraints.*;
/**
* A User who is purchasing from the pet store
*/
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
public class User {
@JsonProperty("id")
private Long id = null;
@@ -180,14 +181,14 @@ public class User {
return false;
}
User user = (User) o;
return Objects.equals(this.id, user.id) &&
Objects.equals(this.username, user.username) &&
Objects.equals(this.firstName, user.firstName) &&
Objects.equals(this.lastName, user.lastName) &&
Objects.equals(this.email, user.email) &&
Objects.equals(this.password, user.password) &&
Objects.equals(this.phone, user.phone) &&
Objects.equals(this.userStatus, user.userStatus);
return Objects.equals(id, user.id) &&
Objects.equals(username, user.username) &&
Objects.equals(firstName, user.firstName) &&
Objects.equals(lastName, user.lastName) &&
Objects.equals(email, user.email) &&
Objects.equals(password, user.password) &&
Objects.equals(phone, user.phone) &&
Objects.equals(userStatus, user.userStatus);
}
@Override
@@ -195,6 +196,7 @@ public class User {
return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus);
}
@SuppressWarnings("StringBufferReplaceableByString")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();

View File

@@ -13,6 +13,7 @@ import java.util.ArrayList;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.inject.Inject;
import java.io.File;
import java.io.IOException;
import swagger.SwaggerUtils;
import com.fasterxml.jackson.core.type.TypeReference;
@@ -43,9 +44,7 @@ public class PetApiController extends Controller {
body.validate();
imp.addPet(body);
return ok();
}
@ApiAction
@@ -53,15 +52,13 @@ public class PetApiController extends Controller {
String valueapiKey = request().getHeader("api_key");
String apiKey;
if (valueapiKey != null) {
apiKey = (String)valueapiKey;
apiKey = valueapiKey;
} else {
apiKey = null;
}
imp.deletePet(petId, apiKey);
return ok();
}
@ApiAction
@@ -78,8 +75,6 @@ public class PetApiController extends Controller {
}
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
@ApiAction
@@ -96,8 +91,6 @@ public class PetApiController extends Controller {
}
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
@ApiAction
@@ -106,8 +99,6 @@ public class PetApiController extends Controller {
obj.validate();
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
@ApiAction
@@ -119,9 +110,7 @@ public class PetApiController extends Controller {
body.validate();
imp.updatePet(body);
return ok();
}
@ApiAction
@@ -129,7 +118,7 @@ public class PetApiController extends Controller {
String valuename = (request().body().asMultipartFormData().asFormUrlEncoded().get("name"))[0];
String name;
if (valuename != null) {
name = (String)valuename;
name = valuename;
} else {
name = null;
@@ -137,15 +126,13 @@ public class PetApiController extends Controller {
String valuestatus = (request().body().asMultipartFormData().asFormUrlEncoded().get("status"))[0];
String status;
if (valuestatus != null) {
status = (String)valuestatus;
status = valuestatus;
} else {
status = null;
}
imp.updatePetWithForm(petId, name, status);
return ok();
}
@ApiAction
@@ -153,17 +140,15 @@ public class PetApiController extends Controller {
String valueadditionalMetadata = (request().body().asMultipartFormData().asFormUrlEncoded().get("additionalMetadata"))[0];
String additionalMetadata;
if (valueadditionalMetadata != null) {
additionalMetadata = (String)valueadditionalMetadata;
additionalMetadata = valueadditionalMetadata;
} else {
additionalMetadata = null;
}
Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file");
ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file);
ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file);
obj.validate();
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
}

View File

@@ -11,6 +11,7 @@ import java.util.HashMap;
import javax.validation.constraints.*;
@SuppressWarnings("RedundantThrows")
public interface PetApiControllerImpInterface {
void addPet(Pet body) ;

View File

@@ -12,6 +12,7 @@ import java.util.ArrayList;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.inject.Inject;
import java.io.File;
import java.io.IOException;
import swagger.SwaggerUtils;
import com.fasterxml.jackson.core.type.TypeReference;
@@ -36,9 +37,7 @@ public class StoreApiController extends Controller {
@ApiAction
public Result deleteOrder(String orderId) {
imp.deleteOrder(orderId);
return ok();
}
@ApiAction
@@ -46,8 +45,6 @@ public class StoreApiController extends Controller {
Map<String, Integer> obj = imp.getInventory();
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
@ApiAction
@@ -56,8 +53,6 @@ public class StoreApiController extends Controller {
obj.validate();
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
@ApiAction
@@ -72,7 +67,5 @@ public class StoreApiController extends Controller {
obj.validate();
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
}

View File

@@ -10,6 +10,7 @@ import java.util.HashMap;
import javax.validation.constraints.*;
@SuppressWarnings("RedundantThrows")
public interface StoreApiControllerImpInterface {
void deleteOrder(String orderId) ;

View File

@@ -12,6 +12,7 @@ import java.util.ArrayList;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.inject.Inject;
import java.io.File;
import java.io.IOException;
import swagger.SwaggerUtils;
import com.fasterxml.jackson.core.type.TypeReference;
@@ -42,9 +43,7 @@ public class UserApiController extends Controller {
body.validate();
imp.createUser(body);
return ok();
}
@ApiAction
@@ -58,9 +57,7 @@ public class UserApiController extends Controller {
}
imp.createUsersWithArrayInput(body);
return ok();
}
@ApiAction
@@ -74,17 +71,13 @@ public class UserApiController extends Controller {
}
imp.createUsersWithListInput(body);
return ok();
}
@ApiAction
public Result deleteUser(String username) {
imp.deleteUser(username);
return ok();
}
@ApiAction
@@ -93,8 +86,6 @@ public class UserApiController extends Controller {
obj.validate();
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
@ApiAction
@@ -102,26 +93,22 @@ public class UserApiController extends Controller {
String valueusername = request().getQueryString("username");
String username;
username = (String)valueusername;
username = valueusername;
String valuepassword = request().getQueryString("password");
String password;
password = (String)valuepassword;
password = valuepassword;
String obj = imp.loginUser(username, password);
JsonNode result = mapper.valueToTree(obj);
return ok(result);
}
@ApiAction
public Result logoutUser() {
imp.logoutUser();
return ok();
}
@ApiAction
@@ -133,8 +120,6 @@ public class UserApiController extends Controller {
body.validate();
imp.updateUser(username, body);
return ok();
}
}

View File

@@ -10,6 +10,7 @@ import java.util.HashMap;
import javax.validation.constraints.*;
@SuppressWarnings("RedundantThrows")
public interface UserApiControllerImpInterface {
void createUser(User body) ;