From 2bcc832adeff81c48991274f4c7fe4f9b4cc1599 Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Tue, 19 Jan 2010 12:47:11 +0000 Subject: [PATCH] removed dependence on Google Guice and Google Collections libraries --- wsdef/pom.xml | 8 ----- .../webservice/definition/CallPathMap.java | 5 ++- .../gson/webservice/definition/HeaderMap.java | 3 -- .../webservice/definition/HeaderMapSpec.java | 5 ++- .../gson/webservice/definition/ParamMap.java | 21 ++++++++++--- .../webservice/definition/Preconditions.java | 31 +++++++++++++++++++ .../webservice/definition/RequestBody.java | 3 -- .../definition/RequestBodySpec.java | 5 ++- .../webservice/definition/RequestSpec.java | 2 -- .../webservice/definition/ResponseBody.java | 3 -- .../definition/ResponseBodySpec.java | 5 ++- .../webservice/definition/ResponseSpec.java | 2 -- .../definition/WebServiceCallSpec.java | 2 -- 13 files changed, 56 insertions(+), 39 deletions(-) create mode 100644 wsdef/src/main/java/com/google/gson/webservice/definition/Preconditions.java diff --git a/wsdef/pom.xml b/wsdef/pom.xml index 8f43abdc..7515ac7a 100644 --- a/wsdef/pom.xml +++ b/wsdef/pom.xml @@ -64,14 +64,6 @@ compile - - - com.google.inject - guice - 2.0 - compile - - junit junit diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/CallPathMap.java b/wsdef/src/main/java/com/google/gson/webservice/definition/CallPathMap.java index 3ddf0524..c083f92a 100644 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/CallPathMap.java +++ b/wsdef/src/main/java/com/google/gson/webservice/definition/CallPathMap.java @@ -15,10 +15,9 @@ */ package com.google.gson.webservice.definition; +import java.util.HashMap; import java.util.Map; -import com.google.common.collect.Maps; - /** * A generic Map of calls with relative path where the call is available as the key. * @@ -29,7 +28,7 @@ import com.google.common.collect.Maps; public final class CallPathMap { public static class Builder { - private final Map contents = Maps.newHashMap(); + private final Map contents = new HashMap(); private final T nullValue; public Builder(T nullValue) { diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/HeaderMap.java b/wsdef/src/main/java/com/google/gson/webservice/definition/HeaderMap.java index 948895c8..4ce3f048 100644 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/HeaderMap.java +++ b/wsdef/src/main/java/com/google/gson/webservice/definition/HeaderMap.java @@ -18,8 +18,6 @@ package com.google.gson.webservice.definition; import java.lang.reflect.Type; import java.util.Map; -import com.google.inject.Inject; - /** * Map of request or response header objects. There is a {@link HeaderMapSpec} associated with the * map as well and only those headers are allowed that are consistent with the specification. @@ -29,7 +27,6 @@ import com.google.inject.Inject; public final class HeaderMap extends ParamMap { public static class Builder extends ParamMap.Builder { - @Inject public Builder(HeaderMapSpec spec) { super(spec); } diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/HeaderMapSpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/HeaderMapSpec.java index 91bc6e7e..154c9a6d 100644 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/HeaderMapSpec.java +++ b/wsdef/src/main/java/com/google/gson/webservice/definition/HeaderMapSpec.java @@ -16,11 +16,10 @@ package com.google.gson.webservice.definition; import java.lang.reflect.Type; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; -import com.google.common.collect.Maps; - /** * Specification of a header map for {@link HeaderMap}. * @@ -29,7 +28,7 @@ import com.google.common.collect.Maps; public final class HeaderMapSpec implements ParamMapSpec { public static class Builder { - private final Map map = Maps.newLinkedHashMap(); + private final Map map = new LinkedHashMap(); public void put(String headerName, Type headerType) { map.put(headerName, headerType); diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/ParamMap.java b/wsdef/src/main/java/com/google/gson/webservice/definition/ParamMap.java index 5e7b141c..7f66cbf3 100644 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/ParamMap.java +++ b/wsdef/src/main/java/com/google/gson/webservice/definition/ParamMap.java @@ -1,16 +1,29 @@ +/* + * Copyright (C) 2010 Google Inc. + * + * 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.gson.webservice.definition; import java.lang.reflect.Type; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; -import com.google.common.base.Preconditions; -import com.google.common.collect.Maps; - class ParamMap { public static class Builder { - protected final Map contents = Maps.newLinkedHashMap(); + protected final Map contents = new LinkedHashMap(); protected final T spec; public Builder(T spec) { diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/Preconditions.java b/wsdef/src/main/java/com/google/gson/webservice/definition/Preconditions.java new file mode 100644 index 00000000..5fd1a506 --- /dev/null +++ b/wsdef/src/main/java/com/google/gson/webservice/definition/Preconditions.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2010 Google Inc. + * + * 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.gson.webservice.definition; + +final class Preconditions { + + public static void checkArgument(boolean condition) { + if (!condition) { + throw new IllegalArgumentException(); + } + } + + public static void checkNotNull(Object obj) { + if (obj == null) { + throw new IllegalArgumentException(); + } + } +} diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/RequestBody.java b/wsdef/src/main/java/com/google/gson/webservice/definition/RequestBody.java index a0939dde..beaf1668 100644 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/RequestBody.java +++ b/wsdef/src/main/java/com/google/gson/webservice/definition/RequestBody.java @@ -18,8 +18,6 @@ package com.google.gson.webservice.definition; import java.lang.reflect.Type; import java.util.Map; -import com.google.inject.Inject; - /** * Definition of the request body of a {@link WebServiceCall}. The request body is what is sent out * in the output stream of the request (for example, with @@ -32,7 +30,6 @@ public final class RequestBody extends ContentBody { public static class Builder extends ParamMap.Builder { - @Inject public Builder(RequestBodySpec spec) { super(spec); } diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/RequestBodySpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/RequestBodySpec.java index 78f5232f..19c77f1d 100644 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/RequestBodySpec.java +++ b/wsdef/src/main/java/com/google/gson/webservice/definition/RequestBodySpec.java @@ -16,10 +16,9 @@ package com.google.gson.webservice.definition; import java.lang.reflect.Type; +import java.util.LinkedHashMap; import java.util.Map; -import com.google.common.collect.Maps; - /** * Specification of a {@link RequestBody}. * @@ -28,7 +27,7 @@ import com.google.common.collect.Maps; public final class RequestBodySpec extends ContentBodySpec { public static class Builder { - private final Map paramsSpec = Maps.newLinkedHashMap(); + private final Map paramsSpec = new LinkedHashMap(); public Builder add(String paramName, Type type) { paramsSpec.put(paramName, type); return this; diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/RequestSpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/RequestSpec.java index 01cb4463..8c49b892 100644 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/RequestSpec.java +++ b/wsdef/src/main/java/com/google/gson/webservice/definition/RequestSpec.java @@ -15,8 +15,6 @@ */ package com.google.gson.webservice.definition; -import com.google.common.base.Preconditions; - /** * Specification for a {@link WebServiceRequest}. * diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/ResponseBody.java b/wsdef/src/main/java/com/google/gson/webservice/definition/ResponseBody.java index 29fe5c0a..bd9a0e2d 100644 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/ResponseBody.java +++ b/wsdef/src/main/java/com/google/gson/webservice/definition/ResponseBody.java @@ -18,8 +18,6 @@ package com.google.gson.webservice.definition; import java.lang.reflect.Type; import java.util.Map; -import com.google.inject.Inject; - /** * body of the response. This is written out as JSON to be sent out to the client. * @@ -29,7 +27,6 @@ public final class ResponseBody extends ContentBody { public static class Builder extends ParamMap.Builder { - @Inject public Builder(ResponseBodySpec spec) { super(spec); } diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/ResponseBodySpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/ResponseBodySpec.java index 6b801d69..a8863e5f 100644 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/ResponseBodySpec.java +++ b/wsdef/src/main/java/com/google/gson/webservice/definition/ResponseBodySpec.java @@ -16,10 +16,9 @@ package com.google.gson.webservice.definition; import java.lang.reflect.Type; +import java.util.LinkedHashMap; import java.util.Map; -import com.google.common.collect.Maps; - /** * Specification of a {@link ResponseBody}. * @@ -28,7 +27,7 @@ import com.google.common.collect.Maps; public final class ResponseBodySpec extends ContentBodySpec { public static class Builder { - private final Map paramsSpec = Maps.newLinkedHashMap(); + private final Map paramsSpec = new LinkedHashMap(); public Builder add(String paramName, Type type) { paramsSpec.put(paramName, type); return this; diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/ResponseSpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/ResponseSpec.java index 3e0e21b7..b7373b9c 100644 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/ResponseSpec.java +++ b/wsdef/src/main/java/com/google/gson/webservice/definition/ResponseSpec.java @@ -15,8 +15,6 @@ */ package com.google.gson.webservice.definition; -import com.google.common.base.Preconditions; - /** * Specification for a {@link WebServiceResponse}. * diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/WebServiceCallSpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/WebServiceCallSpec.java index 76f2bc25..f7e29498 100644 --- a/wsdef/src/main/java/com/google/gson/webservice/definition/WebServiceCallSpec.java +++ b/wsdef/src/main/java/com/google/gson/webservice/definition/WebServiceCallSpec.java @@ -20,8 +20,6 @@ import java.util.Arrays; import java.util.LinkedHashSet; import java.util.Set; -import com.google.common.base.Preconditions; - /** * Specification for a Json web service call. The call includes the relative path where the call