static <A> A cloneWithoutFields(A o, Set<S> fieldsToSkip) ctex { if (o == null) null; final A clone = cast nuObject(o.getClass()); Class c = o.getClass(); while (c != Object.class) { Field[] fields = c.getDeclaredFields(); for (final Field field : fields) { if (contains(fieldsToSkip, field.getName())) continue; if ((field.getModifiers() & Modifier.STATIC) != 0) continue; field.setAccessible(true); field.set(clone, field.get(o)); } c = c.getSuperclass(); } return clone; } static <A> A cloneWithoutFields(A o, S... fieldsToSkip) { ret cloneWithoutFields(o, asHashSet(fieldsToSkip)); }
Began life as a copy of #1015334
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017345 |
Snippet name: | cloneWithoutFields (shallow clone) |
Eternal ID of this version: | #1017345/4 |
Text MD5: | 360958d82754d226158d17a3e5cc6132 |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-07-17 21:22:47 |
Source code size: | 661 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 449 / 512 |
Version history: | 3 change(s) |
Referenced in: | [show references] |