001package org.apache.tapestry5.json.exceptions; 002 003import org.apache.tapestry5.json.JSONType; 004 005public class JSONTypeMismatchException extends RuntimeException 006{ 007 008 private static final long serialVersionUID = 268314880458464132L; 009 010 private final String location; 011 private final JSONType requiredType; 012 private final Class<? extends Object> invalidClass; 013 014 public JSONTypeMismatchException(String location, JSONType requiredType, 015 Class<? extends Object> invalidClass) 016 { 017 super(location + (invalidClass == null ? " is null." 018 : " is not a " + requiredType.name() + ". Actual: " + invalidClass.getName())); 019 this.location = location; 020 this.requiredType = requiredType; 021 this.invalidClass = invalidClass; 022 } 023 024 public String getLocation() 025 { 026 return this.location; 027 } 028 029 public JSONType getRequiredType() 030 { 031 return this.requiredType; 032 } 033 034 public Class<? extends Object> getInvalidClass() 035 { 036 return this.invalidClass; 037 } 038 039}