/** * Retrieves a {@link SqliteTypeAdapter} for the given {@link Class}. * * @param type the {@code Class} to retrieve a {@code SqliteTypeResolver} for * @return {@code SqliteTypeResolver} for the given type * @throws InvalidMappingException if no {@code SqliteTypeResolver} exists for the given {@code * Class} */ @SuppressWarnings("unchecked") @Override public <T> SqliteTypeAdapter<T> resolveType(Class<T> type) throws InvalidMappingException { type = Primitives.unwrap(type); if (mTypeAdapters.containsKey(type)) return (SqliteTypeAdapter<T>) mTypeAdapters.get(type); throw new InvalidMappingException( String.format(mPropLoader.getErrorMessage("CANNOT_MAP_TYPE"), type.getSimpleName())); }
/** * Retrieves the SQLite data type associated with the given {@link Object}. * * @param object the {@code Object} to retrieve the SQLite data type for * @return {@code SqliteDataType} that matches the given {@code Object} */ public SqliteDataType getSqliteDataType(Object object) { SqliteDataType ret = null; Class<?> c = Primitives.unwrap(object.getClass()); if (mTypeAdapters.containsKey(c)) ret = mTypeAdapters.get(c).getSqliteType(); else if (mTypePolicy.isDomainModel(c)) ret = getSqliteDataType(mPersistencePolicy.getPrimaryKeyField(c)); return ret; }