aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/connector/trackable
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/connector/trackable')
-rw-r--r--main/src/cgeo/geocaching/connector/trackable/AbstractTrackableConnector.java12
-rw-r--r--main/src/cgeo/geocaching/connector/trackable/TrackableConnector.java15
-rw-r--r--main/src/cgeo/geocaching/connector/trackable/UnknownTrackableConnector.java6
3 files changed, 29 insertions, 4 deletions
diff --git a/main/src/cgeo/geocaching/connector/trackable/AbstractTrackableConnector.java b/main/src/cgeo/geocaching/connector/trackable/AbstractTrackableConnector.java
index c3a7437..03549d1 100644
--- a/main/src/cgeo/geocaching/connector/trackable/AbstractTrackableConnector.java
+++ b/main/src/cgeo/geocaching/connector/trackable/AbstractTrackableConnector.java
@@ -1,5 +1,6 @@
package cgeo.geocaching.connector.trackable;
+import cgeo.geocaching.Trackable;
import cgeo.geocaching.connector.AbstractConnector;
import cgeo.geocaching.connector.UserAction;
@@ -16,6 +17,11 @@ public abstract class AbstractTrackableConnector implements TrackableConnector {
}
@Override
+ public boolean hasTrackableUrls() {
+ return true;
+ }
+
+ @Override
@Nullable
public String getTrackableCodeFromUrl(@NonNull final String url) {
return null;
@@ -26,4 +32,10 @@ public abstract class AbstractTrackableConnector implements TrackableConnector {
public List<UserAction> getUserActions() {
return AbstractConnector.getDefaultUserActions();
}
+
+ @Override
+ @NonNull
+ public String getUrl(@NonNull final Trackable trackable) {
+ throw new IllegalStateException("this trackable does not have a corresponding URL");
+ }
}
diff --git a/main/src/cgeo/geocaching/connector/trackable/TrackableConnector.java b/main/src/cgeo/geocaching/connector/trackable/TrackableConnector.java
index 1281683..aea60e6 100644
--- a/main/src/cgeo/geocaching/connector/trackable/TrackableConnector.java
+++ b/main/src/cgeo/geocaching/connector/trackable/TrackableConnector.java
@@ -16,6 +16,21 @@ public interface TrackableConnector {
public boolean canHandleTrackable(final String geocode);
+ /**
+ * Check whether the connector has URLs corresponding the the trackable.
+ *
+ * @return <tt>true</tt> if the connector handles URLs, <tt>false</tt> otherwise
+ */
+ public boolean hasTrackableUrls();
+
+ /**
+ * Return the URL for a trackable. Might throw {@link IllegalStateException} if called
+ * on a connector which does not have URLs for trackables. This might be checked using
+ * {@link #hasTrackableUrls()}.
+ *
+ * @param trackable the trackable
+ * @return the URL corresponding to this trackable
+ */
@NonNull
public String getUrl(@NonNull final Trackable trackable);
diff --git a/main/src/cgeo/geocaching/connector/trackable/UnknownTrackableConnector.java b/main/src/cgeo/geocaching/connector/trackable/UnknownTrackableConnector.java
index 5fc7bf1..885df7e 100644
--- a/main/src/cgeo/geocaching/connector/trackable/UnknownTrackableConnector.java
+++ b/main/src/cgeo/geocaching/connector/trackable/UnknownTrackableConnector.java
@@ -2,7 +2,6 @@ package cgeo.geocaching.connector.trackable;
import cgeo.geocaching.Trackable;
-import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
public class UnknownTrackableConnector extends AbstractTrackableConnector {
@@ -13,9 +12,8 @@ public class UnknownTrackableConnector extends AbstractTrackableConnector {
}
@Override
- @NonNull
- public String getUrl(@NonNull final Trackable trackable) {
- throw new IllegalStateException("getUrl cannot be called on unknown trackables");
+ public boolean hasTrackableUrls() {
+ return false;
}
@Override