projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix rescue mode.
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
template
/
ReplyAccessor.java
diff --git
a/src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java
b/src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java
index
d5fd7e4
..
b497a94
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java
+++ b/
src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java
@@
-1,5
+1,5
@@
/*
/*
- * Sone - ReplyAccessor.java - Copyright © 2010 David Roden
+ * Sone - ReplyAccessor.java - Copyright © 2010
–2013
David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@
-18,20
+18,30
@@
package net.pterodactylus.sone.template;
import net.pterodactylus.sone.core.Core;
package net.pterodactylus.sone.template;
import net.pterodactylus.sone.core.Core;
+import net.pterodactylus.sone.data.PostReply;
import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.util.template.
DataProvide
r;
+import net.pterodactylus.util.template.
Accesso
r;
import net.pterodactylus.util.template.ReflectionAccessor;
import net.pterodactylus.util.template.ReflectionAccessor;
+import net.pterodactylus.util.template.TemplateContext;
/**
/**
- * TODO
+ * {@link Accessor} implementation that adds a couple of properties to
+ * {@link Reply}s.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class ReplyAccessor extends ReflectionAccessor {
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class ReplyAccessor extends ReflectionAccessor {
+ /** The core. */
private final Core core;
private final Core core;
+ /**
+ * Creates a new reply accessor.
+ *
+ * @param core
+ * The core
+ */
public ReplyAccessor(Core core) {
this.core = core;
}
public ReplyAccessor(Core core) {
this.core = core;
}
@@
-40,15
+50,19
@@
public class ReplyAccessor extends ReflectionAccessor {
* {@inheritDoc}
*/
@Override
* {@inheritDoc}
*/
@Override
- public Object get(
DataProvider dataProvider
, Object object, String member) {
-
Reply reply = (
Reply) object;
+ public Object get(
TemplateContext templateContext
, Object object, String member) {
+
PostReply reply = (Post
Reply) object;
if ("likes".equals(member)) {
return core.getLikes(reply);
} else if (member.equals("liked")) {
if ("likes".equals(member)) {
return core.getLikes(reply);
} else if (member.equals("liked")) {
- Sone currentSone = (Sone)
dataProvider.getData
("currentSone");
+ Sone currentSone = (Sone)
templateContext.get
("currentSone");
return (currentSone != null) && (currentSone.isLikedReplyId(reply.getId()));
return (currentSone != null) && (currentSone.isLikedReplyId(reply.getId()));
+ } else if (member.equals("new")) {
+ return !reply.isKnown();
+ } else if (member.equals("loaded")) {
+ return reply.getSone() != null;
}
}
- return super.get(
dataProvider
, object, member);
+ return super.get(
templateContext
, object, member);
}
}
}
}