com.omertron.imdbapi.wrapper.AbstractWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api-imdb Show documentation
Show all versions of api-imdb Show documentation
API for the mobile JSON API of IMDB
package com.omertron.imdbapi.wrapper;
import com.omertron.imdbapi.model.AbstractJsonMapping;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class AbstractWrapper extends AbstractJsonMapping implements IWrapperResult {
private static final Logger LOG = LoggerFactory.getLogger(AbstractWrapper.class);
protected E result;
@Override
public final E getResult(Class resultClass) {
// If the wrapper has an error, propogate it to the subclass
if (isError()) {
try {
// If the wrapper is in error, there is no result class, so we need to create one
result = resultClass.newInstance();
result.setStatusMessage(getStatusMessage());
} catch (InstantiationException | IllegalAccessException ex) {
LOG.warn("Failed to instantiate {}", resultClass.getSimpleName(), ex);
result = null;
}
}
// Return the result
return result;
}
}
© 2015 - 2026 Weber Informatics LLC | Privacy Policy