Skip to content

Commit

Permalink
Remove useless/redundant Javadoc in the models package, clear up some…
Browse files Browse the repository at this point in the history
… things
  • Loading branch information
mattbdean committed Mar 2, 2015
1 parent 5ee0956 commit 01b1c86
Show file tree
Hide file tree
Showing 44 changed files with 447 additions and 887 deletions.
4 changes: 4 additions & 0 deletions src/main/java/net/dean/jraw/JrawUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,8 @@ public static String urlDecode(String data) {
throw new RuntimeException("Charset '" + CHARSET + "' not found", e);
}
}

public static ObjectMapper objectMapper() {
return mapper;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
*/
public class NoSuchEnumConstantException extends RuntimeException {
public NoSuchEnumConstantException(Class<? extends Enum> enumClass, String val) {
super("Could not find enum constant in " + enumClass.getName() + " via input '" + val + "'.");
super("Could not find enum constant in " + enumClass.getName() + " for JSON value '" + val + "'.");
}
}
9 changes: 1 addition & 8 deletions src/main/java/net/dean/jraw/RedditClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,7 @@ public Captcha getNewCaptcha() throws NetworkException, ApiException {
*/
@EndpointImplementation(Endpoints.CAPTCHA_IDEN)
public Captcha getCaptcha(String id) {
// Use Request to format the URL
HttpRequest request = request()
.host(HOST_SPECIAL)
.endpoint(Endpoints.CAPTCHA_IDEN, id)
.get()
.build();

return new Captcha(id, request.getUrl());
return new Captcha(id);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/dean/jraw/managers/InboxManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.dean.jraw.http.NetworkException;
import net.dean.jraw.http.RestResponse;
import net.dean.jraw.models.Message;
import net.dean.jraw.models.PrivateMessage;
import net.dean.jraw.paginators.InboxPaginator;
import net.dean.jraw.paginators.Paginator;

Expand Down Expand Up @@ -38,7 +37,7 @@ public InboxManager(RedditClient client) {
Endpoints.READ_MESSAGE,
Endpoints.UNREAD_MESSAGE
})
public void setRead(PrivateMessage m, boolean read) throws NetworkException {
public void setRead(Message m, boolean read) throws NetworkException {
reddit.execute(reddit.request()
.endpoint(read ? Endpoints.READ_MESSAGE : Endpoints.UNREAD_MESSAGE)
.post(JrawUtils.mapOf("id", m.getFullName()))
Expand Down Expand Up @@ -107,6 +106,7 @@ public void compose(String from, String to, String subject, String body) throws

/**
* Creates a new Paginator that will iterate through unread messages.
* @return
*/
public Paginator<Message> read() {
return read("unread");
Expand Down
18 changes: 8 additions & 10 deletions src/main/java/net/dean/jraw/managers/MultiRedditManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
import net.dean.jraw.http.NetworkException;
import net.dean.jraw.http.RestResponse;
import net.dean.jraw.models.MultiReddit;
import net.dean.jraw.models.MultiSubreddit;

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

/**
* This class provides the ability to create, read, update, and delete multireddits.
Expand Down Expand Up @@ -59,18 +58,17 @@ public List<MultiReddit> mine() throws NetworkException, ApiException {
* @param updateData The request to be sent
* @throws NetworkException If the request was not successful
* @throws ApiException If the Reddit API returned an error
* @return The updated MultiReddit
* @return The updated MultiReddit. Note that the only non-null property in its list of {@link MultiSubreddit}s will
* be their names.
*/
@EndpointImplementation({Endpoints.MULTI_MULTIPATH_PUT, Endpoints.MULTI_MULTIPATH_POST})
public MultiReddit createOrUpdate(MultiRedditUpdateRequest updateData) throws NetworkException, ApiException {
Map<String, String> args = new HashMap<>();
args.put("model", JrawUtils.toJson(updateData));

HttpRequest.Builder request = reddit.request()
.query("expand_srs", "true")
.endpoint(Endpoints.MULTI_MULTIPATH_POST, getMultiPath(updateData.getName()).substring(1));

request.put(args);
.endpoint(Endpoints.MULTI_MULTIPATH_POST, getMultiPath(updateData.getName()).substring(1))
.put(JrawUtils.mapOf(
"model", JrawUtils.toJson(updateData),
"expand_srs", "true"
));

RestResponse response = reddit.execute(request.build());
JsonNode result = response.getJson();
Expand Down
36 changes: 8 additions & 28 deletions src/main/java/net/dean/jraw/models/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,68 +14,48 @@
*/
@Model(kind = Model.Kind.ACCOUNT)
public class Account extends Thing implements Created {
/**
* Instantiates a new Account
* @param data The node to get data from
*/
/** Instantiates a new Account */
public Account(JsonNode data) {
super(data);
}

/**
* Gets the user's comment karma
* @return the user's comment karma
*/
/** Gets the user's comment karma */
@JsonProperty
public Integer getCommentKarma() {
return data("comment_karma", Integer.class);
}

/**
* Checks whether or not the logged-in user has this user set as a friend
* @return Whether the logged-in user has this user set as a friend
*/
/** Checks whether or not the logged-in user has this user set as a friend */
@JsonProperty
public Boolean isFriend() {
return data("is_friend", Boolean.class);
}

/**
* Checks if the user has Reddit Gold
* @return Reddit gold status
*/
/** Checks if the user has Reddit Gold */
@JsonProperty
public Boolean hasGold() {
return data("is_gold", Boolean.class);
}

/**
* Checks whether this account moderates any subreddits
* @return True if this account moderates any subreddits
*/
/** Checks whether this account moderates any subreddits */
@JsonProperty
public Boolean isMod() {
return data("is_mod", Boolean.class);
}

/**
* Gets the user's link karma
* @return The user's link karma
*/
/** Gets the user's link karma */
@JsonProperty
public Integer getLinkKarma() {
return data("link_karma", Integer.class);
}

/**
* Whether this account is set to be over 18
* @return If this account is set to be over 18
*/
/** Checks if this account is said to be over 18 and "willing to view adult content." */
@JsonProperty(nullable = true)
public Boolean isOver18() {
return data("over_18", Boolean.class);
}

@Override
public Date getCreated() {
return _getCreated();
}
Expand Down
Loading

0 comments on commit 01b1c86

Please sign in to comment.