1 package com.atlassian.bonnie.index;
2
3 import java.util.Collection;
4 import java.util.Collections;
5
6
7
8
9 public class SingletonObjectQueue implements ObjectQueue
10 {
11 private Object o;
12 private ObjectToDocumentConverter otdc;
13
14 public SingletonObjectQueue(Object o, ObjectToDocumentConverter otdc)
15 {
16 this.o = o;
17 this.otdc = otdc;
18 }
19
20 public Collection pop()
21 {
22 Object toreturn = o;
23 this.o = null;
24 return Collections.singletonList(toreturn);
25 }
26
27 public boolean hasMore()
28 {
29 return o != null;
30 }
31
32 public int size()
33 {
34 return 1;
35 }
36
37 public Processor getProcessor()
38 {
39 return new Processor()
40 {
41 public void indexCollection(Collection collection, BatchOpIndexer.DocumentWritingScheme documentWritingScheme)
42 {
43 documentWritingScheme.write(otdc.convert(collection.toArray()[0], null));
44 }
45 };
46 }
47 }