static Field findField(Object o, String field) { if (o instanceof Class) return findField_static((Class) o, field); Class c = o.getClass(); for (Field f : c.getDeclaredFields()) if (f.getName().equals(field)) return f; throw new RuntimeException("Field '" + field + "' not found in " + c.getName()); } static Field findField_static(Class<?> c, String field) { for (Field f : c.getDeclaredFields()) if (f.getName().equals(field) && (f.getModifiers() & Modifier.STATIC) != 0) return f; throw new RuntimeException("Static field '" + field + "' not found in " + c.getName()); }
Began life as a copy of #1000619
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1000799 |
Snippet name: | findField function |
Eternal ID of this version: | #1000799/1 |
Text MD5: | 4446366abd7c61cc63723b4fc2158548 |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-08-28 16:05:35 |
Source code size: | 626 bytes / 16 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 732 / 981 |
Referenced in: | [show references] |