Skip to content

Commit cb4286f

Browse files
---
yaml --- r: 8007 b: refs/heads/tswast-patch-1 c: ff8376e h: refs/heads/master i: 8005: 30a6290 8003: a19a98a 7999: df4b61b
1 parent f51a602 commit cb4286f

2 files changed

Lines changed: 49 additions & 6 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: 2fd93d9b2614185934c42741532bff5777f9d93d
60+
refs/heads/tswast-patch-1: ff8376e7f9eae2b379fc1682f307db4172c0d375
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/google-cloud-logging/src/main/java/com/google/cloud/logging/HttpRequest.java

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package com.google.cloud.logging;
1818

19+
import com.google.api.core.ApiFunction;
20+
import com.google.cloud.StringEnumType;
21+
import com.google.cloud.StringEnumValue;
1922
import com.google.common.base.MoreObjects;
2023

2124
import java.io.Serializable;
@@ -50,11 +53,51 @@ public final class HttpRequest implements Serializable {
5053
/**
5154
* The HTTP request method.
5255
*/
53-
public enum RequestMethod {
54-
GET,
55-
HEAD,
56-
PUT,
57-
POST
56+
public static final class RequestMethod extends StringEnumValue {
57+
private static final long serialVersionUID = 2403969065179486996L;
58+
59+
private RequestMethod(String constant) {
60+
super(constant);
61+
}
62+
63+
private static final ApiFunction<String, RequestMethod> CONSTRUCTOR =
64+
new ApiFunction<String, RequestMethod>() {
65+
@Override
66+
public RequestMethod apply(String constant) {
67+
return new RequestMethod(constant);
68+
}
69+
};
70+
71+
private static final StringEnumType<RequestMethod> type = new StringEnumType(
72+
RequestMethod.class,
73+
CONSTRUCTOR);
74+
75+
public static final RequestMethod GET = type.createAndRegister("GET");
76+
public static final RequestMethod HEAD = type.createAndRegister("HEAD");
77+
public static final RequestMethod PUT = type.createAndRegister("PUT");
78+
public static final RequestMethod POST = type.createAndRegister("POST");
79+
80+
/**
81+
* Get the RequestMethod for the given String constant, and throw an exception if the constant is
82+
* not recognized.
83+
*/
84+
public static RequestMethod valueOfStrict(String constant) {
85+
return type.valueOfStrict(constant);
86+
}
87+
88+
/**
89+
* Get the RequestMethod for the given String constant, and allow unrecognized values.
90+
*/
91+
public static RequestMethod valueOf(String constant) {
92+
return type.valueOf(constant);
93+
}
94+
95+
/**
96+
* Return the known values for RequestMethod.
97+
*/
98+
public static RequestMethod[] values() {
99+
return type.values();
100+
}
58101
}
59102

60103
/**

0 commit comments

Comments
 (0)