jsinterop.annotations.JsOverlay Java Examples

The following examples show how to use jsinterop.annotations.JsOverlay. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsPropertyMap.java    From jsinterop-base with Apache License 2.0 5 votes vote down vote up
/** Returns an object literal as {@code JsPropertyMap} that has provided key-value pairs. */
@JsOverlay
static <T> JsPropertyMap<T> of(String k, @DoNotAutobox T v) {
  JsPropertyMap<T> map = of();
  map.set(k, v);
  return map;
}
 
Example #2
Source File: CastToTypeVariable.java    From j2cl with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unused", "unchecked"})
@JsOverlay
public final T setField(int index, boolean value) {
  Object o = new Object();
  T[] a = (T[]) o;
  return (T) this;
}
 
Example #3
Source File: Any.java    From jsinterop-base with Apache License 2.0 5 votes vote down vote up
/**
 * Performs unchecked cast to lefthand-side type. You should always prefer regular casting over
 * this (unless you know what you are doing!).
 */
@JsOverlay
@UncheckedCast
@SuppressWarnings({"TypeParameterUnusedInFormals", "unchecked"})
default <T> T uncheckedCast() {
  return (T) this;
}
 
Example #4
Source File: TestCaseLogger.java    From j2cl with Apache License 2.0 5 votes vote down vote up
@JsOverlay
public static void log(String message) {
  // We are using the prefix here so that we can clearly identify messages coming from our tests
  // vs. messages that just happened to be in the output of a test (e.g. coming from the
  // testing infrastructure itself).
  getActiveTestCase().saveMessage("[java_message_from_test] " + message);
}
 
Example #5
Source File: Main.java    From j2cl with Apache License 2.0 5 votes vote down vote up
@JsOverlay
public final int bar() {
  return new Intf() {
    @Override
    public int run(int x, int y) {
      return x + y;
    }
  }.run(10, 20);
}
 
Example #6
Source File: JsPropertyMap.java    From jsinterop-base with Apache License 2.0 5 votes vote down vote up
/** Returns an object literal as {@code JsPropertyMap} that has provided key-value pairs. */
@JsOverlay
static <T> JsPropertyMap<T> of(
    String k1, @DoNotAutobox T v1, String k2, @DoNotAutobox T v2, String k3, @DoNotAutobox T v3) {
  JsPropertyMap<T> map = of();
  map.set(k1, v1);
  map.set(k2, v2);
  map.set(k3, v3);
  return map;
}
 
Example #7
Source File: JsConstructorFn.java    From jsinterop-base with Apache License 2.0 5 votes vote down vote up
/** Returns this constructor as a Class instance. */
@JsOverlay
default Class<T> asClass() {
  Class<T> clazz = InternalJsUtil.toClass(this);
  checkType(clazz != null);
  return clazz;
}
 
Example #8
Source File: JsPropertyMap.java    From jsinterop-base with Apache License 2.0 5 votes vote down vote up
/** Returns an object literal as {@code JsPropertyMap} that has provided key-value pairs. */
@JsOverlay
static <T> JsPropertyMap<T> of(String k1, @DoNotAutobox T v1, String k2, @DoNotAutobox T v2) {
  JsPropertyMap<T> map = of();
  map.set(k1, v1);
  map.set(k2, v2);
  return map;
}
 
Example #9
Source File: Main.java    From j2cl with Apache License 2.0 5 votes vote down vote up
@JsOverlay
public final void overlayWithJsFunction() {
  new Intf() {
    @Override
    public void run() {}
  }.run();
}
 
Example #10
Source File: MyNativeType.java    From j2cl with Apache License 2.0 5 votes vote down vote up
@JsOverlay
public final void useFieldsAndMethods() {
  @SuppressWarnings("unused")
  int value = publicField + privateField + packageField + protectedField;
  publicMethod();
  privateMethod();
  packageMethod();
  protectedMethod();
}
 
Example #11
Source File: NativeArray.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
public final Object a() {
  return new Object() {};
}
 
Example #12
Source File: Main.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
private final int foo() {
  return 1;
}
 
Example #13
Source File: Main.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
private int baz() {
  return 1;
}
 
Example #14
Source File: Main.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
public static int varargs(int... a) {
  return a[0];
}
 
Example #15
Source File: Main.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
private static final Object getStaticField() {
  return staticField;
}
 
Example #16
Source File: NativeJsTypeTest.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
public final Object getObject() {
  return object;
}
 
Example #17
Source File: ObjectMap.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
static ObjectMap<String> createForString() {
  return null;
}
 
Example #18
Source File: Main.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
public final void overlay() {}
 
Example #19
Source File: NativeJsTypeTest.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
public final NativeJsTypeWithOverlay setK(int k) {
  this.k = k;
  return this;
}
 
Example #20
Source File: Main.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
final void doTransitiveInstanceMethod(String arg1) {}
 
Example #21
Source File: Main.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
public final int callM() {
  return m();
}
 
Example #22
Source File: NativeArray.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
public final Object getObject() {
  return new Object() {};
}
 
Example #23
Source File: NativeArray2.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
public final Object getObject() {
  return new Object() {};
}
 
Example #24
Source File: Java8Test.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
default int len() {
  return this.getLength();
}
 
Example #25
Source File: Main.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
public int buzz() {
  return 42;
}
 
Example #26
Source File: Main.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
private int baz() {
  return 30;
}
 
Example #27
Source File: Main.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
private final int foo() {
  return 20;
}
 
Example #28
Source File: Main.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
default int overlayMethod() {
  return foo(42);
}
 
Example #29
Source File: Main.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
public static final int fun(int a, int b) {
  return a > b ? a + b : a * b;
}
 
Example #30
Source File: Constructor.java    From j2cl with Apache License 2.0 4 votes vote down vote up
@JsOverlay
public final boolean isPrimitive() {
  return Util.$extractClassType(this) == Util.TYPE_PRIMITIVE;
}