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).

1  
// TODO: if field is a Ref<>, you can thoretically use findBackRefs
2  
3  
static <A extends Concept> A nuLike findConceptWhere(Class<A> c, O... params) {
4  
  ret findConceptWhere(db_mainConcepts(), c, params);
5  
}
6  
7  
static <A extends Concept> A findConceptWhere(Concepts concepts, Class<A> c, O... params) {
8  
  ping();
9  
  params = expandParams(c, params);
10  
  
11  
  // indexed
12  
  if (concepts.fieldIndices != null)
13  
    for (int i = 0; i < l(params); i += 2) {
14  
      IFieldIndex<A, O> index = concepts.getFieldIndex(c, (S) params[i]);
15  
      if (index != null) {
16  
        for (A x : index.getAll(params[i+1]))
17  
          if (checkConceptFields(x, params)) ret x;
18  
        null;
19  
      }
20  
    }
21  
    
22  
  // table scan
23  
  for (A x : concepts.list(c)) if (checkConceptFields(x, params)) ret x;
24  
  null;
25  
}
26  
27  
static Concept findConceptWhere(Concepts concepts, S c, O... params) {
28  
  for (Concept x : concepts.list(c)) if (checkConceptFields(x, params)) ret x;
29  
  null;
30  
}

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: 579 / 630
Version history: 11 change(s)
Referenced in: [show references]