KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > annotation > processing > Completions


1 /*
2  * @(#)Completions.java 1.2 06/07/31
3  *
4  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.annotation.processing;
9
10 import java.util.Arrays JavaDoc;
11
12 /**
13  * Utility class for assembling {@link Completion} objects.
14  *
15  * @author Joseph D. Darcy
16  * @author Scott Seligman
17  * @author Peter von der Ahé
18  * @version 1.2 06/07/31
19  * @since 1.6
20  */

21 public class Completions {
22     // No instances for you.
23
private Completions() {}
24
25     private static class SimpleCompletion implements Completion {
26     private String JavaDoc value;
27     private String JavaDoc message;
28
29     SimpleCompletion(String JavaDoc value, String JavaDoc message) {
30         if (value == null || message == null)
31         throw new NullPointerException JavaDoc("Null completion strings not accepted.");
32         this.value = value;
33         this.message = message;
34     }
35
36     public String JavaDoc getValue() {
37         return value;
38     }
39
40
41     public String JavaDoc getMessage() {
42         return message;
43     }
44
45     @Override JavaDoc
46     public String JavaDoc toString() {
47         return "[\"" + value + "\", \"" + message + "\"]";
48     }
49     // Default equals and hashCode are fine.
50
}
51
52     /**
53      * Returns a completion of the value and message.
54      *
55      * @param value the text of the completion
56      * @param message a message about the completion
57      * @return a completion of the provided value and message
58      */

59     public static Completion of(String JavaDoc value, String JavaDoc message) {
60     return new SimpleCompletion(value, message);
61     }
62
63     /**
64      * Returns a completion of the value and an empty message
65      *
66      * @param value the text of the completion
67      * @return a completion of the value and an empty message
68      */

69     public static Completion of(String JavaDoc value) {
70     return new SimpleCompletion(value, "");
71     }
72 }
73
Popular Tags