- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- io.github.mmm.base.exception.ApplicationException
-
- io.github.mmm.base.exception.DuplicateObjectException
-
- All Implemented Interfaces:
Localizable,LocalizableObject,Serializable
public class DuplicateObjectException extends ApplicationException
AnDuplicateObjectExceptionis thrown if an object was rejected because it is a duplicate. This typically happens if objects are registered (e.g. in aMap) and an object is already associated for the same key.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringMESSAGE_CODE
-
Constructor Summary
Constructors Constructor Description DuplicateObjectException(Object object)The constructor.DuplicateObjectException(Object object, Object key)The constructor.DuplicateObjectException(Object object, Object key, Object existing)The constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetCode()This method gets the code that identifies the detailed type of this object.static <KEY,VALUE>
voidput(Map<KEY,VALUE> map, KEY key, VALUE value)-
Methods inherited from class io.github.mmm.base.exception.ApplicationException
createUuid, getLocalizedMessage, getLocalizedMessage, getMessage, getNlsMessage, getNlsMessage, getUuid, isForUser, isTechnical, printStackTrace, toString, toString, toString
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.github.mmm.base.i18n.Localizable
getArgument, getLocalizedMessage, toLocalizable
-
-
-
-
Field Detail
-
MESSAGE_CODE
public static final String MESSAGE_CODE
- See Also:
getCode(), Constant Field Values
-
-
Constructor Detail
-
DuplicateObjectException
public DuplicateObjectException(Object object)
The constructor.- Parameters:
object- is the object that was rejected because it is a duplicate.
-
DuplicateObjectException
public DuplicateObjectException(Object object, Object key)
The constructor.- Parameters:
object- is the object that was rejected because it is a duplicate.key- is the key the object could NOT be associated with because it already leads to another object.
-
DuplicateObjectException
public DuplicateObjectException(Object object, Object key, Object existing)
The constructor.- Parameters:
object- is the object that was rejected because it is a duplicate.key- is the key the object could NOT be associated with because it already leads to another object.existing- is the object that is already registered for the givenkey.- Since:
- 3.0.0
-
-
Method Detail
-
put
public static <KEY,VALUE> void put(Map<KEY,VALUE> map, KEY key, VALUE value) throws DuplicateObjectException
- Type Parameters:
KEY- is the generic type of thekey.VALUE- is the generic type of thevalue.- Parameters:
map- is theMap.key- is thekey.value- is the value toput.- Throws:
DuplicateObjectException- if the givenmapalready contains a value for the givenkeythat is NOT equal to the givenvalue.
-
getCode
public String getCode()
Description copied from class:ApplicationExceptionThis method gets the code that identifies the detailed type of this object. WhileUUIDis unique per instance of aApplicationExceptionthis code is a short and readable identifier representing theApplicationExceptionClass. The default implementation returns thesimple name. However, the code should remain stable after refactoring (so at least after the rename the previous code should be returned asStringliteral). This code may be used as a compact identifier to reference the related problem or information as well as for automatic tests of error situations that should remain stable even if the message text gets improved or the locale is unknown.- Overrides:
getCodein classApplicationException- Returns:
- the error code.
-
-