1 package sun.jvm.hotspot.utilities.soql.wrapper;
   2 
   3 import java.util.Arrays;
   4 import jdk.dynalink.beans.StaticClass;
   5 import jdk.nashorn.api.scripting.AbstractJSObject;
   6 
   7 
   8 public class JSObjectClassWrapper extends AbstractJSObject{
   9 
  10   private final Class<?> clazz;
  11 
  12   public JSObjectClassWrapper(Object clazz){
  13     StaticClass staticClass = (StaticClass)clazz;
  14     this.clazz = staticClass.getRepresentedClass();
  15   }
  16 
  17   @Override
  18   public Object getMember(String name){
  19     var method = Arrays.stream(clazz.getMethods())
  20                        .filter(m -> m.getName().equals(name))
  21                        .findFirst()
  22                        .get();
  23     return new JSObjectMethodWrapper(clazz, method);
  24   }
  25 
  26   @Override
  27   public boolean hasMember(String name){
  28     return Arrays.stream(clazz.getMethods())
  29                  .anyMatch(m -> m.getName().equals(name));
  30   }
  31 
  32 }