removed dependence on Google Guice and Google Collections libraries

This commit is contained in:
Inderjeet Singh 2010-01-19 12:47:11 +00:00
parent bf2a0e4e0b
commit 2bcc832ade
13 changed files with 56 additions and 39 deletions

View File

@ -64,14 +64,6 @@
<scope>compile</scope>
</dependency>
<!-- Guice: Dependency injection -->
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

View File

@ -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<T> {
public static class Builder<T> {
private final Map<CallPath, T> contents = Maps.newHashMap();
private final Map<CallPath, T> contents = new HashMap<CallPath, T>();
private final T nullValue;
public Builder(T nullValue) {

View File

@ -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<HeaderMapSpec> {
@Inject
public Builder(HeaderMapSpec spec) {
super(spec);
}

View File

@ -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<String, Type> map = Maps.newLinkedHashMap();
private final Map<String, Type> map = new LinkedHashMap<String, Type>();
public void put(String headerName, Type headerType) {
map.put(headerName, headerType);

View File

@ -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<T extends ParamMapSpec> {
protected final Map<String, Object> contents = Maps.newLinkedHashMap();
protected final Map<String, Object> contents = new LinkedHashMap<String, Object>();
protected final T spec;
public Builder(T spec) {

View File

@ -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();
}
}
}

View File

@ -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<RequestBodySpec> {
@Inject
public Builder(RequestBodySpec spec) {
super(spec);
}

View File

@ -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<String, Type> paramsSpec = Maps.newLinkedHashMap();
private final Map<String, Type> paramsSpec = new LinkedHashMap<String, Type>();
public Builder add(String paramName, Type type) {
paramsSpec.put(paramName, type);
return this;

View File

@ -15,8 +15,6 @@
*/
package com.google.gson.webservice.definition;
import com.google.common.base.Preconditions;
/**
* Specification for a {@link WebServiceRequest}.
*

View File

@ -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<ResponseBodySpec> {
@Inject
public Builder(ResponseBodySpec spec) {
super(spec);
}

View File

@ -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<String, Type> paramsSpec = Maps.newLinkedHashMap();
private final Map<String, Type> paramsSpec = new LinkedHashMap<String, Type>();
public Builder add(String paramName, Type type) {
paramsSpec.put(paramName, type);
return this;

View File

@ -15,8 +15,6 @@
*/
package com.google.gson.webservice.definition;
import com.google.common.base.Preconditions;
/**
* Specification for a {@link WebServiceResponse}.
*

View File

@ -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