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

20
LINES

< > BotCompany Repo | #1009257 // cset - set fields in Concept object (with notification of DB)

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

Libraryless. Click here for Pure Java version (13189L/90K).

// returns number of changes
static int cset(Concept c, O... values) ctex {
  if (c == null) ret 0;
  warnIfOddCount(values = expandParams(c.getClass(), values));
  int changes = 0;
  for (int i = 0; i+1 < l(values); i += 2)
    if (_csetField(c, (S) values[i], values[i+1])) ++changes;
  ret changes;
}

static int cset(Iterable<? extends Concept> l, O... values) {
  int changes = 0;
  fOr (Concept c : l)
    changes += cset(c, values);
  ret changes;
}

static <A extends Concept> int cset(Concept.Ref<A> c, O... values) {
  ret cset(getVar(c), values);
}

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: #1009257
Snippet name: cset - set fields in Concept object (with notification of DB)
Eternal ID of this version: #1009257/16
Text MD5: 67fad25d4a8013de46edd7db2a76eedc
Transpilation MD5: a6a1cbfe143d5ec72245be87acf531d1
Author: stefan
Category: javax / concepts
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-10-07 22:59:23
Source code size: 578 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 739 / 922
Version history: 15 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1011826 - cset_compareByStruct - cset with structEq() instead of eq()
#1015812 - csetAndReturn - return the concept
#1023723 - cset_sync - set fields in Concept object (synchronizing on DB)
#1026008 - cSmartSet - set fields in Concept object with smart conversions (e.g. string to int)
#1028350 - cset_trueIfChanged
#1030713 - cclearAllDynamicFields - empty undeclared fields of concept