Skip to content
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

Fix fields and getters name collision #178

Merged
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
22 changes: 11 additions & 11 deletions src/main/java/de/sstoehr/harreader/model/HarRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class HarRequest {

protected static final Long DEFAULT_SIZE = -1L;

private HttpMethod method;
private String rawMethod;
private HttpMethod parsedMethod;
private String method;
private String url;
private String httpVersion;
private List<HarCookie> cookies;
Expand All @@ -39,26 +39,26 @@ public class HarRequest {
* @return Request method, null if not present.
*/
public HttpMethod getMethod() {
return method;
return parsedMethod;
}

public void setMethod(HttpMethod method) {
this.method = method;
this.rawMethod = method.name();
this.parsedMethod = method;
this.method = method.name();
}

/**
* @return Request method, null if not present.
*/
@JsonProperty("method")
public String getRawMethod() {
return rawMethod;
return method;
}

@JsonProperty("method")
public void setRawMethod(String rawMethod) {
this.method = HttpMethod.fromString(rawMethod);
this.rawMethod = rawMethod;
this.parsedMethod = HttpMethod.fromString(rawMethod);
this.method = rawMethod;
}

/**
Expand Down Expand Up @@ -198,8 +198,8 @@ public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof HarRequest)) return false;
HarRequest that = (HarRequest) o;
return method == that.method &&
Objects.equals(rawMethod, that.rawMethod) &&
return parsedMethod == that.parsedMethod &&
Objects.equals(method, that.method) &&
Objects.equals(url, that.url) &&
Objects.equals(httpVersion, that.httpVersion) &&
Objects.equals(cookies, that.cookies) &&
Expand All @@ -214,7 +214,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(method, rawMethod, url, httpVersion, cookies, headers, queryString, postData, headersSize,
return Objects.hash(parsedMethod, method, url, httpVersion, cookies, headers, queryString, postData, headersSize,
bodySize, comment, additional);
}
}
26 changes: 13 additions & 13 deletions src/main/java/de/sstoehr/harreader/model/HarResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class HarResponse {

protected static final Long DEFAULT_SIZE = -1L;

private HttpStatus status;
private int rawStatus = HttpStatus.UNKNOWN_HTTP_STATUS.getCode();
private HttpStatus parsedStatus;
private int status = HttpStatus.UNKNOWN_HTTP_STATUS.getCode();
private String statusText;
private String httpVersion;
private List<HarCookie> cookies;
Expand All @@ -39,29 +39,29 @@ public class HarResponse {
* @return Response status, 0 if not present or unknown.
*/
public int getStatus() {
if (status == null) {
status = HttpStatus.UNKNOWN_HTTP_STATUS;
if (parsedStatus == null) {
parsedStatus = HttpStatus.UNKNOWN_HTTP_STATUS;
}
return status.getCode();
return parsedStatus.getCode();
}

public void setStatus(int status) {
this.status = HttpStatus.byCode(status);
this.rawStatus = status;
this.parsedStatus = HttpStatus.byCode(status);
this.status = status;
}

/**
* @return Response status, 0 if not present
*/
@JsonProperty("status")
public int getRawStatus() {
return rawStatus;
return status;
}

@JsonProperty("status")
public void setRawStatus(int rawStatus) {
this.status = HttpStatus.byCode(rawStatus);
this.rawStatus = rawStatus;
this.parsedStatus = HttpStatus.byCode(rawStatus);
this.status = rawStatus;
}

/**
Expand Down Expand Up @@ -199,8 +199,8 @@ public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof HarResponse)) return false;
HarResponse that = (HarResponse) o;
return status == that.status &&
rawStatus == that.rawStatus &&
return parsedStatus == that.parsedStatus &&
status == that.status &&
Objects.equals(statusText, that.statusText) &&
Objects.equals(httpVersion, that.httpVersion) &&
Objects.equals(cookies, that.cookies) &&
Expand All @@ -215,7 +215,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(status, rawStatus, statusText, httpVersion, cookies, headers, content, redirectURL, headersSize,
return Objects.hash(parsedStatus, status, statusText, httpVersion, cookies, headers, content, redirectURL, headersSize,
bodySize, comment, additional);
}
}