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

13
LINES

< > BotCompany Repo | #1030746 // replaceConceptAndUpdateRefs - replace a concept with a new one, keeping its ID and updating all references

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (15653L/101K).

1  
static <A extends Concept> A replaceConceptAndUpdateRefs(Concept a, A b) {
2  
  assertTrue("object to replace with must be unlisted", isUnlisted(b));
3  
  Concepts cc = a.concepts();
4  
  assertTrue("object to replace must be listed", cc != null);
5  
  L<Concept.Ref> refs = allBackRefObjects(a);
6  
  b.id = a.id;
7  
  deleteConcept(a);
8  
  cc.register_phase2(b);
9  
  cset(a, meta_migratedTo := b); // for objects that may have had direct pointers
10  
  for (Concept.Ref ref : refs)
11  
    ref.set(b);
12  
  ret b;
13  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030746
Snippet name: replaceConceptAndUpdateRefs - replace a concept with a new one, keeping its ID and updating all references
Eternal ID of this version: #1030746/10
Text MD5: b0553b44229194f95842f47532307d8e
Transpilation MD5: e00668d109a9059eb1f3d409d6b06dc0
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-21 23:47:57
Source code size: 496 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 253 / 367
Version history: 9 change(s)
Referenced in: [show references]