Skip to content

Use LinkedHashMap as default map implementation #2021 #2022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ public void testSerializeSecurityRequirement_UsingSpecCompliantMethods() throws
.security(new SecurityRequirement().requirement("api_key").requirement("basic_auth"))
.security(new SecurityRequirement().requirement("oauth2", Arrays.asList("hello", "world")));
json = Json.mapper().writeValueAsString(swagger);
assertEquals(json, "{\"swagger\":\"2.0\",\"security\":[{\"basic_auth\":[],\"api_key\":[]},{\"oauth2\":[\"hello\",\"world\"]}]}");
assertEquals(json, "{\"swagger\":\"2.0\",\"security\":[{\"api_key\":[],\"basic_auth\":[]},{\"oauth2\":[\"hello\",\"world\"]}]}");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public abstract class AbstractModel implements Model {
private ExternalDocs externalDocs;
private String reference;
private String title;
private final Map<String, Object> vendorExtensions = new HashMap<String, Object>();
private final Map<String, Object> vendorExtensions = new LinkedHashMap<String, Object>();

@Override
public ExternalDocs getExternalDocs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
Expand All @@ -20,7 +20,7 @@ public class ExternalDocs {
*/
private String url;

private final Map<String, Object> vendorExtensions = new HashMap<String, Object>();
private final Map<String, Object> vendorExtensions = new LinkedHashMap<String, Object>();

public ExternalDocs() {
}
Expand Down Expand Up @@ -115,4 +115,4 @@ public boolean equals(Object obj) {
}
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class Info {
Expand All @@ -13,7 +13,7 @@ public class Info {
private String termsOfService;
private Contact contact;
private License license;
private Map<String, Object> vendorExtensions = new HashMap<String, Object>();
private Map<String, Object> vendorExtensions = new LinkedHashMap<String, Object>();

public Info version(String version) {
this.setVersion(version);
Expand Down Expand Up @@ -212,4 +212,4 @@ public boolean equals(Object obj) {
}
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class License {
private final Map<String, Object> vendorExtensions = new HashMap<String, Object>();
private final Map<String, Object> vendorExtensions = new LinkedHashMap<String, Object>();
private String name;
private String url;

Expand Down Expand Up @@ -86,4 +86,4 @@ public boolean equals(Object obj) {
}
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import io.swagger.models.parameters.Parameter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class Operation {
private final Map<String, Object> vendorExtensions = new HashMap<String, Object>();
private final Map<String, Object> vendorExtensions = new LinkedHashMap<String, Object>();
private List<String> tags;
private String summary;
private String description;
Expand Down Expand Up @@ -220,7 +220,7 @@ public void setResponses(Map<String, Response> responses) {

public void addResponse(String key, Response response) {
if (this.responses == null) {
this.responses = new HashMap<String, Response>();
this.responses = new LinkedHashMap<String, Response>();
}
this.responses.put(key, response);
}
Expand All @@ -237,7 +237,7 @@ public void addSecurity(String name, List<String> scopes) {
if (this.security == null) {
this.security = new ArrayList<Map<String, List<String>>>();
}
Map<String, List<String>> req = new HashMap<String, List<String>>();
Map<String, List<String>> req = new LinkedHashMap<String, List<String>>();
if (scopes == null) {
scopes = new ArrayList<String>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
import io.swagger.models.parameters.Parameter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@JsonPropertyOrder({"get", "head", "post", "put", "delete", "options", "patch"})
public class Path {

private final Map<String, Object> vendorExtensions = new HashMap<String, Object>();
private final Map<String, Object> vendorExtensions = new LinkedHashMap<String, Object>();
private Operation get;
private Operation put;
private Operation post;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.fasterxml.jackson.annotation.JsonAnySetter;
import io.swagger.models.properties.Property;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

Expand All @@ -13,7 +12,7 @@ public class Response {
private Property schema;
private Map<String, Object> examples;
private Map<String, Property> headers;
private final Map<String, Object> vendorExtensions = new HashMap<String, Object>();
private final Map<String, Object> vendorExtensions = new LinkedHashMap<String, Object>();

public Response schema(Property property) {
this.setSchema(property);
Expand All @@ -27,7 +26,7 @@ public Response description(String description) {

public Response example(String type, Object example) {
if (examples == null) {
examples = new HashMap<String, Object>();
examples = new LinkedHashMap<String, Object>();
}
examples.put(type, example);
return this;
Expand Down Expand Up @@ -162,4 +161,4 @@ public boolean equals(Object obj) {
}
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class SecurityRequirement {
private String name;
private List<String> scopes;
// private final Map<String, Object> vendorExtensions = new HashMap<String, Object>();
private Map<String, List<String>> requirements = new HashMap<String, List<String>>();
private Map<String, List<String>> requirements = new LinkedHashMap<String, List<String>>();

public SecurityRequirement() {
}
Expand All @@ -30,7 +30,7 @@ public SecurityRequirement scope(String scope) {

public SecurityRequirement requirement(String name, List<String> scopes) {
if(requirements == null) {
requirements = new HashMap<String, List<String>>();
requirements = new LinkedHashMap<String, List<String>>();
}

if(scopes == null) {
Expand Down Expand Up @@ -152,4 +152,4 @@ public boolean equals(Object obj) {
}
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import io.swagger.models.parameters.Parameter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -139,7 +138,7 @@ public Swagger security(SecurityRequirement securityRequirement) {

public Swagger vendorExtension(String key, Object extension) {
if(this.vendorExtensions == null) {
this.vendorExtensions = new HashMap<String, Object>();
this.vendorExtensions = new LinkedHashMap<String, Object>();
}
this.vendorExtensions.put(key, extension);
return this;
Expand Down Expand Up @@ -281,7 +280,7 @@ public void setSecurityDefinitions(Map<String, SecuritySchemeDefinition> securit

public void addSecurityDefinition(String name, SecuritySchemeDefinition securityDefinition) {
if (this.securityDefinitions == null) {
this.securityDefinitions = new HashMap<String, SecuritySchemeDefinition>();
this.securityDefinitions = new LinkedHashMap<String, SecuritySchemeDefinition>();
}
this.securityDefinitions.put(name, securityDefinition);
}
Expand Down Expand Up @@ -338,7 +337,7 @@ public void setDefinitions(Map<String, Model> definitions) {

public void addDefinition(String key, Model model) {
if (this.definitions == null) {
this.definitions = new HashMap<String, Model>();
this.definitions = new LinkedHashMap<String, Model>();
}
this.definitions.put(key, model);
}
Expand All @@ -360,7 +359,7 @@ public Parameter getParameter(String parameter) {

public void addParameter(String key, Parameter parameter) {
if (this.parameters == null) {
this.parameters = new HashMap<String, Parameter>();
this.parameters = new LinkedHashMap<String, Parameter>();
}
this.parameters.put(key, parameter);
}
Expand Down Expand Up @@ -542,7 +541,7 @@ public Swagger vendorExtensions(Map<String, Object> vendorExtensions) {
}

if( this.vendorExtensions == null ){
this.vendorExtensions = new HashMap<String, Object>();
this.vendorExtensions = new LinkedHashMap<String, Object>();
}

this.vendorExtensions.putAll( vendorExtensions );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class Tag {
private final Map<String, Object> vendorExtensions = new HashMap<String, Object>();
private final Map<String, Object> vendorExtensions = new LinkedHashMap<String, Object>();
private String name;
private String description;
private ExternalDocs externalDocs;
Expand Down Expand Up @@ -122,4 +122,4 @@ public boolean equals(Object obj) {
}
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;


public abstract class AbstractSecuritySchemeDefinition implements SecuritySchemeDefinition {

private final Map<String, Object> vendorExtensions = new HashMap<String, Object>();
private final Map<String, Object> vendorExtensions = new LinkedHashMap<String, Object>();

private String description;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public enum In {
HEADER, QUERY;

private static Map<String, In> names = new HashMap<String, In>();
private static Map<String, In> names = new LinkedHashMap<String, In>();

@JsonCreator
public static In forValue(String value) {
Expand All @@ -31,4 +31,4 @@ public String toValue() {
names.put("header", HEADER);
names.put("query", QUERY);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.swagger.models.auth;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class OAuth2Definition extends AbstractSecuritySchemeDefinition {
Expand Down Expand Up @@ -77,7 +77,7 @@ public void setScopes(Map<String, String> scopes) {

public void addScope(String name, String description) {
if (this.scopes == null) {
this.scopes = new HashMap<String, String>();
this.scopes = new LinkedHashMap<String, String>();
}
this.scopes.put(name, description);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public abstract class AbstractParameter {
private final Map<String, Object> vendorExtensions = new HashMap<String, Object>();
private final Map<String, Object> vendorExtensions = new LinkedHashMap<String, Object>();
protected String in;
protected String name;
protected String description;
Expand Down Expand Up @@ -150,4 +150,4 @@ public boolean equals(Object obj) {
}
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.models.Model;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class BodyParameter extends AbstractParameter implements Parameter {
Expand Down Expand Up @@ -44,7 +44,7 @@ public void setSchema(Model schema) {

public void addExample(String mediaType, String value) {
if(examples == null) {
examples = new HashMap<String, String>();
examples = new LinkedHashMap<String, String>();
}
examples.put(mediaType, value);
}
Expand Down Expand Up @@ -87,4 +87,4 @@ public boolean equals(Object obj) {
}
return true;
}
}
}
Loading