-
Notifications
You must be signed in to change notification settings - Fork 16
Remove guava dependency #265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,12 @@ plugins { | |
| alias(libs.plugins.osdetector) | ||
| } | ||
|
|
||
| // Conformance tests aren't bound by lowest common library version. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No reason the tests themselves couldn't target a later version of Java. |
||
| java { | ||
| sourceCompatibility = JavaVersion.VERSION_21 | ||
| targetCompatibility = JavaVersion.VERSION_21 | ||
| } | ||
|
|
||
| val buf: Configuration by configurations.creating | ||
|
|
||
| tasks.register("configureBuf") { | ||
|
|
@@ -116,7 +122,7 @@ configure<SpotlessExtension> { | |
|
|
||
| dependencies { | ||
| implementation(project(":")) | ||
| implementation(libs.guava) | ||
| implementation(libs.errorprone.annotations) | ||
| implementation(libs.protobuf.java) | ||
|
|
||
| implementation(libs.assertj) | ||
|
|
@@ -127,5 +133,5 @@ dependencies { | |
| testImplementation("org.junit.jupiter:junit-jupiter") | ||
| testRuntimeOnly("org.junit.platform:junit-platform-launcher") | ||
|
|
||
| errorprone(libs.errorprone) | ||
| errorprone(libs.errorprone.core) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,6 @@ | |
|
|
||
| package build.buf.protovalidate; | ||
|
|
||
| import com.google.common.primitives.Bytes; | ||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
| import java.util.regex.Pattern; | ||
|
|
@@ -205,12 +204,34 @@ private static Overload celContains() { | |
| if (lhsType == TypeEnum.Bytes) { | ||
| byte[] receiver = (byte[]) lhs.value(); | ||
| byte[] param = (byte[]) rhs.value(); | ||
| return Types.boolOf(Bytes.indexOf(receiver, param) != -1); | ||
| return Types.boolOf(bytesContains(receiver, param)); | ||
| } | ||
| return Err.noSuchOverload(lhs, OVERLOAD_CONTAINS, rhs); | ||
| }); | ||
| } | ||
|
|
||
| static boolean bytesContains(byte[] arr, byte[] subArr) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the main thing we got from Guava. Immutable types are great but for our usage we didn't require them anywhere. We could always (when upgrading to Java 11) switch to similar types on the List/Map methods. |
||
| if (subArr.length == 0) { | ||
| return true; | ||
| } | ||
| if (subArr.length > arr.length) { | ||
| return false; | ||
| } | ||
| for (int i = 0; i < arr.length - subArr.length + 1; i++) { | ||
| boolean found = true; | ||
| for (int j = 0; j < subArr.length; j++) { | ||
| if (arr[i + j] != subArr[j]) { | ||
| found = false; | ||
| break; | ||
| } | ||
| } | ||
| if (found) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| /** | ||
| * Creates a custom binary function overload for the "isHostname" operation. | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jspecify appears to be the newer long term replacement for javax annotations, so switched to it. Previously we pulled these annotations in through Guava's jsr305 dependency.