From fbae4981d8b42f5ad79a82b6c883a45670b175d8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 24 Jul 2015 16:58:55 +0200 Subject: [PATCH] Store in post part whether the internal ID was used to create this part --- .../java/net/pterodactylus/sone/text/PostPart.java | 31 +++++++--------------- .../pterodactylus/sone/text/SoneTextParser.java | 2 +- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/text/PostPart.java b/src/main/java/net/pterodactylus/sone/text/PostPart.java index f7177c9..c6ab534 100644 --- a/src/main/java/net/pterodactylus/sone/text/PostPart.java +++ b/src/main/java/net/pterodactylus/sone/text/PostPart.java @@ -26,39 +26,26 @@ import net.pterodactylus.sone.data.Post; */ public class PostPart implements Part { - /** The post this part refers to. */ private final Post post; + private final boolean usesDeprecatedLink; - /** - * Creates a new post part. - * - * @param post - * The referenced post - */ public PostPart(Post post) { - this.post = post; + this(post, false); } - // - // ACCESSORS - // + public PostPart(Post post, boolean usesDeprecatedLink) { + this.post = post; + this.usesDeprecatedLink = usesDeprecatedLink; + } - /** - * Returns the post referenced by this part. - * - * @return The post referenced by this part - */ public Post getPost() { return post; } - // - // PART METHODS - // + public boolean usesDeprecatedLink() { + return usesDeprecatedLink; + } - /** - * {@inheritDoc} - */ @Override public String getText() { return post.getText(); diff --git a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java index 7194b89..1573d1c 100644 --- a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java +++ b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java @@ -206,7 +206,7 @@ public class SoneTextParser implements Parser { if (linkType == LinkType.POST) { Optional post = postProvider.getPost(link.substring(7)); if (post.isPresent()) { - parts.add(new PostPart(post.get())); + parts.add(new PostPart(post.get(), link.substring(7).equals(post.get().getInternalId()))); } else { parts.add(new PlainTextPart(link)); } -- 2.7.4