@Test public void testDerivedReflection () throws ReflectiveOperationException { ObjectMeta meta = new ObjectMeta(); Foo bar = new Bar(); bar.setMetadata(meta); assertSame(meta, ReflectUtils.objectMetadata(bar)); }
public static ObjectMeta objectMetadata(Object obj) throws ReflectiveOperationException { if (obj instanceof HasMetadata) { return ((HasMetadata) obj).getMetadata(); } try { Method mdField = obj.getClass().getMethod("getMetadata"); return (ObjectMeta) mdField.invoke(obj); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new ReflectiveOperationException(e); } }
ReflectUtils { public static ObjectMeta objectMetadata(Object obj) throws ReflectiveOperationException { if (obj instanceof HasMetadata) { return ((HasMetadata) obj).getMetadata(); } try { Method mdField = obj.getClass().getMethod("getMetadata"); return (ObjectMeta) mdField.invoke(obj); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new ReflectiveOperationException(e); } } }
ReflectUtils { public static ObjectMeta objectMetadata(Object obj) throws ReflectiveOperationException { if (obj instanceof HasMetadata) { return ((HasMetadata) obj).getMetadata(); } try { Method mdField = obj.getClass().getMethod("getMetadata"); return (ObjectMeta) mdField.invoke(obj); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new ReflectiveOperationException(e); } }  }
ReflectUtils { public static ObjectMeta objectMetadata(Object obj) throws ReflectiveOperationException { if (obj instanceof HasMetadata) { return ((HasMetadata) obj).getMetadata(); } try { Method mdField = obj.getClass().getMethod("getMetadata"); return (ObjectMeta) mdField.invoke(obj); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new ReflectiveOperationException(e); } }  static ObjectMeta objectMetadata(Object obj); static String namespace(Object obj); static ListMeta listMetadata(Object listObj); static List<ApiType> getItems(Object listObj); }
ReflectUtils { public static ObjectMeta objectMetadata(Object obj) throws ReflectiveOperationException { if (obj instanceof HasMetadata) { return ((HasMetadata) obj).getMetadata(); } try { Method mdField = obj.getClass().getMethod("getMetadata"); return (ObjectMeta) mdField.invoke(obj); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new ReflectiveOperationException(e); } }  static ObjectMeta objectMetadata(Object obj); static String namespace(Object obj); static ListMeta listMetadata(Object listObj); static List<ApiType> getItems(Object listObj);  }