Example usage for java.lang.reflect AccessibleObject getClass

List of usage examples for java.lang.reflect AccessibleObject getClass

Introduction

In this page you can find the example usage for java.lang.reflect AccessibleObject getClass.

Prototype

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

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.mylife.hbase.mapper.HBaseEntityMapper.java

private byte[] getRowKeyFrom(final Object hbasePersistableObject) throws Exception {
    /*/*from   www  . j ava 2  s .c  o  m*/
     * Get the field or method that has the @HBaseRowKey annotation.
     */
    AccessibleObject accessibleObject = annotatedClassToAnnotatedHBaseRowKey
            .get(hbasePersistableObject.getClass());
    accessibleObject.setAccessible(true);
    /*
     * Either invoke a method to get the key value from the overall hbasePersistableObject or simple field value.
     */
    if (accessibleObject.getClass().isAssignableFrom(Method.class)) {
        return toBytes(((Method) accessibleObject).invoke(hbasePersistableObject, (Object[]) null));
    } else {
        return toBytes(((Field) accessibleObject).get(hbasePersistableObject));
    }
}