Sho SHIMIZU | 9257b0c | 2014-08-13 15:00:10 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.newintent; |
| 2 | |
| 3 | import net.onrc.onos.api.newintent.IntentId; |
Sho SHIMIZU | 7cd8a42 | 2014-08-27 16:05:21 -0700 | [diff] [blame] | 4 | import net.onrc.onos.core.util.AbstractBlockAllocatorBasedIdGenerator; |
Sho SHIMIZU | 9257b0c | 2014-08-13 15:00:10 -0700 | [diff] [blame] | 5 | import net.onrc.onos.core.util.IdBlockAllocator; |
Sho SHIMIZU | 9257b0c | 2014-08-13 15:00:10 -0700 | [diff] [blame] | 6 | |
| 7 | /** |
Sho SHIMIZU | 7cd8a42 | 2014-08-27 16:05:21 -0700 | [diff] [blame] | 8 | * An implementation of {@link net.onrc.onos.core.util.IdGenerator} of intent ID, |
| 9 | * which uses {@link IdBlockAllocator}. |
Sho SHIMIZU | 9257b0c | 2014-08-13 15:00:10 -0700 | [diff] [blame] | 10 | */ |
Sho SHIMIZU | 7cd8a42 | 2014-08-27 16:05:21 -0700 | [diff] [blame] | 11 | public class IdBlockAllocatorBasedIntentIdGenerator extends AbstractBlockAllocatorBasedIdGenerator<IntentId> { |
Sho SHIMIZU | 9257b0c | 2014-08-13 15:00:10 -0700 | [diff] [blame] | 12 | |
Sho SHIMIZU | 42b9281 | 2014-08-17 19:56:44 -0700 | [diff] [blame] | 13 | /** |
Sho SHIMIZU | a8fae01 | 2014-08-18 10:57:30 -0700 | [diff] [blame] | 14 | * Constructs an intent ID generator, which uses the specified ID block allocator |
| 15 | * to generate a global unique intent ID. |
Sho SHIMIZU | 42b9281 | 2014-08-17 19:56:44 -0700 | [diff] [blame] | 16 | * |
Sho SHIMIZU | a8fae01 | 2014-08-18 10:57:30 -0700 | [diff] [blame] | 17 | * @param allocator the ID block allocator to use for generating intent IDs |
Sho SHIMIZU | 42b9281 | 2014-08-17 19:56:44 -0700 | [diff] [blame] | 18 | */ |
Sho SHIMIZU | 9257b0c | 2014-08-13 15:00:10 -0700 | [diff] [blame] | 19 | public IdBlockAllocatorBasedIntentIdGenerator(IdBlockAllocator allocator) { |
Sho SHIMIZU | 7cd8a42 | 2014-08-27 16:05:21 -0700 | [diff] [blame] | 20 | super(allocator); |
Sho SHIMIZU | 9257b0c | 2014-08-13 15:00:10 -0700 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | @Override |
Sho SHIMIZU | 7cd8a42 | 2014-08-27 16:05:21 -0700 | [diff] [blame] | 24 | protected IntentId convertFrom(long value) { |
| 25 | return new IntentId(value); |
Sho SHIMIZU | 9257b0c | 2014-08-13 15:00:10 -0700 | [diff] [blame] | 26 | } |
| 27 | } |