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

19
LINES

< > BotCompany Repo | #1011578 // paramsPlus - concat param arrays (second one overrides)

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

Libraryless. Click here for Pure Java version (2872L/17K).

1  
static O[] paramsPlus(O[] a1, O... a2) {
2  
  if (a2 == null) ret a1;
3  
  if (a1 == null) ret a2;
4  
  if (l(a1) == 1 && a1[0] instanceof Map)
5  
    ret new O[] { mapPlus((Map) a1[0], a2) };
6  
  assertEvenLength(a1);
7  
  assertEvenLength(a2);
8  
  Map map = paramsToOrderedMap(a1);
9  
  int n = l(a2);
10  
  for (int i = 0; i < n; i += 2) {
11  
    O key = a2[i];
12  
    if (key != null) map.put(key, a2[i+1]);
13  
  }
14  
  ret mapToParams(map);
15  
}
16  
17  
static O[] paramsPlus(Map a1, O... a2) {
18  
  ret paramsPlus(new O[] {a1}, a2);
19  
}

Author comment

Began life as a copy of #1003112

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: #1011578
Snippet name: paramsPlus - concat param arrays (second one overrides)
Eternal ID of this version: #1011578/12
Text MD5: 7aa1e3e444d1dcb2cad68fa0ff3be791
Transpilation MD5: 36050b0e00f227b00dc3e4ad4f6cda70
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-02-22 13:17:10
Source code size: 507 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 564 / 662
Version history: 11 change(s)
Referenced in: [show references]