Skip to content

Commit

Permalink
NoIssue: code smells removed
Browse files Browse the repository at this point in the history
  • Loading branch information
nbartels committed Jun 5, 2020
1 parent 279f015 commit f5aac7e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
7 changes: 4 additions & 3 deletions src/main/java/com/restfb/DefaultFacebookClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class DefaultFacebookClient extends BaseFacebookClient implements Faceboo
public static final String APP_ID = "appId";
public static final String APP_SECRET = "appSecret";
public static final String SCOPE = "scope";
public static final String CANNOT_EXTRACT_ACCESS_TOKEN_MESSAGE = "Unable to extract access token from response.";
/**
* Graph API access token.
*/
Expand Down Expand Up @@ -428,7 +429,7 @@ public AccessToken obtainAppAccessToken(String appId, String appSecret) {
try {
return getAccessTokenFromResponse(response);
} catch (Exception t) {
throw new FacebookResponseContentException("Unable to extract access token from response.", t);
throw new FacebookResponseContentException(CANNOT_EXTRACT_ACCESS_TOKEN_MESSAGE, t);
}
}

Expand Down Expand Up @@ -477,7 +478,7 @@ public AccessToken obtainUserAccessToken(String appId, String appSecret, String
try {
return getAccessTokenFromResponse(response);
} catch (Exception t) {
throw new FacebookResponseContentException("Unable to extract access token from response.", t);
throw new FacebookResponseContentException(CANNOT_EXTRACT_ACCESS_TOKEN_MESSAGE, t);
}
}

Expand Down Expand Up @@ -510,7 +511,7 @@ public AccessToken obtainExtendedAccessToken(String appId, String appSecret, Str
try {
return getAccessTokenFromResponse(response);
} catch (Exception t) {
throw new FacebookResponseContentException("Unable to extract access token from response.", t);
throw new FacebookResponseContentException(CANNOT_EXTRACT_ACCESS_TOKEN_MESSAGE, t);
}
}

Expand Down
24 changes: 12 additions & 12 deletions src/main/java/com/restfb/json/JsonNumber.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@
@SuppressWarnings("serial") // use default serial UID
class JsonNumber extends JsonValue {

private final String string;
private final String numberStr;

JsonNumber(String string) {
Objects.requireNonNull(string, STRING_IS_NULL);
this.string = string;
JsonNumber(String numberStr) {
Objects.requireNonNull(numberStr, STRING_IS_NULL);
this.numberStr = numberStr;
}

@Override
public String toString() {
return string;
return numberStr;
}

@Override
void write(JsonWriter writer) throws IOException {
writer.writeNumber(string);
writer.writeNumber(numberStr);
}

@Override
Expand All @@ -51,27 +51,27 @@ public boolean isNumber() {

@Override
public int asInt() {
return Integer.parseInt(string, 10);
return Integer.parseInt(numberStr, 10);
}

@Override
public long asLong() {
return Long.parseLong(string, 10);
return Long.parseLong(numberStr, 10);
}

@Override
public float asFloat() {
return Float.parseFloat(string);
return Float.parseFloat(numberStr);
}

@Override
public double asDouble() {
return Double.parseDouble(string);
return Double.parseDouble(numberStr);
}

@Override
public int hashCode() {
return string.hashCode();
return numberStr.hashCode();
}

@Override
Expand All @@ -86,7 +86,7 @@ public boolean equals(Object object) {
return false;
}
JsonNumber other = (JsonNumber) object;
return string.equals(other.string);
return numberStr.equals(other.numberStr);
}

}

0 comments on commit f5aac7e

Please sign in to comment.