1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jdo.impl.model.java;
19
20 import org.apache.jdo.model.java.JavaType;
21
22 /***
23 * An instance of class NullType represents the type of the null expression
24 * in Java. It is compatible to all reference types.
25 *
26 * @author Michael Bouschen
27 * @since JDO 1.0.1
28 */
29 public class NullType
30 extends AbstractJavaType
31 {
32 /*** The singleton NullType instance. */
33 public static final NullType nullType = new NullType();
34
35 /***
36 * Creates new a NullType instance. This constructor should not be
37 * called directly; instead, the singleton instance {@link #nullType}
38 * should be used.
39 */
40 protected NullType() {}
41
42 /***
43 * Returns true if this JavaType is compatible with the specified
44 * JavaType. This implementation returns <code>true</code>, if the
45 * specified javaType is a not a primitive type, because the type of
46 * null is compatiple with all reference types.
47 * @param javaType the type this JavaType is checked with.
48 * @return <code>true</code> if this is compatible with the specified
49 * type; <code>false</code> otherwise.
50 */
51 public boolean isCompatibleWith(JavaType javaType)
52 {
53 return !javaType.isPrimitive();
54 }
55
56 /***
57 * Returns the name of the type.
58 * @return type name
59 */
60 public String getName()
61 {
62 return "<null type>";
63 }
64
65 }