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

8
LINES

< > BotCompany Repo | #1020506 // safeUnstructureAllowingCertainClasses - safe-unstructure, but allowing a few main$ classes

JavaX fragment (include)

1  
static <A> A safeUnstructureAllowingCertainClasses(S s, S... allowedClasses) {
2  
  final Set<S> allowedClassesSet = asSet(map(allowedClasses, func(S name) -> S { "main$" + name }));
3  
  O classFinder = func(S name) {
4  
    if (!allowedClassesSet.contains(name)) fail("Class not allowed to unstructure: " + name);
5  
    ret classForName(name);
6  
  };
7  
  ret (A) unstructure(s, false, classFinder);
8  
}

Author comment

Began life as a copy of #1006909

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020506
Snippet name: safeUnstructureAllowingCertainClasses - safe-unstructure, but allowing a few main$ classes
Eternal ID of this version: #1020506/1
Text MD5: d7cdfba7ceb79a8b92bf4518841a2394
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-25 16:46:16
Source code size: 394 bytes / 8 lines
Pitched / IR pitched: No / No
Views / Downloads: 261 / 296
Referenced in: [show references]