File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed
src/main/java/org/scijava/usage Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 3535import java .util .Map ;
3636
3737import org .scijava .Identifiable ;
38+ import org .scijava .Locatable ;
3839import org .scijava .event .EventHandler ;
3940import org .scijava .module .ModuleInfo ;
4041import org .scijava .module .event .ModuleExecutedEvent ;
@@ -71,12 +72,13 @@ public void clearStats() {
7172
7273 @ Override
7374 public UsageStats getUsage (final Object o ) {
74- if (!(o instanceof Identifiable )) {
75- // only track objects with an identifier
75+ if (!(o instanceof Identifiable ) || !( o instanceof Locatable ) ) {
76+ // only track objects with an identifier and a location
7677 return null ;
7778 }
7879 final String id = ((Identifiable ) o ).getIdentifier ();
79- if (!stats .containsKey (id )) stats .put (id , new UsageStats (id ));
80+ final String url = ((Locatable ) o ).getLocation ();
81+ if (!stats .containsKey (id )) stats .put (id , new UsageStats (id , url ));
8082 return stats .get (id );
8183 }
8284
Original file line number Diff line number Diff line change 3232package org .scijava .usage ;
3333
3434import org .scijava .Identifiable ;
35+ import org .scijava .Locatable ;
3536
3637/**
3738 * Data structure storing usage statistics for a particular identifier.
3839 *
3940 * @author Curtis Rueden
4041 */
41- public class UsageStats implements Identifiable {
42+ public class UsageStats implements Identifiable , Locatable {
4243
4344 /** The object's unique identifier. */
4445 private String id ;
4546
47+ /** This object's location URL. */
48+ private String url ;
49+
4650 /** Number of times the object was used. */
4751 private long count ;
4852
49- public UsageStats (final String id ) {
53+ public UsageStats (final String id , final String url ) {
5054 this .id = id ;
55+ this .url = url ;
5156 }
5257
5358 /** Gets the number of times the object has been used. */
@@ -67,4 +72,11 @@ public String getIdentifier() {
6772 return id ;
6873 }
6974
75+ // -- Locatable methods --
76+
77+ @ Override
78+ public String getLocation () {
79+ return url ;
80+ }
81+
7082}
You can’t perform that action at this time.
0 commit comments