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

22
LINES

< > BotCompany Repo | #1005040 // uniqueConcept - now with db lock

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

Libraryless. Click here for Pure Java version (15592L/100K).

static <A extends Concept> A uniqueConcept(Class<A> c, O... params) {
  ret uniqueConcept(db_mainConcepts(), c, params);
}

static <A extends Concept> A uniqueConcept(Concepts cc, Class<A> c, O... params) {
  temp tempDBLock(cc);
  params = expandParams(c, params);
  A x = findConceptWhere(cc, c, params);
  if (x == null) {
    x = unlisted(c);
    ifdef uniqueConcept_debug
      printStackTrace(renderVars_str uniqueConcept_debug(action := "Made unlisted", +cc, +c, +params, +x));
    endifdef
    csetAll(x, params);
    cc.register(x);
  } else {
    ifdef uniqueConcept_debug
      printStackTrace(renderVars_str printVars_str uniqueConcept_debug(action := "Found existing", +cc, +c, +params, +x));
    endifdef
  }
  ret x;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005040
Snippet name: uniqueConcept - now with db lock
Eternal ID of this version: #1005040/12
Text MD5: a0272c3ac004a0f151c2df90f08b82f5
Transpilation MD5: d86d0cdf3fba8f53afca4c8890cc0904
Author: stefan
Category: javax / concepts
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-18 16:28:28
Source code size: 754 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 707 / 793
Version history: 11 change(s)
Referenced in: #1005261 - unique - short for uniqueConcept
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1008467 - uniq2 - get or make concept with certain parameters; return whether it was new. now synced
#1011021 - uniq_debug - get or make concept with certain parameters
#1023275 - uniqCI - get or make concept with certain parameters, ignoring case
#1030272 - uniq_cached - uniq, but create index too. for now only without parameters