net.sf.eBus.messages.InvalidMessageException Maven / Gradle / Ivy
The newest version!
//
// Copyright 2001 - 2008, 2013 Charles W. Rapp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package net.sf.eBus.messages;
/**
* {@code InvalidMessageException} is thrown when a message
* class has an invalid layout. A message class is invalid when:
*
* -
* if the class is not an {@link EMessage} subclass,
*
* -
* a message field is either not public, not final or is
* static, or
*
* -
* the message class does not have the required deserialize
* builder inner class (see {@link EMessageObject} for more
* about this).
*
*
*
* @author Charles Rapp
*/
public final class InvalidMessageException
extends RuntimeException
{
//---------------------------------------------------------------
// Member data.
//
//-----------------------------------------------------------
// Constants.
//
/**
* This is eBus version 2.1.0.
*/
private static final long serialVersionUID = 0x050200L;
//-----------------------------------------------------------
// Locals.
//
/**
* The invalid message identifier.
*/
private final Class extends EMessageObject> mMsgClass;
//---------------------------------------------------------------
// Member methods.
//
//-----------------------------------------------------------
// Constructors.
//
/**
* Creates an InvalidMessageException for the given message.
* @param mc the invalid message class.
*/
public InvalidMessageException(
final Class extends EMessageObject> mc)
{
super ("invalid message");
mMsgClass = mc;
} // end of InvalidMessageException(Class)
/**
* Creates an InvalidMessageException for the given message
* and exception reason.
* @param mc the invalid message class.
* @param reason the reason the message is invalid.
*/
public InvalidMessageException(
final Class extends EMessageObject> mc,
final String reason)
{
super (reason);
mMsgClass = mc;
} // end of InvalidMessageException(Class, String)
/**
* Creates an InvalidMessageException for the given message,
* reason, and cause.
* @param mc the invalid message class.
* @param reason the reason the message is invalid.
* @param t the cause for this exception.
*/
public InvalidMessageException(
final Class extends EMessageObject> mc,
final String reason,
final Throwable t)
{
super (reason, t);
mMsgClass = mc;
} // end of InvalidMessageException(Class, String, Throwable)
//
// end of Constructors.
//-----------------------------------------------------------
//-----------------------------------------------------------
// Get methods.
//
/**
* Returns the message class.
* @return the message class.
*/
public Class extends EMessageObject> messageClass()
{
return (mMsgClass);
} // end of messageClass()
//
// end of Get methods.
//-----------------------------------------------------------
} // end of class InvalidMessageException