Commit 7bec3f99 authored by Andrew Wright's avatar Andrew Wright Committed by andrew

added the ability to specify the jive id type as an annotation of a class


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1389 b35dd754-fafc-0310-a699-88a17e54d16e
parent 97d8494a
package org.jivesoftware.database;
/**
* Used to specify what jive id an object should have
*
* @author Andrew Wright
*/
public @interface JiveID {
/**
* should return the int type for this object
*/
int value();
}
......@@ -84,6 +84,34 @@ public class SequenceManager {
}
}
/**
* Method for objects that have defined the annotation {@link JiveID} in their class.
*
* The annotation JiveID should contain the id type for the object (the same number you would
* use to call nextID(int type))
*
* Example class definition:
*
* <code>
* \@JiveID(10)
* public class MyClass {
*
* }
* </code>
*
* @param o object that has annotation JiveID
* @return the next int
*/
public static long nextID(Object o) {
JiveID id = o.getClass().getAnnotation(JiveID.class);
if(id == null) {
throw new IllegalArgumentException("Annotation JiveID must be defined in the class");
}
return nextID(id.value());
}
/**
* Used to set the blocksize of a given SequenceManager. If no SequenceManager has been registered
* for the type we will verify the type is valid and then create a new sequence manager for it.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment