Skip to content

Commit

Permalink
Move attachments from Feed to Item. Fixes #8.
Browse files Browse the repository at this point in the history
  • Loading branch information
devilgate committed Oct 27, 2020
1 parent 689c1e9 commit ad6a0ae
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 135 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plugins {
}

sourceCompatibility = 1.8
version = '1.0.4'
version = '1.0.5'

jar {
manifest {
Expand Down
112 changes: 0 additions & 112 deletions pom.xml

This file was deleted.

4 changes: 0 additions & 4 deletions src/main/java/software/tinlion/pertwee/Feed.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ public interface Feed {

List<Hub> hubs();

boolean hasAttachments();

List<Attachment> attachments();

boolean hasExtensions();

/**
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/software/tinlion/pertwee/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ public interface Item {

public List<String> tags();

boolean hasAttachments();

List<Attachment> attachments();
}
18 changes: 0 additions & 18 deletions src/main/java/software/tinlion/pertwee/feed/DefaultFeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,24 +204,6 @@ public boolean hasExtensions() {
return false;
}

@Override
public boolean hasAttachments() {

return feedObject.has("attachments")
&& feedObject.optJSONArray("attachements") != null
&& !feedObject.getJSONArray("attachments").isEmpty();
}

@Override
public List<Attachment> attachments() {

if (hasAttachments()) {

return AnAttachment.parseAttachmentsFromJson(feedObject.getJSONArray("attachments"));
}
return null;
}

public String print() {

StringBuilder output = new StringBuilder();
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/software/tinlion/pertwee/feed/DefaultItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import org.json.JSONObject;

import software.tinlion.pertwee.Attachment;
import software.tinlion.pertwee.Author;
import software.tinlion.pertwee.Item;
import software.tinlion.pertwee.check.GetIfPresent;
Expand Down Expand Up @@ -121,4 +122,24 @@ public String toString() {

return itemObject.toString();
}

@Override
public boolean hasAttachments() {

return itemObject.has("attachments")
&& itemObject.optJSONArray("attachements") != null
&& !itemObject.getJSONArray("attachments").isEmpty();
}

@Override
public List<Attachment> attachments() {

if (hasAttachments()) {

return AnAttachment.parseAttachmentsFromJson(itemObject.getJSONArray("attachments"));
}
return null;
}


}

0 comments on commit ad6a0ae

Please sign in to comment.