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

com.jwebmp.entityassist.services.EntityAssistIDMapping Maven / Gradle / Ivy

There is a newer version: 0.68.0.1
Show newest version
package com.jwebmp.entityassist.services;

import com.jwebmp.guicedinjection.interfaces.IDefaultService;
import com.jwebmp.logger.LogFactory;

import java.lang.reflect.ParameterizedType;
import java.util.logging.Level;

/**
 * Maps an entity assist ID Mapping for db returned data from the query.
 * 

* Is a class and not an interface to read the typed mappings * * @param * The Database Returned Type * @param * The object to render */ public abstract class EntityAssistIDMapping implements IDefaultService> { public abstract OBJECT toObject(DB dbReturned); @SuppressWarnings("unchecked") public Class getDBClassType() { try { return (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; } catch (Exception e) { LogFactory.getLog("EntityAssistIDMapping") .log(Level.SEVERE, "Cannot return the db or entity id class - config seems wrong. " + "Check that a builder is attached to this entity as the second generic field type\n" + e, e); } return null; } @SuppressWarnings("unchecked") public Class getObjectClassType() { try { return (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[1]; } catch (Exception e) { LogFactory.getLog("EntityAssistIDMapping") .log(Level.SEVERE, "Cannot return the db or entity id class - config seems wrong. " + "Check that a builder is attached to this entity as the second generic field type\n" + e, e); } return null; } }