Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

16
LINES

< > BotCompany Repo | #1015334 // cloneWithoutField (shallow clone)

JavaX fragment (include)

static O cloneWithoutField(O o, S fieldToSkip) ctex {
  if (o == null) null;
  final O clone = nuObject(o.getClass());
  Class c = o.getClass();
  while (c != Object.class) {
    Field[] fields = c.getDeclaredFields();
    for (final Field field : fields) {
      if (eq(field.getName(), fieldToSkip)) continue;
      if ((field.getModifiers() & Modifier.STATIC) != 0) continue;
      field.setAccessible(true);
      field.set(clone, field.get(o));
    }
    c = c.getSuperclass();
  }
  return clone;
}

Author comment

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: 267 / 316
Version history: 4 change(s)
Referenced in: [show references]