Skip to content

Commit

Permalink
Add j2cl specializers for Doubles.min/max, Floats.min/max, Ints.min/m…
Browse files Browse the repository at this point in the history
…ax, and Shorts.min/max.

RELNOTES=n/a

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=304448129
  • Loading branch information
marcianx authored and nick-someone committed Apr 2, 2020
1 parent d86c850 commit c34f584
Show file tree
Hide file tree
Showing 32 changed files with 364 additions and 50 deletions.
Expand Up @@ -194,6 +194,7 @@ public void testLastIndexOf() {
assertEquals(-1, Doubles.lastIndexOf(new double[] {NaN, 5.0}, NaN));
}

@GwtIncompatible
public void testMax_noArgs() {
try {
Doubles.max();
Expand All @@ -216,6 +217,7 @@ public void testMax() {
assertTrue(Double.isNaN(Doubles.max(VALUES)));
}

@GwtIncompatible
public void testMin_noArgs() {
try {
Doubles.min();
Expand Down
Expand Up @@ -186,6 +186,7 @@ public void testLastIndexOf() {
assertEquals(-1, Floats.lastIndexOf(new float[] {NaN, 5f}, NaN));
}

@GwtIncompatible
public void testMax_noArgs() {
try {
Floats.max();
Expand All @@ -207,6 +208,7 @@ public void testMax() {
assertTrue(Float.isNaN(Floats.max(VALUES)));
}

@GwtIncompatible
public void testMin_noArgs() {
try {
Floats.min();
Expand Down
Expand Up @@ -155,6 +155,7 @@ public void testLastIndexOf() {
assertEquals(3, Ints.lastIndexOf(new int[] {(int) 2, (int) 3, (int) 2, (int) 3}, (int) 3));
}

@GwtIncompatible
public void testMax_noArgs() {
try {
Ints.max();
Expand All @@ -169,6 +170,7 @@ public void testMax() {
assertEquals((int) 9, Ints.max((int) 8, (int) 6, (int) 7, (int) 5, (int) 3, (int) 0, (int) 9));
}

@GwtIncompatible
public void testMin_noArgs() {
try {
Ints.min();
Expand Down
Expand Up @@ -175,6 +175,7 @@ public void testLastIndexOf() {
3, Shorts.lastIndexOf(new short[] {(short) 2, (short) 3, (short) 2, (short) 3}, (short) 3));
}

@GwtIncompatible
public void testMax_noArgs() {
try {
Shorts.max();
Expand All @@ -191,6 +192,7 @@ public void testMax() {
Shorts.max((short) 8, (short) 6, (short) 7, (short) 5, (short) 3, (short) 0, (short) 9));
}

@GwtIncompatible
public void testMin_noArgs() {
try {
Shorts.min();
Expand Down
6 changes: 5 additions & 1 deletion android/guava/src/com/google/common/primitives/Doubles.java
Expand Up @@ -46,7 +46,7 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
public final class Doubles {
public final class Doubles extends DoublesMethodsForWeb {
private Doubles() {}

/**
Expand Down Expand Up @@ -207,6 +207,8 @@ private static int lastIndexOf(double[] array, double target, int start, int end
* the array
* @throws IllegalArgumentException if {@code array} is empty
*/
@GwtIncompatible(
"Available in GWT! Annotation is to avoid conflict with GWT specialization of base class.")
public static double min(double... array) {
checkArgument(array.length > 0);
double min = array[0];
Expand All @@ -225,6 +227,8 @@ public static double min(double... array) {
* in the array
* @throws IllegalArgumentException if {@code array} is empty
*/
@GwtIncompatible(
"Available in GWT! Annotation is to avoid conflict with GWT specialization of base class.")
public static double max(double... array) {
checkArgument(array.length > 0);
double max = array[0];
Expand Down
@@ -0,0 +1,24 @@
/*
* Copyright (C) 2020 The Guava Authors
*
* 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 com.google.common.primitives;

import com.google.common.annotations.GwtCompatible;

/**
* Holder for web specializations of methods of {@code Doubles}. Intended to be empty for regular
* version.
*/
@GwtCompatible(emulated = true)
abstract class DoublesMethodsForWeb {}
6 changes: 5 additions & 1 deletion android/guava/src/com/google/common/primitives/Floats.java
Expand Up @@ -46,7 +46,7 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
public final class Floats {
public final class Floats extends FloatsMethodsForWeb {
private Floats() {}

/**
Expand Down Expand Up @@ -204,6 +204,8 @@ private static int lastIndexOf(float[] array, float target, int start, int end)
* the array
* @throws IllegalArgumentException if {@code array} is empty
*/
@GwtIncompatible(
"Available in GWT! Annotation is to avoid conflict with GWT specialization of base class.")
public static float min(float... array) {
checkArgument(array.length > 0);
float min = array[0];
Expand All @@ -222,6 +224,8 @@ public static float min(float... array) {
* in the array
* @throws IllegalArgumentException if {@code array} is empty
*/
@GwtIncompatible(
"Available in GWT! Annotation is to avoid conflict with GWT specialization of base class.")
public static float max(float... array) {
checkArgument(array.length > 0);
float max = array[0];
Expand Down
@@ -0,0 +1,24 @@
/*
* Copyright (C) 2020 The Guava Authors
*
* 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 com.google.common.primitives;

import com.google.common.annotations.GwtCompatible;

/**
* Holder for web specializations of methods of {@code Floats}. Intended to be empty for regular
* version.
*/
@GwtCompatible(emulated = true)
abstract class FloatsMethodsForWeb {}
9 changes: 7 additions & 2 deletions android/guava/src/com/google/common/primitives/Ints.java
Expand Up @@ -21,6 +21,7 @@

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Converter;
import java.io.Serializable;
import java.util.AbstractList;
Expand All @@ -42,8 +43,8 @@
* @author Kevin Bourrillion
* @since 1.0
*/
@GwtCompatible
public final class Ints {
@GwtCompatible(emulated = true)
public final class Ints extends IntsMethodsForWeb {
private Ints() {}

/**
Expand Down Expand Up @@ -218,6 +219,8 @@ private static int lastIndexOf(int[] array, int target, int start, int end) {
* the array
* @throws IllegalArgumentException if {@code array} is empty
*/
@GwtIncompatible(
"Available in GWT! Annotation is to avoid conflict with GWT specialization of base class.")
public static int min(int... array) {
checkArgument(array.length > 0);
int min = array[0];
Expand All @@ -237,6 +240,8 @@ public static int min(int... array) {
* in the array
* @throws IllegalArgumentException if {@code array} is empty
*/
@GwtIncompatible(
"Available in GWT! Annotation is to avoid conflict with GWT specialization of base class.")
public static int max(int... array) {
checkArgument(array.length > 0);
int max = array[0];
Expand Down
@@ -0,0 +1,24 @@
/*
* Copyright (C) 2020 The Guava Authors
*
* 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 com.google.common.primitives;

import com.google.common.annotations.GwtCompatible;

/**
* Holder for web specializations of methods of {@code Ints}. Intended to be empty for regular
* version.
*/
@GwtCompatible(emulated = true)
abstract class IntsMethodsForWeb {}
6 changes: 5 additions & 1 deletion android/guava/src/com/google/common/primitives/Shorts.java
Expand Up @@ -44,7 +44,7 @@
* @since 1.0
*/
@GwtCompatible(emulated = true)
public final class Shorts {
public final class Shorts extends ShortsMethodsForWeb {
private Shorts() {}

/**
Expand Down Expand Up @@ -218,6 +218,8 @@ private static int lastIndexOf(short[] array, short target, int start, int end)
* the array
* @throws IllegalArgumentException if {@code array} is empty
*/
@GwtIncompatible(
"Available in GWT! Annotation is to avoid conflict with GWT specialization of base class.")
public static short min(short... array) {
checkArgument(array.length > 0);
short min = array[0];
Expand All @@ -237,6 +239,8 @@ public static short min(short... array) {
* in the array
* @throws IllegalArgumentException if {@code array} is empty
*/
@GwtIncompatible(
"Available in GWT! Annotation is to avoid conflict with GWT specialization of base class.")
public static short max(short... array) {
checkArgument(array.length > 0);
short max = array[0];
Expand Down
@@ -0,0 +1,24 @@
/*
* Copyright (C) 2020 The Guava Authors
*
* 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 com.google.common.primitives;

import com.google.common.annotations.GwtCompatible;

/**
* Holder for web specializations of methods of {@code Shorts}. Intended to be empty for regular
* version.
*/
@GwtCompatible(emulated = true)
abstract class ShortsMethodsForWeb {}
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2020 The Guava Authors
*
* 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 com.google.common.primitives;

import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsPackage;

/** Web specializations for {@link Doubles} methods. */
abstract class DoublesMethodsForWeb {

@JsMethod(name = "Math.min", namespace = JsPackage.GLOBAL)
public static native double min(double... array);

@JsMethod(name = "Math.max", namespace = JsPackage.GLOBAL)
public static native double max(double... array);
}
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2020 The Guava Authors
*
* 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 com.google.common.primitives;

import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsPackage;

/** Web specializations for {@link Floats} methods. */
abstract class FloatsMethodsForWeb {

@JsMethod(name = "Math.min", namespace = JsPackage.GLOBAL)
public static native float min(float... array);

@JsMethod(name = "Math.max", namespace = JsPackage.GLOBAL)
public static native float max(float... array);
}
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2020 The Guava Authors
*
* 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 com.google.common.primitives;

import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsPackage;

/** Web specializations for {@link Ints} methods. */
abstract class IntsMethodsForWeb {

@JsMethod(name = "Math.min", namespace = JsPackage.GLOBAL)
public static native int min(int... array);

@JsMethod(name = "Math.max", namespace = JsPackage.GLOBAL)
public static native int max(int... array);
}
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2020 The Guava Authors
*
* 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 com.google.common.primitives;

import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsPackage;

/** Web specializations for {@link Shorts} methods. */
abstract class ShortsMethodsForWeb {

@JsMethod(name = "Math.min", namespace = JsPackage.GLOBAL)
public static native short min(short... array);

@JsMethod(name = "Math.max", namespace = JsPackage.GLOBAL)
public static native short max(short... array);
}

0 comments on commit c34f584

Please sign in to comment.