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 multiplicity constraint violations.
027 * <p>Specifications with a multiplicity of {@code MULTIPLICITY_ONE} specify
028 * that exactly one corresponding implementation must be available among a set
029 * of modules. This exception gets thrown for any specification violating this
030 * constraint.</p>
031 *
032 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
033 * @version $JDTAUS: MultiplicityConstraintException.java 8641 2012-09-27 06:45:17Z schulte $
034 *
035 * @see Specification#getMultiplicity()
036 */
037public class MultiplicityConstraintException extends IllegalStateException
038{
039    //--Constants---------------------------------------------------------------
040
041    /** Serial version UID for backwards compatibility with 1.2.x classes. */
042    private static final long serialVersionUID = 344879434134284092L;
043
044    //---------------------------------------------------------------Constants--
045    //--Constructors------------------------------------------------------------
046
047    /**
048     * Creates a new {@code MultiplicityConstraintException} taking the
049     * identifier of the specification for which the multiplicity constraint
050     * is violated.
051     *
052     * @param specificationIdentifier identifier of the specification for
053     * which the constraint is violated.
054     */
055    public MultiplicityConstraintException( final String specificationIdentifier )
056    {
057        super( MultiplicityConstraintExceptionBundle.getInstance().
058               getMultiplicityConstraintMessage( Locale.getDefault(),
059                                                 specificationIdentifier ) );
060
061        this.specificationIdentifier = specificationIdentifier;
062    }
063
064    //------------------------------------------------------------Constructors--
065    //--MultiplicityConstraintException-----------------------------------------
066
067    /**
068     * Identifier of the specification for which the multiplicity constraint
069     * is violated.
070     * @serial
071     */
072    private final String specificationIdentifier;
073
074    /**
075     * Gets the identifier of the specification for which the multiplicity
076     * constraint is violated.
077     *
078     * @return the identifier of the specification for which the multiplicity
079     * constraint is violated.
080     */
081    public String getSpecificationIdentifier()
082    {
083        return this.specificationIdentifier;
084    }
085
086    //-----------------------------------------MultiplicityConstraintException--
087}