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

18
LINES

< > BotCompany Repo | #1024130 // syncGetOrCreate - map lookup or create from class, synchronized on map

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

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

static <A, B> B syncGetOrCreate(Map<A, B> map, A key, Class<? extends B> c) ctex {
  synchronized(map) { ret getOrCreate(map, key, c); }
}

// f : func -> B
static <A, B> B syncGetOrCreate(Map<A, B> map, A key, O f) {
  synchronized(map) { ret getOrCreate(map, key, f); }
}


static <A, B> B nuLike syncGetOrCreate(Class<? extends B> c, Map<A, B> map, A key) {
  ret syncGetOrCreate(map, key, c);
}


static <A, B> B syncGetOrCreate(Map<A, B> map, A key, IF0<B> f) {
  synchronized(map) { ret getOrCreate(map, key, f); }
}

Author comment

Began life as a copy of #1013935

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024130
Snippet name: syncGetOrCreate - map lookup or create from class, synchronized on map
Eternal ID of this version: #1024130/3
Text MD5: ca183bf4b9496b042bd99501431b7a34
Transpilation MD5: fe677dd602cb88080e87e6c43be2176d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-07-23 18:27:12
Source code size: 539 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 278 / 386
Version history: 2 change(s)
Referenced in: [show references]