1 | static O cloneWithoutField(O o, S fieldToSkip) ctex { |
2 | if (o == null) null; |
3 | final O clone = nuObject(o.getClass()); |
4 | Class c = o.getClass(); |
5 | while (c != Object.class) { |
6 | Field[] fields = c.getDeclaredFields(); |
7 | for (final Field field : fields) { |
8 | if (eq(field.getName(), fieldToSkip)) continue; |
9 | if ((field.getModifiers() & Modifier.STATIC) != 0) continue; |
10 | field.setAccessible(true); |
11 | field.set(clone, field.get(o)); |
12 | } |
13 | c = c.getSuperclass(); |
14 | } |
15 | return clone; |
16 | } |
Began life as a copy of #1001715
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: | #1015334 |
Snippet name: | cloneWithoutField (shallow clone) |
Eternal ID of this version: | #1015334/5 |
Text MD5: | bae0c4e0d003f3e78a8f5b2eb42420f3 |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-05-13 00:23:43 |
Source code size: | 521 bytes / 16 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 330 / 388 |
Version history: | 4 change(s) |
Referenced in: | [show references] |