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

8
LINES

< > BotCompany Repo | #1030120 // safeUnstructureAllowingClasses - safe-unstructure, but allowing a few main$ classes, takes Class references, so "safe code"-safe (haha)

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

Libraryless. Click here for Pure Java version (4872L/30K).

1  
sO safeUnstructureAllowingClasses(S s, Class... allowedClasses) {
2  
  final Set<S> allowedClassesSet = mapToSet className(allowedClasses);
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 unstructure(s, false, classFinder);
8  
}

Author comment

Began life as a copy of #1020506

download  show line numbers  debug dex  old transpilations   

Travelled to 5 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030120
Snippet name: safeUnstructureAllowingClasses - safe-unstructure, but allowing a few main$ classes, takes Class references, so "safe code"-safe (haha)
Eternal ID of this version: #1030120/4
Text MD5: 08e20f815381ea98e57adb9434b3b596
Transpilation MD5: 5e222ada8d79f56ff03e2f2e8731b195
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-12-02 23:30:16
Source code size: 347 bytes / 8 lines
Pitched / IR pitched: No / No
Views / Downloads: 205 / 304
Version history: 3 change(s)
Referenced in: [show references]