Skip to content

Commit

Permalink
fix functional interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Aug 6, 2024
1 parent 84e740e commit 3eb32bd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xyz.wagyourtail.jvmdg.j11.impl.http;

import xyz.wagyourtail.jvmdg.j11.stub.java_net_http.J_N_H_HttpClient;
import xyz.wagyourtail.jvmdg.j11.stub.java_net_http.J_N_H_HttpHeaders;
import xyz.wagyourtail.jvmdg.j11.stub.java_net_http.J_N_H_HttpRequest;

import java.net.URI;
Expand Down Expand Up @@ -59,4 +60,9 @@ public URI uri() {
public Optional<J_N_H_HttpClient.Version> version() {
return Optional.ofNullable(version);
}

@Override
public J_N_H_HttpHeaders headers() {
return new J_N_H_HttpHeaders(headers);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public static Builder newBuilder() {
return new HttpRequestBuilderImpl();
}

public static Builder newBuilder(URI uri) {
return new HttpRequestBuilderImpl().uri(uri);
}

public abstract Optional<BodyPublisher> bodyPublisher();

public abstract String method();
Expand All @@ -37,7 +41,8 @@ public static Builder newBuilder() {
public abstract URI uri();

public abstract Optional<J_N_H_HttpClient.Version> version();
// public abstract HttpHeaders headers();

public abstract J_N_H_HttpHeaders headers();

public final boolean equals(Object obj) {
if (!(obj instanceof J_N_H_HttpRequest)) {
Expand All @@ -47,14 +52,14 @@ public final boolean equals(Object obj) {
if (!that.method().equals(this.method())) {
return false;
}
if (!that.headers().equals(this.headers())) {
return false;
}
return that.uri().equals(this.uri());
// if (!that.headers().equals(this.headers())) {
// return false;
// }
}

public final int hashCode() {
return method().hashCode() + uri().hashCode(); // + headers().hashCode();
return Objects.hash(method().hashCode(), uri().hashCode(), headers().hashCode());
}

@Adapter("Ljava/net/http/HttpRequest$BodyPublisher;")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import xyz.wagyourtail.jvmdg.exc.MissingStubError;
import xyz.wagyourtail.jvmdg.j11.stub.java_base.J_L_String;
import xyz.wagyourtail.jvmdg.j11.impl.CharReader;
import xyz.wagyourtail.jvmdg.util.Consumer;
import xyz.wagyourtail.jvmdg.util.Function;
import xyz.wagyourtail.jvmdg.version.Adapter;

import javax.net.ssl.SSLSession;
Expand All @@ -31,6 +29,8 @@
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Flow;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Stream;

@Adapter("Ljava/net/http/HttpResponse;")
Expand Down

0 comments on commit 3eb32bd

Please sign in to comment.