All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lonepulse.zombielink.request.SerializerInstantiationException Maven / Gradle / Ivy

The newest version!
package com.lonepulse.zombielink.request;

/*
 * #%L
 * ZombieLink
 * %%
 * Copyright (C) 2013 - 2014 Lonepulse
 * %%
 * 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.
 * #L%
 */

import org.apache.http.HttpEntity;

import com.lonepulse.zombielink.util.Entities;
import com.lonepulse.zombielink.util.EntityResolutionFailedException;

/**
 * 

This runtime exception is thrown when a custom {@link Serializer} failed to be instantiated * using the default constructor on its {@link Class}.

* * @version 1.1.0 *

* @since 1.3.0 *

* @author Lahiru Sahan Jayasinghe */ class SerializerInstantiationException extends SerializerException { private static final long serialVersionUID = -5176137903007152524L; /** *

Displays a detailed error message with information on the {@link Class} of the serializer type * which failed to be instantiated.

* * @param serializerType * the {@link Class} of the {@link Serializer} which failed to be instantiated *

* @since 1.3.0 */ public SerializerInstantiationException(Class> serializerType) { super(new StringBuilder("The serializer of type ").append(serializerType.getName()) .append(" failed to be instantiated using its default constructor. Please ensure that an") .append(" accessible default constructor is available. ").toString()); } /** *

Displays a detailed error message with information on the {@link Class} of the {@link Serializer} * which failed to be instantiated due to an {@link EntityResolutionFailedException}.

* *

See {@link AbstractSerializer#AbstractSerializer(Class)}.

* * @param serializerType * the {@link Class} of the {@link Serializer} which failed to be instantiated *

* @param erfe * the {@link EntityResolutionFailedException} which served as the root cause * for {@link Serializer} instantiation failure *

* @since 1.3.0 */ public SerializerInstantiationException( @SuppressWarnings("rawtypes") Class serializerType, EntityResolutionFailedException erfe) { super(new StringBuilder("Serializers of type ").append(serializerType.getName()) .append(" produce an output which cannot be translated to an ") .append(HttpEntity.class.getName()) .append(". \nPlease verify that the output type complies with those specified on ") .append(Entities.class.getName()).append("#resolve(Class) or at the very least ") .append("ensure that the output type is \"java.io.Serializable\"").toString(), erfe); } /** *

Displays a detailed error message with information on the {@link Class} of the {@link Serializer} * which failed to be instantiated, while preserving the stacktrace.

* * @param serializerType * the {@link Class} of the {@link Serializer} which failed to be instantiated *

* @param rootCause * the root {@link Throwable} cause which led to instantiation failure *

* @since 1.3.0 */ public SerializerInstantiationException( Class> serializerType, Throwable rootCause) { super(new StringBuilder("The serializer of type ").append(serializerType.getName()) .append(" failed to be instantiated using its default constructor. Please ensure that an") .append(" accessible default constructor is available. ").toString(), rootCause); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy