Example usage for android.database Cursor getClass

List of usage examples for android.database Cursor getClass

Introduction

In this page you can find the example usage for android.database Cursor getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.wit.android.support.database.adapter.BaseCursorAdapter.java

/**
 * Inner implementation of {@link #onWrapCursor(android.database.Cursor)} to hide such an implementation.
 *///from ww w.  java  2  s .c  om
@SuppressWarnings("unchecked")
private C wrapCursorInner(Cursor cursor) {
    if (mClassOfCursorWrapper != null) {
        if (mClassOfCursorWrapper.equals(cursor.getClass())) {
            // Do not wrap same classes.
            return (C) cursor;
        }

        try {
            return mClassOfCursorWrapper.getConstructor(Cursor.class).newInstance(cursor);
        } catch (InstantiationException | IllegalAccessException | InvocationTargetException
                | NoSuchMethodException e) {
            throw new IllegalStateException("Failed to create cursor wrapper from class("
                    + mClassOfCursorWrapper + "). "
                    + "Check if this wrapper class has public access and public constructor which takes Cursor as parameter.");
        }
    }
    return (C) cursor;
}