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).

sO safeUnstructureAllowingClasses(S s, Class... allowedClasses) {
  final Set<S> allowedClassesSet = mapToSet className(allowedClasses);
  O classFinder = func(S name) {
    if (!allowedClassesSet.contains(name)) fail("Class not allowed to unstructure: " + name);
    ret classForName(name);
  };
  ret unstructure(s, false, classFinder);
}

Author comment

Began life as a copy of #1020506

download  show line numbers  debug dex   

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

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: 21 / 46
Version history: 3 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1030120 & http://1030120.tinybrain.de