All Downloads are FREE. Search and download functionalities are using the official Maven repository.

elemental2.core.ProxyHandler Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2018 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package elemental2.core;

import jsinterop.annotations.JsFunction;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
import jsinterop.base.Js;
import jsinterop.base.JsConstructorFn;
import jsinterop.base.JsPropertyMap;

@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public interface ProxyHandler {
  @JsFunction
  public interface ApplyFn {
    Object onInvoke(TARGET p0, Object p1, JsArray p2);
  }

  @JsFunction
  public interface ConstructFn {
    @JsOverlay
    default JsObject onInvoke(TARGET p0, JsArray p1, Class p2) {
      return onInvoke(p0, p1, Js.asConstructorFn(p2));
    }

    JsObject onInvoke(TARGET p0, JsArray p1, JsConstructorFn p2);
  }

  @JsFunction
  public interface DefinePropertyFn {
    @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
    public interface P1UnionType {
      @JsOverlay
      static ProxyHandler.DefinePropertyFn.P1UnionType of(Object o) {
        return Js.cast(o);
      }

      @JsOverlay
      default Object asObject() {
        return Js.cast(this);
      }

      @JsOverlay
      default String asString() {
        return Js.asString(this);
      }

      @JsOverlay
      default boolean isObject() {
        return (Object) this instanceof Object;
      }

      @JsOverlay
      default boolean isString() {
        return (Object) this instanceof String;
      }
    }

    @JsOverlay
    default boolean onInvoke(TARGET p0, Object p1, ObjectPropertyDescriptor p2) {
      return onInvoke(p0, Js.uncheckedCast(p1), p2);
    }

    boolean onInvoke(
        TARGET p0, ProxyHandler.DefinePropertyFn.P1UnionType p1, ObjectPropertyDescriptor p2);

    @JsOverlay
    default boolean onInvoke(TARGET p0, String p1, ObjectPropertyDescriptor p2) {
      return onInvoke(p0, Js.uncheckedCast(p1), p2);
    }
  }

  @JsFunction
  public interface DeletePropertyFn {
    @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
    public interface P1UnionType {
      @JsOverlay
      static ProxyHandler.DeletePropertyFn.P1UnionType of(Object o) {
        return Js.cast(o);
      }

      @JsOverlay
      default Object asObject() {
        return Js.cast(this);
      }

      @JsOverlay
      default String asString() {
        return Js.asString(this);
      }

      @JsOverlay
      default boolean isObject() {
        return (Object) this instanceof Object;
      }

      @JsOverlay
      default boolean isString() {
        return (Object) this instanceof String;
      }
    }

    @JsOverlay
    default boolean onInvoke(TARGET p0, Object p1) {
      return onInvoke(p0, Js.uncheckedCast(p1));
    }

    boolean onInvoke(TARGET p0, ProxyHandler.DeletePropertyFn.P1UnionType p1);

    @JsOverlay
    default boolean onInvoke(TARGET p0, String p1) {
      return onInvoke(p0, Js.uncheckedCast(p1));
    }
  }

  @JsFunction
  public interface GetFn {
    @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
    public interface P1UnionType {
      @JsOverlay
      static ProxyHandler.GetFn.P1UnionType of(Object o) {
        return Js.cast(o);
      }

      @JsOverlay
      default Object asObject() {
        return Js.cast(this);
      }

      @JsOverlay
      default String asString() {
        return Js.asString(this);
      }

      @JsOverlay
      default boolean isObject() {
        return (Object) this instanceof Object;
      }

      @JsOverlay
      default boolean isString() {
        return (Object) this instanceof String;
      }
    }

    @JsOverlay
    default Object onInvoke(TARGET p0, Object p1, JsObject p2) {
      return onInvoke(p0, Js.uncheckedCast(p1), p2);
    }

    @JsOverlay
    default Object onInvoke(TARGET p0, Object p1, Object p2) {
      return onInvoke(p0, p1, Js.uncheckedCast(p2));
    }

    Object onInvoke(TARGET p0, ProxyHandler.GetFn.P1UnionType p1, JsObject p2);

    @JsOverlay
    default Object onInvoke(TARGET p0, ProxyHandler.GetFn.P1UnionType p1, Object p2) {
      return onInvoke(p0, p1, Js.uncheckedCast(p2));
    }

    @JsOverlay
    default Object onInvoke(TARGET p0, String p1, JsObject p2) {
      return onInvoke(p0, Js.uncheckedCast(p1), p2);
    }

    @JsOverlay
    default Object onInvoke(TARGET p0, String p1, Object p2) {
      return onInvoke(p0, p1, Js.uncheckedCast(p2));
    }
  }

  @JsFunction
  public interface GetOwnPropertyDescriptorFn {
    @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
    public interface P1UnionType {
      @JsOverlay
      static ProxyHandler.GetOwnPropertyDescriptorFn.P1UnionType of(Object o) {
        return Js.cast(o);
      }

      @JsOverlay
      default Object asObject() {
        return Js.cast(this);
      }

      @JsOverlay
      default String asString() {
        return Js.asString(this);
      }

      @JsOverlay
      default boolean isObject() {
        return (Object) this instanceof Object;
      }

      @JsOverlay
      default boolean isString() {
        return (Object) this instanceof String;
      }
    }

    @JsOverlay
    default ObjectPropertyDescriptor onInvoke(TARGET p0, Object p1) {
      return onInvoke(
          p0, Js.uncheckedCast(p1));
    }

    ObjectPropertyDescriptor onInvoke(
        TARGET p0, ProxyHandler.GetOwnPropertyDescriptorFn.P1UnionType p1);

    @JsOverlay
    default ObjectPropertyDescriptor onInvoke(TARGET p0, String p1) {
      return onInvoke(
          p0, Js.uncheckedCast(p1));
    }
  }

  @JsFunction
  public interface GetPrototypeOfFn {
    JsObject onInvoke(TARGET p0);
  }

  @JsFunction
  public interface HasFn {
    @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
    public interface P1UnionType {
      @JsOverlay
      static ProxyHandler.HasFn.P1UnionType of(Object o) {
        return Js.cast(o);
      }

      @JsOverlay
      default Object asObject() {
        return Js.cast(this);
      }

      @JsOverlay
      default String asString() {
        return Js.asString(this);
      }

      @JsOverlay
      default boolean isObject() {
        return (Object) this instanceof Object;
      }

      @JsOverlay
      default boolean isString() {
        return (Object) this instanceof String;
      }
    }

    @JsOverlay
    default boolean onInvoke(TARGET p0, Object p1) {
      return onInvoke(p0, Js.uncheckedCast(p1));
    }

    boolean onInvoke(TARGET p0, ProxyHandler.HasFn.P1UnionType p1);

    @JsOverlay
    default boolean onInvoke(TARGET p0, String p1) {
      return onInvoke(p0, Js.uncheckedCast(p1));
    }
  }

  @JsFunction
  public interface IsExtensibleFn {
    boolean onInvoke(TARGET p0);
  }

  @JsFunction
  public interface OwnKeysFn {
    @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
    public interface ArrayUnionType {
      @JsOverlay
      static ProxyHandler.OwnKeysFn.ArrayUnionType of(Object o) {
        return Js.cast(o);
      }

      @JsOverlay
      default Object asObject() {
        return Js.cast(this);
      }

      @JsOverlay
      default String asString() {
        return Js.asString(this);
      }

      @JsOverlay
      default boolean isObject() {
        return (Object) this instanceof Object;
      }

      @JsOverlay
      default boolean isString() {
        return (Object) this instanceof String;
      }
    }

    JsArray onInvoke(TARGET p0);
  }

  @JsFunction
  public interface PreventExtensionsFn {
    boolean onInvoke(TARGET p0);
  }

  @JsFunction
  public interface SetFn {
    @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
    public interface P1UnionType {
      @JsOverlay
      static ProxyHandler.SetFn.P1UnionType of(Object o) {
        return Js.cast(o);
      }

      @JsOverlay
      default Object asObject() {
        return Js.cast(this);
      }

      @JsOverlay
      default String asString() {
        return Js.asString(this);
      }

      @JsOverlay
      default boolean isObject() {
        return (Object) this instanceof Object;
      }

      @JsOverlay
      default boolean isString() {
        return (Object) this instanceof String;
      }
    }

    @JsOverlay
    default boolean onInvoke(TARGET p0, Object p1, Object p2, JsObject p3) {
      return onInvoke(p0, Js.uncheckedCast(p1), p2, p3);
    }

    @JsOverlay
    default boolean onInvoke(TARGET p0, Object p1, Object p2, Object p3) {
      return onInvoke(p0, p1, p2, Js.uncheckedCast(p3));
    }

    boolean onInvoke(TARGET p0, ProxyHandler.SetFn.P1UnionType p1, Object p2, JsObject p3);

    @JsOverlay
    default boolean onInvoke(TARGET p0, ProxyHandler.SetFn.P1UnionType p1, Object p2, Object p3) {
      return onInvoke(p0, p1, p2, Js.uncheckedCast(p3));
    }

    @JsOverlay
    default boolean onInvoke(TARGET p0, String p1, Object p2, JsObject p3) {
      return onInvoke(p0, Js.uncheckedCast(p1), p2, p3);
    }

    @JsOverlay
    default boolean onInvoke(TARGET p0, String p1, Object p2, Object p3) {
      return onInvoke(p0, p1, p2, Js.uncheckedCast(p3));
    }
  }

  @JsFunction
  public interface SetPrototypeOfFn {
    boolean onInvoke(TARGET p0, JsObject p1);

    @JsOverlay
    default boolean onInvoke(TARGET p0, Object p1) {
      return onInvoke(p0, Js.uncheckedCast(p1));
    }
  }

  @JsOverlay
  static  ProxyHandler create() {
    return Js.uncheckedCast(JsPropertyMap.of());
  }

  @JsProperty
  ProxyHandler.ApplyFn getApply();

  @JsProperty
  ProxyHandler.ConstructFn getConstruct();

  @JsProperty
  ProxyHandler.DefinePropertyFn getDefineProperty();

  @JsProperty
  ProxyHandler.DeletePropertyFn getDeleteProperty();

  @JsProperty
  ProxyHandler.GetFn getGet();

  @JsProperty
  ProxyHandler.GetOwnPropertyDescriptorFn getGetOwnPropertyDescriptor();

  @JsProperty
  ProxyHandler.GetPrototypeOfFn getGetPrototypeOf();

  @JsProperty
  ProxyHandler.HasFn getHas();

  @JsProperty
  ProxyHandler.IsExtensibleFn getIsExtensible();

  @JsProperty
  ProxyHandler.OwnKeysFn getOwnKeys();

  @JsProperty
  ProxyHandler.PreventExtensionsFn getPreventExtensions();

  @JsProperty
  ProxyHandler.SetFn getSet();

  @JsProperty
  ProxyHandler.SetPrototypeOfFn getSetPrototypeOf();

  @JsProperty
  void setApply(ProxyHandler.ApplyFn apply);

  @JsProperty
  void setConstruct(ProxyHandler.ConstructFn construct);

  @JsProperty
  void setDefineProperty(ProxyHandler.DefinePropertyFn defineProperty);

  @JsProperty
  void setDeleteProperty(ProxyHandler.DeletePropertyFn deleteProperty);

  @JsProperty
  void setGet(ProxyHandler.GetFn get);

  @JsProperty
  void setGetOwnPropertyDescriptor(
      ProxyHandler.GetOwnPropertyDescriptorFn getOwnPropertyDescriptor);

  @JsProperty
  void setGetPrototypeOf(ProxyHandler.GetPrototypeOfFn getPrototypeOf);

  @JsProperty
  void setHas(ProxyHandler.HasFn has);

  @JsProperty
  void setIsExtensible(ProxyHandler.IsExtensibleFn isExtensible);

  @JsProperty
  void setOwnKeys(ProxyHandler.OwnKeysFn ownKeys);

  @JsProperty
  void setPreventExtensions(ProxyHandler.PreventExtensionsFn preventExtensions);

  @JsProperty
  void setSet(ProxyHandler.SetFn set);

  @JsProperty
  void setSetPrototypeOf(ProxyHandler.SetPrototypeOfFn setPrototypeOf);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy