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

30
LINES

< > BotCompany Repo | #1005039 - findConceptWhere

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

Libraryless. Click here for Pure Java version (14730L/95K).

// TODO: if field is a Ref<>, you can thoretically use findBackRefs

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

static <A extends Concept> A findConceptWhere(Concepts concepts, Class<A> c, O... params) {
  ping();
  params = expandParams(c, params);
  
  // indexed
  if (concepts.fieldIndices != null)
    for (int i = 0; i < l(params); i += 2) {
      IFieldIndex<A, O> index = concepts.getFieldIndex(c, (S) params[i]);
      if (index != null) {
        for (A x : index.getAll(params[i+1]))
          if (checkConceptFields(x, params)) ret x;
        null;
      }
    }
    
  // table scan
  for (A x : concepts.list(c)) if (checkConceptFields(x, params)) ret x;
  null;
}

static Concept findConceptWhere(Concepts concepts, S c, O... params) {
  for (Concept x : concepts.list(c)) if (checkConceptFields(x, params)) ret x;
  null;
}

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: #1005039
Snippet name: findConceptWhere
Eternal ID of this version: #1005039/12
Text MD5: b7335a922e234dd6f5a1ffc1daaacd57
Transpilation MD5: 86bf3ffb13c4cc27e51955bccf67c3ea
Author: stefan
Category: javax / concepts
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-03-19 17:46:20
Source code size: 964 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 469 / 470
Version history: 11 change(s)
Referenced in: [show references]