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