com.atlassian.scheduler.compat
Class JobHandlerKey

java.lang.Object
  extended by com.atlassian.scheduler.compat.JobHandlerKey
All Implemented Interfaces:
Serializable, Comparable<JobHandlerKey>

@Immutable
@PublicApi
public final class JobHandlerKey
extends Object
implements Serializable, Comparable<JobHandlerKey>

A wrapper to distinguish job handler keys from simple strings and to make it easier to avoid confusing them with Job IDs.

This class is the compatibility layer's equivalent for the JobRunnerKey.

Since:
v1.0
See Also:
Serialized Form

Method Summary
 int compareTo(JobHandlerKey o)
           
 boolean equals(Object o)
           
 int hashCode()
           
static JobHandlerKey of(String key)
          Wraps the provided string as a JobHandlerKey.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

of

public static JobHandlerKey of(@Nonnull
                               String key)
Wraps the provided string as a JobHandlerKey.

Although it is not necessary for correctness, it will usually make sense to create a single instance of the JobHandlerKey and reuse it as a constant, as in:

     private static final JobHandlerKey POP3_SERVICE = JobHandlerKey.of("com.example.plugin.Pop3Service");

     // ...

     private void registerJobHandler()
     {
         compatibilityPluginScheduler.registerJobHandler(POP3_SERVICE, new Pop3JobHandler());
     }

     private void scheduleJob(String jobId, long intervalInMillis, Date firstRun)
     {
         compatibilityPluginScheduler.scheduleJob(jobKey, POP3_SERVICE, null, intervalInMillis, firstRun);
     }
 

Parameters:
key - the job handler key, as a string
Returns:
the wrapped job handler key

equals

public boolean equals(Object o)
Overrides:
equals in class Object

compareTo

public int compareTo(JobHandlerKey o)
Specified by:
compareTo in interface Comparable<JobHandlerKey>

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014 Atlassian. All Rights Reserved.