Home | History | Annotate | Download | only in typesystem
      1 /*
      2  * Copyright 2016 Federico Tomassetti
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  * http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.github.javaparser.symbolsolver.model.typesystem;
     18 
     19 import com.github.javaparser.resolution.types.ResolvedType;
     20 
     21 /**
     22  * This is a virtual type used to represent null values.
     23  *
     24  * @author Federico Tomassetti
     25  */
     26 public class NullType implements ResolvedType {
     27 
     28     public static final NullType INSTANCE = new NullType();
     29 
     30     private NullType() {
     31         // prevent instantiation
     32     }
     33 
     34     @Override
     35     public boolean isArray() {
     36         return false;
     37     }
     38 
     39     @Override
     40     public boolean isPrimitive() {
     41         return false;
     42     }
     43 
     44     public boolean isNull() {
     45         return true;
     46     }
     47 
     48     @Override
     49     public boolean isReferenceType() {
     50         return false;
     51     }
     52 
     53     @Override
     54     public String describe() {
     55         return "null";
     56     }
     57 
     58     @Override
     59     public boolean isTypeVariable() {
     60         return false;
     61     }
     62 
     63     @Override
     64     public boolean isAssignableBy(ResolvedType other) {
     65         throw new UnsupportedOperationException("It does not make sense to assign a value to null, it can only be assigned");
     66     }
     67 
     68 }
     69