001/*
002 *  jDTAUS Core API
003 *  Copyright (C) 2005 Christian Schulte
004 *  <cs@schulte.it>
005 *
006 *  This library is free software; you can redistribute it and/or
007 *  modify it under the terms of the GNU Lesser General Public
008 *  License as published by the Free Software Foundation; either
009 *  version 2.1 of the License, or any later version.
010 *
011 *  This library is distributed in the hope that it will be useful,
012 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 *  Lesser General Public License for more details.
015 *
016 *  You should have received a copy of the GNU Lesser General Public
017 *  License along with this library; if not, write to the Free Software
018 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
019 *
020 */
021package org.jdtaus.core.container;
022
023import java.util.Locale;
024
025/**
026 * Gets thrown for type collisions of inherited properties, implemented
027 * properties, or dependency properties.
028 *
029 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
030 * @version $JDTAUS: IllegalPropertyTypeException.java 8743 2012-10-07 03:06:20Z schulte $
031 */
032public class IllegalPropertyTypeException extends IllegalStateException
033{
034    //--Constants---------------------------------------------------------------
035
036    /** Serial version UID for backwards compatibility with 1.5.x classes. */
037    private static final long serialVersionUID = -2081711860347150219L;
038
039    //---------------------------------------------------------------Constants--
040    //--Constructors------------------------------------------------------------
041
042    /**
043     * Creates a new instance of {@code IllegalPropertyTypeException} taking a
044     * property name and the illegal type.
045     *
046     * @param name the name of the property with illegal type.
047     * @param type the illegal type of the property with name {@code name}.
048     * @param expectedType the expected type of the property with name
049     * {@code name}.
050     */
051    public IllegalPropertyTypeException( final String name, final Class type,
052                                         final Class expectedType )
053    {
054        super( IllegalPropertyTypeExceptionBundle.getInstance().
055               getIllegalPropertyTypeMessage( Locale.getDefault(), name,
056                                              type.getName(),
057                                              expectedType.getName() ) );
058
059        this.name = name;
060        this.type = type;
061        this.expectedType = expectedType;
062    }
063
064    //------------------------------------------------------------Constructors--
065    //--IllegalPropertyTypeException--------------------------------------------
066
067    /**
068     * The name of the property with illegal type.
069     * @serial
070     */
071    private final String name;
072
073    /**
074     * The illegal type.
075     * @serial
076     */
077    private final Class type;
078
079    /**
080     * The expected type.
081     * @serial
082     */
083    private final Class expectedType;
084
085    /**
086     * Gets the name of the property with illegal type.
087     *
088     * @return the name of the property with illegal type.
089     */
090    public String getName()
091    {
092        return this.name;
093    }
094
095    /**
096     * Gets the illegal type of the property.
097     *
098     * @return the illegal type of the property.
099     */
100    public Class getType()
101    {
102        return this.type;
103    }
104
105    /**
106     * Gets the expected type of the property.
107     *
108     * @return the expected type of the property.
109     */
110    public Class getExpectedType()
111    {
112        return this.expectedType;
113    }
114
115    //--------------------------------------------IllegalPropertyTypeException--
116}