> entrySet();
-
- public int size();
-
-}
\ No newline at end of file
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/TypeUtils.java b/wsdef/src/main/java/com/google/gson/webservice/definition/TypeUtils.java
deleted file mode 100644
index 108a6d4a..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/TypeUtils.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-// Copied from com.google.gson.TypeUtils
-package com.google.gson.webservice.definition;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-
-/**
- * Utility class containing some methods for obtaining information on types.
- *
- * @author Inderjeet Singh
- * @author Joel Leitch
- */
-final class TypeUtils {
-
- /**
- * Returns the actual type matching up with the first type variable.
- * So, for a {@code typeInfo} instance defined as:
- *
- * class Foo {
- * }
- * Type fooType = new TypeToken>() {}.getType();
- *
- * TypeUtils.getActualTypeForFirstTypeVariable(fooType)
will return Integer.class.
- */
- static Type getActualTypeForFirstTypeVariable(Type type) {
- if (type instanceof Class) {
- return Object.class;
- } else if (type instanceof ParameterizedType) {
- return ((ParameterizedType)type).getActualTypeArguments()[0];
- } else if (type instanceof GenericArrayType) {
- return getActualTypeForFirstTypeVariable(((GenericArrayType)type).getGenericComponentType());
- } else {
- throw new IllegalArgumentException("Type \'" + type + "\' is not a Class, "
- + "ParameterizedType, or GenericArrayType. Can't extract class.");
- }
- }
-
- static boolean isArray(Type type) {
- if (type instanceof Class) {
- return ((Class>)type).isArray();
- } else if (type instanceof GenericArrayType) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * This method returns the actual raw class associated with the specified type.
- */
- static Class> toRawClass(Type type) {
- if (type instanceof Class) {
- return (Class>) type;
- } else if (type instanceof ParameterizedType) {
- ParameterizedType actualType = (ParameterizedType)type;
- return toRawClass(actualType.getRawType());
- } else if (type instanceof GenericArrayType) {
- GenericArrayType actualType = (GenericArrayType) type;
- Class> rawClass = toRawClass(actualType.getGenericComponentType());
- return wrapWithArray(rawClass);
- } else {
- throw new IllegalArgumentException("Type \'" + type + "\' is not a Class, "
- + "ParameterizedType, or GenericArrayType. Can't extract class.");
- }
- }
-
- static Class> wrapWithArray(Class> rawClass) {
- return Array.newInstance(rawClass, 0).getClass();
- }
-
- private TypeUtils() {
- // Class with just some static utility methods, should not be instantiated
- }
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/TypedKey.java b/wsdef/src/main/java/com/google/gson/webservice/definition/TypedKey.java
deleted file mode 100644
index fd46576f..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/TypedKey.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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 com.google.gson.webservice.definition.internal.utils.Preconditions;
-
-/**
- * A typed key for use in a {@link ParamMap} or a {@link ParamMapSpec}.
- *
- * @author inder
- *
- * @param Intended type of the content for the key
- */
-public class TypedKey {
- private final String name;
- private final Class classOfT;
-
- public TypedKey(String name, Class classOfT) {
- Preconditions.checkNotNull(name);
- Preconditions.checkNotNull(classOfT);
-
- this.name = name;
- this.classOfT = classOfT;
- }
-
- public String getName() {
- return name;
- }
-
- public Class getClassOfT() {
- return classOfT;
- }
-
-
- @Override
- public int hashCode() {
- return name.hashCode() + classOfT.getCanonicalName().hashCode() >> 1;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- TypedKey> other = (TypedKey>) obj;
- return name.equals(other.name) && classOfT.equals(other.classOfT);
- }
-
- @Override
- public String toString() {
- return String.format("{name:%s, classOfT:%s}", name, classOfT);
- }
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/Util.java b/wsdef/src/main/java/com/google/gson/webservice/definition/Util.java
deleted file mode 100644
index 3e989eae..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/Util.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2008 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.Map;
-
-final class Util {
- private Util() { }
-
- public static boolean isAssignableFrom(Type typeOfValue, Type expectedType) {
- return typeOfValue.equals(expectedType);
- }
-
- public static String toStringMapKeys(Map map) {
- StringBuilder sb = new StringBuilder("[");
- boolean first = true;
- for (Map.Entry entry : map.entrySet()) {
- if (first) {
- first = false;
- } else {
- sb.append(",");
- }
- sb.append(entry.getKey());
- }
- sb.append("]");
- return sb.toString();
- }
-
- public static String toStringMapOfTypes(Map map) {
- StringBuilder sb = new StringBuilder("[");
- boolean first = true;
- for (Map.Entry entry : map.entrySet()) {
- if (first) {
- first = false;
- } else {
- sb.append(",");
- }
- sb.append(entry.getKey()).append(":");
- Class> clazz = (Class>) entry.getValue();
- sb.append(clazz.getSimpleName());
- }
- sb.append("]");
- return sb.toString();
- }
-
- public static String toStringMap(Map map) {
- StringBuilder sb = new StringBuilder("[");
- boolean first = true;
- for (Map.Entry entry : map.entrySet()) {
- if (first) {
- first = false;
- } else {
- sb.append(",");
- }
- sb.append(entry.getKey()).append(":").append(entry.getValue());
- }
- sb.append("]");
- return sb.toString();
- }
-
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/WebServiceSystemException.java b/wsdef/src/main/java/com/google/gson/webservice/definition/WebServiceSystemException.java
deleted file mode 100644
index e183757d..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/WebServiceSystemException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2008 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;
-
-/**
- * Base class for all exceptions thrown by the Web service to indicate a system error condition.
- * This should never be thrown to indicate bad user input.
- *
- * @author inder
- */
-public class WebServiceSystemException extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
-
- public WebServiceSystemException(Exception cause) {
- super(cause);
- }
-
- public WebServiceSystemException(String msg, Exception cause) {
- super(msg, cause);
- }
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/internal/utils/Pair.java b/wsdef/src/main/java/com/google/gson/webservice/definition/internal/utils/Pair.java
deleted file mode 100644
index d3454d8d..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/internal/utils/Pair.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.internal.utils;
-
-/**
- * A simple object that holds onto a pair of object references, first and second.
- *
- * @author Inderjeet Singh
- *
- * @param
- * @param
- */
-public final class Pair {
-
- public final FIRST first;
- public final SECOND second;
-
- public Pair(FIRST first, SECOND second) {
- this.first = first;
- this.second = second;
- }
-
- public static Pair create(F first, S second) {
- return new Pair(first, second);
- }
-
- @Override
- public int hashCode() {
- return 17 * ((first != null) ? first.hashCode() : 0)
- + 17 * ((second != null) ? second.hashCode() : 0);
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof Pair, ?>)) {
- return false;
- }
-
- Pair, ?> that = (Pair, ?>) o;
- return equal(this.first, that.first) && equal(this.second, that.second);
- }
-
- private static boolean equal(Object a, Object b) {
- return a == b || (a != null && a.equals(b));
- }
-
- @Override
- public String toString() {
- return String.format("{%s,%s}", first, second);
- }
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/internal/utils/Preconditions.java b/wsdef/src/main/java/com/google/gson/webservice/definition/internal/utils/Preconditions.java
deleted file mode 100644
index 547f79bd..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/internal/utils/Preconditions.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.internal.utils;
-
-public final class Preconditions {
-
- public static void checkArgument(boolean condition) {
- if (!condition) {
- throw new IllegalArgumentException();
- }
- }
-
- public static void checkArgument(boolean condition, String msg, Object... msgArgs) {
- if (!condition) {
- throw new IllegalArgumentException(String.format(msg, msgArgs));
- }
- }
-
- public static void checkNotNull(Object obj) {
- if (obj == null) {
- throw new IllegalArgumentException();
- }
- }
-
- public static void checkNotNull(Object obj, String msg, Object... msgArgs) {
- if (obj == null) {
- throw new IllegalArgumentException(String.format(msg, msgArgs));
- }
- }
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBody.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBody.java
deleted file mode 100644
index 44a0c82f..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBody.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2008 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.procedural;
-
-import com.google.gson.webservice.definition.ContentBody;
-import com.google.gson.webservice.definition.ParamMap;
-import com.google.gson.webservice.definition.TypedKey;
-import com.google.gson.webservice.definition.ParamMap.Builder;
-
-import java.lang.reflect.Type;
-import java.util.Map;
-
-/**
- * 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
- * {@link java.net.HttpURLConnection#getOutputStream()}) , and is read by the
- * javax.servlet.http.HttpServletRequest#getInputStream().
- * This class omits the default constructor for use by Gson. Instead the user must use
- * {@link com.google.gson.webservice.definition.procedural.RequestBodyGsonConverter}
- *
- * @author inder
- */
-public final class RequestBody extends ContentBody {
-
- public static class Builder extends ParamMap.Builder {
-
- public Builder(RequestBodySpec spec) {
- super(spec);
- }
-
- @Override
- public Builder put(String paramName, Object content) {
- return (Builder) super.put(paramName, content);
- }
-
- @Override
- public Builder put(String paramName, Object content, Type typeOfContent) {
- return (Builder) super.put(paramName, content, typeOfContent);
- }
-
- @Override
- public Builder put(TypedKey paramKey, T param) {
- return (Builder) super.put(paramKey, param);
- }
-
- public RequestBody build() {
- return new RequestBody(spec, contents);
- }
- }
-
- private RequestBody(RequestBodySpec spec, Map contents) {
- super(spec, contents);
- }
-
- @Override
- public RequestBodySpec getSpec() {
- return (RequestBodySpec) spec;
- }
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBodyGsonConverter.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBodyGsonConverter.java
deleted file mode 100644
index f817617e..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBodyGsonConverter.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2008 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.procedural;
-
-import java.lang.reflect.Type;
-import java.util.Map;
-
-import com.google.gson.InstanceCreator;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
-
-/**
- * Gson type adapter for {@link RequestBody}.
- *
- * @author inder
- */
-public class RequestBodyGsonConverter implements JsonSerializer,
- JsonDeserializer, InstanceCreator {
-
- private final RequestBodySpec spec;
-
- public RequestBodyGsonConverter(RequestBodySpec spec) {
- this.spec = spec;
- }
-
- @Override
- public JsonElement serialize(RequestBody src, Type typeOfSrc,
- JsonSerializationContext context) {
- JsonObject root = new JsonObject();
- for(Map.Entry entry : src.entrySet()) {
- String key = entry.getKey();
- Type entryType = src.getSpec().getTypeFor(key);
- JsonElement value = context.serialize(entry.getValue(), entryType);
- root.add(key, value);
- }
- return root;
- }
-
- @Override
- public RequestBody deserialize(JsonElement json, Type typeOfT,
- JsonDeserializationContext context) throws JsonParseException {
- RequestBody.Builder builder = new RequestBody.Builder(spec);
- for (Map.Entry entry : json.getAsJsonObject().entrySet()) {
- String key = entry.getKey();
- Type entryType = spec.getTypeFor(key);
- Object value = context.deserialize(entry.getValue(), entryType);
- builder.put(key, value);
- }
- return builder.build();
- }
-
- @Override
- public RequestBody createInstance(Type type) {
- return new RequestBody.Builder(spec).build();
- }
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBodySpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBodySpec.java
deleted file mode 100644
index 6f835fcc..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestBodySpec.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2008 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.procedural;
-
-
-import com.google.gson.webservice.definition.ContentBodySpec;
-
-import java.lang.reflect.Type;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Specification of a {@link RequestBody}.
- *
- * @author inder
- */
-public final class RequestBodySpec extends ContentBodySpec {
-
- public static class Builder {
- private final Map paramsSpec = new LinkedHashMap();
- public Builder add(String paramName, Type type) {
- paramsSpec.put(paramName, type);
- return this;
- }
-
- public RequestBodySpec build() {
- RequestBodySpec spec = new RequestBodySpec(paramsSpec);
- return spec;
- }
- }
-
- public RequestBodySpec(Map paramsSpec) {
- super(paramsSpec);
- }
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestSpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestSpec.java
deleted file mode 100644
index 3520cc86..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/RequestSpec.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2008 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.procedural;
-
-import com.google.gson.webservice.definition.HeaderMapSpec;
-import com.google.gson.webservice.definition.internal.utils.Preconditions;
-
-/**
- * Specification for a {@link WebServiceRequest}.
- *
- * @author inder
- */
-public final class RequestSpec {
-
- private final HeaderMapSpec headersSpec;
- private final RequestBodySpec bodySpec;
-
- public RequestSpec(HeaderMapSpec headersSpec, RequestBodySpec bodySpec) {
- Preconditions.checkNotNull(headersSpec);
- Preconditions.checkNotNull(bodySpec);
-
- this.headersSpec = headersSpec;
- this.bodySpec = bodySpec;
- }
-
- public HeaderMapSpec getHeadersSpec() {
- return headersSpec;
- }
-
- public RequestBodySpec getBodySpec() {
- return bodySpec;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("{headersSpec:");
- sb.append(headersSpec).append(",bodySpec:");
- sb.append(bodySpec).append("}");
- return sb.toString();
- }
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBody.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBody.java
deleted file mode 100644
index 5a0f4bb3..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBody.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2008 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.procedural;
-
-import com.google.gson.webservice.definition.ContentBody;
-import com.google.gson.webservice.definition.ParamMap;
-import com.google.gson.webservice.definition.TypedKey;
-
-import java.lang.reflect.Type;
-import java.util.Map;
-
-/**
- * body of the response. This is written out as JSON to be sent out to the client.
- * This class omits the default constructor for use by Gson. Instead the user must use
- * {@link com.google.gson.webservice.definition.procedural.ResponseBodyGsonConverter}
- *
- * @author inder
- */
-public final class ResponseBody extends ContentBody {
-
- public static class Builder extends ParamMap.Builder {
-
- public Builder(ResponseBodySpec spec) {
- super(spec);
- }
-
- @Override
- public Builder put(String paramName, Object content) {
- return (Builder) super.put(paramName, content);
- }
-
- @Override
- public Builder put(String paramName, Object content, Type typeOfContent) {
- return (Builder) super.put(paramName, content, typeOfContent);
- }
-
- @Override
- public Builder put(TypedKey paramKey, T param) {
- return (Builder) super.put(paramKey, param);
- }
-
- public ResponseBody build() {
- return new ResponseBody(spec, contents);
- }
- }
-
- private ResponseBody(ResponseBodySpec spec, Map contents) {
- super(spec, contents);
- }
-
- @Override
- public ResponseBodySpec getSpec() {
- return (ResponseBodySpec) spec;
- }
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBodyGsonConverter.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBodyGsonConverter.java
deleted file mode 100644
index ccdb25e1..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBodyGsonConverter.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2008 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.procedural;
-
-import java.lang.reflect.Type;
-import java.util.Map;
-
-import com.google.gson.InstanceCreator;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
-
-/**
- * Gson type adapter for {@link ResponseBody}.
- *
- * @author inder
- */
-public final class ResponseBodyGsonConverter implements JsonSerializer,
- JsonDeserializer, InstanceCreator {
-
- private final ResponseBodySpec spec;
-
- public ResponseBodyGsonConverter(ResponseBodySpec spec) {
- this.spec = spec;
- }
-
- @Override
- public JsonElement serialize(ResponseBody src, Type typeOfSrc,
- JsonSerializationContext context) {
- JsonObject root = new JsonObject();
- for(Map.Entry entry : src.entrySet()) {
- String key = entry.getKey();
- Type entryType = src.getSpec().getTypeFor(key);
- JsonElement value = context.serialize(entry.getValue(), entryType);
- root.add(key, value);
- }
- return root;
- }
-
- @Override
- public ResponseBody deserialize(JsonElement json, Type typeOfT,
- JsonDeserializationContext context) throws JsonParseException {
- ResponseBody.Builder responseBodyBuilder = new ResponseBody.Builder(spec);
- for (Map.Entry entry : json.getAsJsonObject().entrySet()) {
- String key = entry.getKey();
- Type entryType = spec.getTypeFor(key);
- Object value = context.deserialize(entry.getValue(), entryType);
- responseBodyBuilder.put(key, value, entryType);
- }
- return responseBodyBuilder.build();
- }
-
- @Override
- public ResponseBody createInstance(Type type) {
- return new ResponseBody.Builder(spec).build();
- }
-}
\ No newline at end of file
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBodySpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBodySpec.java
deleted file mode 100644
index 2b3022e2..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseBodySpec.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2008 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.procedural;
-
-import com.google.gson.webservice.definition.ContentBodySpec;
-
-import java.lang.reflect.Type;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Specification of a {@link ResponseBody}.
- *
- * @author inder
- */
-public final class ResponseBodySpec extends ContentBodySpec {
-
- public static class Builder {
- private final Map paramsSpec = new LinkedHashMap();
- public Builder add(String paramName, Type type) {
- paramsSpec.put(paramName, type);
- return this;
- }
-
- public ResponseBodySpec build() {
- ResponseBodySpec spec = new ResponseBodySpec(paramsSpec);
- return spec;
- }
- }
-
- public ResponseBodySpec(Map paramsSpec) {
- super(paramsSpec);
- }
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseSpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseSpec.java
deleted file mode 100644
index 9ecc4d43..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/ResponseSpec.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2008 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.procedural;
-
-import com.google.gson.webservice.definition.HeaderMapSpec;
-import com.google.gson.webservice.definition.internal.utils.Preconditions;
-
-/**
- * Specification for a {@link WebServiceResponse}.
- *
- * @author inder
- */
-public final class ResponseSpec {
- private final HeaderMapSpec headersSpec;
- private final ResponseBodySpec bodySpec;
-
- public ResponseSpec(HeaderMapSpec headersSpec, ResponseBodySpec bodySpec) {
- Preconditions.checkNotNull(headersSpec);
- Preconditions.checkNotNull(bodySpec);
-
- this.headersSpec = headersSpec;
- this.bodySpec = bodySpec;
- }
-
- public ResponseBodySpec getBodySpec() {
- return bodySpec;
- }
-
- public HeaderMapSpec getHeadersSpec() {
- return headersSpec;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("{headersSpec:");
- sb.append(headersSpec).append(",bodySpec:");
- sb.append(bodySpec).append("}");
- return sb.toString();
- }
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceCall.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceCall.java
deleted file mode 100644
index faa8f476..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceCall.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2008 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.procedural;
-
-
-/**
- * The data associated with a Web service call. This includes http request header parameters (form
- * and URL parameters), {@link RequestBody}, response header parameters, and {@link ResponseBody}.
- *
- * @author inder
- */
-public final class WebServiceCall {
-
- private final WebServiceCallSpec callSpec;
- private final WebServiceRequest request;
- private final WebServiceResponse response;
-
- public WebServiceCall(WebServiceCallSpec callSpec, WebServiceRequest request,
- WebServiceResponse response) {
- this.callSpec = callSpec;
- this.request = request;
- this.response = response;
- }
-
- public WebServiceCallSpec getSpec() {
- return callSpec;
- }
-
- public WebServiceRequest getRequest() {
- return request;
- }
-
- public WebServiceResponse getResponse() {
- return response;
- }
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceCallSpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceCallSpec.java
deleted file mode 100644
index 693ad74f..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceCallSpec.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2008 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.procedural;
-
-import com.google.gson.webservice.definition.CallPath;
-import com.google.gson.webservice.definition.HeaderMapSpec;
-import com.google.gson.webservice.definition.HttpMethod;
-import com.google.gson.webservice.definition.TypedKey;
-import com.google.gson.webservice.definition.internal.utils.Preconditions;
-
-import java.util.Arrays;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- * Specification for a Json web service call. The call includes the relative path where the call
- * is available, the specification of requests, and responses.
- *
- * @author inder
- */
-public final class WebServiceCallSpec {
-
- public static final WebServiceCallSpec NULL_SPEC = new Builder(new CallPath("")).build();
-
- public static class Builder {
- private final CallPath callPath;
- private final Set supportedHttpMethods = new LinkedHashSet();
- private final HeaderMapSpec.Builder reqParamsSpecBuilder = new HeaderMapSpec.Builder();
- private final RequestBodySpec.Builder reqBodySpecBuilder = new RequestBodySpec.Builder();
- private final HeaderMapSpec.Builder resParamsSpecBuilder = new HeaderMapSpec.Builder();
- private final ResponseBodySpec.Builder resBodySpecBuilder = new ResponseBodySpec.Builder();
-
- public Builder(CallPath callPath) {
- this.callPath = callPath;
- }
-
- /**
- * If this method is not invoked, then it is assumed that the WebServiceCall supports all
- * methods specified in {@link HttpMethod#values()}.
- *
- * @param httpMethods list of methods that this call supports.
- * @return self to follow the Builder pattern.
- */
- public Builder supportsHttpMethod(HttpMethod... httpMethods) {
- supportedHttpMethods.addAll(Arrays.asList(httpMethods));
- return this;
- }
-
- public Builder addRequestParam(TypedKey param) {
- reqParamsSpecBuilder.put(param.getName(), param.getClassOfT());
- return this;
- }
-
- public Builder addRequestBodyParam(TypedKey param) {
- reqBodySpecBuilder.add(param.getName(), param.getClassOfT());
- return this;
- }
-
- public Builder addResponseParam(TypedKey param) {
- resParamsSpecBuilder.put(param.getName(), param.getClassOfT());
- return this;
- }
-
- public Builder addResponseBodyParam(TypedKey param) {
- resBodySpecBuilder.add(param.getName(), param.getClassOfT());
- return this;
- }
-
- public WebServiceCallSpec build() {
- if (supportedHttpMethods.isEmpty()) {
- supportedHttpMethods.addAll(Arrays.asList(HttpMethod.values()));
- }
- RequestSpec requestSpec =
- new RequestSpec(reqParamsSpecBuilder.build(), reqBodySpecBuilder.build());
- ResponseSpec responseSpec =
- new ResponseSpec(resParamsSpecBuilder.build(), resBodySpecBuilder.build());
- WebServiceCallSpec callSpec = new WebServiceCallSpec(supportedHttpMethods, callPath,
- requestSpec, responseSpec);
- return callSpec;
- }
- }
-
- private final Set supportedHttpMethods;
- private final CallPath path;
- private final ResponseSpec responseSpec;
- private final RequestSpec requestSpec;
-
- private WebServiceCallSpec(Set supportedHttpMethods, CallPath path,
- RequestSpec requestSpec, ResponseSpec responseSpec) {
- Preconditions.checkArgument(!supportedHttpMethods.isEmpty());
- Preconditions.checkNotNull(path);
-
- this.supportedHttpMethods = supportedHttpMethods;
- this.path = path;
- this.requestSpec = requestSpec;
- this.responseSpec = responseSpec;
- }
-
- public CallPath getPath() {
- return path;
- }
-
- public Set getSupportedHttpMethods() {
- return supportedHttpMethods;
- }
-
- public ResponseSpec getResponseSpec() {
- return responseSpec;
- }
-
- public RequestSpec getRequestSpec() {
- return requestSpec;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("{path:");
- sb.append(path).append(",supportedHttpMethods:[");
- boolean first = true;
- for (HttpMethod method : supportedHttpMethods) {
- if (first) {
- first = false;
- } else {
- sb.append(",");
- }
- sb.append(method);
- }
- sb.append("],requestSpec:").append(requestSpec);
- sb.append(",responseSpec:").append(responseSpec).append("}");
- return sb.toString();
- }
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceRequest.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceRequest.java
deleted file mode 100644
index b5db7852..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceRequest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2008 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.procedural;
-
-import com.google.gson.webservice.definition.ContentBodySpec;
-import com.google.gson.webservice.definition.HeaderMap;
-import com.google.gson.webservice.definition.HttpMethod;
-import com.google.gson.webservice.definition.TypedKey;
-
-/**
- * The data associated with a Web service request. This includes HTTP request header parameters
- * (form and URL parameters), and {@link RequestBody}.
- *
- * @author inder
- */
-public final class WebServiceRequest {
- private final HttpMethod method;
- private final HeaderMap headers;
- private final RequestBody body;
- private final RequestSpec spec;
-
- public WebServiceRequest(HttpMethod method, HeaderMap requestHeaders, RequestBody requestBody) {
- this.method = method;
- this.body = requestBody;
- this.headers = requestHeaders;
- this.spec = new RequestSpec(requestHeaders.getSpec(), requestBody.getSpec());
- }
-
- public HttpMethod getMethod() {
- return method;
- }
-
- public RequestSpec getSpec() {
- return spec;
- }
-
- public HttpMethod getHttpMethod() {
- return method;
- }
-
- public RequestBody getBody() {
- return body;
- }
-
- public HeaderMap getHeaders() {
- return headers;
- }
-
- public String getContentType() {
- return ContentBodySpec.JSON_CONTENT_TYPE;
- }
-
- public T getHeader(TypedKey headerKey) {
- return headers.get(headerKey);
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("{");
- sb.append(method).append(",");
- sb.append(",headers:").append(headers);
- sb.append(",body:").append(body);
- sb.append("}");
- return sb.toString();
- }
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceResponse.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceResponse.java
deleted file mode 100644
index 66132ef0..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceResponse.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2008 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.procedural;
-
-import com.google.gson.webservice.definition.HeaderMap;
-import com.google.gson.webservice.definition.TypedKey;
-
-import java.lang.reflect.Type;
-
-/**
- * The data associated with a Web service response. This includes http response header parameters,
- * and {@link ResponseBody}.
- *
- * @author inder
- */
-public final class WebServiceResponse {
-
- private final HeaderMap headers;
- private final ResponseBody body;
- private final ResponseSpec spec;
-
- public static class Builder {
- private final HeaderMap.Builder headers;
- private final ResponseBody.Builder body;
- private final ResponseSpec spec;
-
- public Builder(ResponseSpec spec) {
- this.spec = spec;
- headers = new HeaderMap.Builder(spec.getHeadersSpec());
- body = new ResponseBody.Builder(spec.getBodySpec());
- }
-
- public Builder putHeader(String paramName, Object content) {
- headers.put(paramName, content);
- return this;
- }
-
- public Builder putHeader(String paramName, Object content, Type typeOfContent) {
- headers.put(paramName, content, typeOfContent);
- return this;
- }
-
- public Builder putBody(TypedKey paramName, T content) {
- return putBody(paramName.getName(), content);
- }
-
- public Builder putBody(String paramName, Object content) {
- body.put(paramName, content);
- return this;
- }
-
- public Builder put(String paramName, Object content, Type typeOfContent) {
- body.put(paramName, content, typeOfContent);
- return this;
- }
-
- public WebServiceResponse build() {
- return new WebServiceResponse(spec, headers.build(), body.build());
- }
- }
-
- private WebServiceResponse(ResponseSpec spec, HeaderMap headers, ResponseBody body) {
- this.spec = spec;
- this.headers = headers;
- this.body = body;
- }
-
- public WebServiceResponse(HeaderMap responseHeaders, ResponseBody responseBody) {
- this.spec = new ResponseSpec(responseHeaders.getSpec(), responseBody.getSpec());
- this.headers = responseHeaders;
- this.body = responseBody;
- }
-
- public ResponseSpec getSpec() {
- return spec;
- }
-
- public HeaderMap getHeaders() {
- return headers;
- }
-
- public ResponseBody getBody() {
- return body;
- }
-
- @SuppressWarnings("unchecked")
- public T getHeader(String headerName) {
- return (T) headers.get(headerName);
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("{headers:");
- sb.append(headers);
- sb.append(",body:").append(body);
- sb.append("}");
- return sb.toString();
- }
-}
diff --git a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceSpec.java b/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceSpec.java
deleted file mode 100644
index 7cd5d899..00000000
--- a/wsdef/src/main/java/com/google/gson/webservice/definition/procedural/WebServiceSpec.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2008 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.procedural;
-
-import com.google.gson.webservice.definition.CallPathMap;
-
-/**
- * Specification of the Web service. This contains a specification of all the
- * {@link WebServiceCall}s supported by this Web service.
- *
- * @author inder
- */
-public interface WebServiceSpec {
- public CallPathMap getCalls();
-}
diff --git a/wsdef/src/test/java/com/google/gson/rest/definition/IdTest.java b/wsdef/src/test/java/com/google/gson/rest/definition/IdTest.java
deleted file mode 100644
index 9a2e72bd..00000000
--- a/wsdef/src/test/java/com/google/gson/rest/definition/IdTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.rest.definition;
-
-import java.lang.reflect.ParameterizedType;
-
-import junit.framework.TestCase;
-
-import com.google.gson.reflect.TypeToken;
-import com.google.gson.rest.definition.ValueBasedId;
-
-/**
- * Unit test for {@link ValueBasedId}
- *
- * @author inder
- */
-public class IdTest extends TestCase {
-
- public void testRawTypeNotEqualToParameterizedOfConcreteType() {
- ParameterizedType type = (ParameterizedType) new TypeToken>(){}.getType();
- assertFalse(ValueBasedId.areEquivalentTypes(type, ValueBasedId.class));
- }
-
- public void testRawTypeEqualToParameterizedOfWildcardType() {
- ParameterizedType fooType = (ParameterizedType) new TypeToken>(){}.getType();
- assertTrue(ValueBasedId.areEquivalentTypes(fooType, ValueBasedId.class));
- }
-
- public void testStaticEquals() {
- ValueBasedId id1 = ValueBasedId.get(3L, Foo.class);
- ValueBasedId id2 = ValueBasedId.get(3L, Foo.class);
- ValueBasedId id3 = ValueBasedId.get(4L, Foo.class);
- assertTrue(ValueBasedId.equals(id1, id2));
- assertFalse(ValueBasedId.equals(null, id2));
- assertFalse(ValueBasedId.equals(id1, null));
- assertTrue(ValueBasedId.equals(null, null));
- assertFalse(ValueBasedId.equals(id1, id3));
- }
-
- private static class Foo {
- }
-}
diff --git a/wsdef/src/test/java/com/google/gson/rest/definition/IdTypeAdapterTest.java b/wsdef/src/test/java/com/google/gson/rest/definition/IdTypeAdapterTest.java
deleted file mode 100644
index 98f4b5ea..00000000
--- a/wsdef/src/test/java/com/google/gson/rest/definition/IdTypeAdapterTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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.rest.definition;
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.reflect.TypeToken;
-import com.google.gson.rest.definition.ValueBasedId;
-
-/**
- * Unit tests for {@link ValueBasedId.GsonTypeAdapter}
- *
- * @author inder
- */
-public class IdTypeAdapterTest extends TestCase {
- private static final ValueBasedId STUDENT1_ID = ValueBasedId.get(5L, Student.class);
- private static final ValueBasedId STUDENT2_ID = ValueBasedId.get(6L, Student.class);
- private static final Student STUDENT1 = new Student(STUDENT1_ID, "first");
- private static final Student STUDENT2 = new Student(STUDENT2_ID, "second");
- private static final Type TYPE_COURSE_HISTORY =
- new TypeToken>(){}.getType();
- private static final ValueBasedId> COURSE_ID = ValueBasedId.get(10L, TYPE_COURSE_HISTORY);
-
- private Gson gson;
- private Course course;
-
- @Override
- protected void setUp() {
- gson = new GsonBuilder()
- .registerTypeAdapter(ValueBasedId.class, new ValueBasedId.GsonTypeAdapter())
- .create();
- course = new Course(COURSE_ID, 4,
- new Assignment(null, null), createList(STUDENT1, STUDENT2));
- }
-
- public void testSerializeId() {
- String json = gson.toJson(course, TYPE_COURSE_HISTORY);
- assertTrue(json.contains(String.valueOf(COURSE_ID.getValue())));
- assertTrue(json.contains(String.valueOf(STUDENT1_ID.getValue())));
- assertTrue(json.contains(String.valueOf(STUDENT2_ID.getValue())));
- }
-
- public void testDeserializeId() {
- String json = "{courseId:1,students:[{id:1,name:'first'},{id:6,name:'second'}],"
- + "numAssignments:4,assignment:{}}";
- Course target = gson.fromJson(json, TYPE_COURSE_HISTORY);
- assertEquals(1, target.getStudents().get(0).id.getValue());
- assertEquals(6, target.getStudents().get(1).id.getValue());
- assertEquals(1, target.getId().getValue());
- }
-
- @SuppressWarnings("unused")
- private static class Student {
- ValueBasedId id;
- String name;
-
- private Student() {
- this(null, null);
- }
- public Student(ValueBasedId id, String name) {
- this.id = id;
- this.name = name;
- }
- }
- @SuppressWarnings("unused")
- private static class Course {
- final List students;
- private final ValueBasedId> courseId;
- private final int numAssignments;
- private final Assignment assignment;
-
- private Course() {
- this(null, 0, null, new ArrayList());
- }
-
- public Course(ValueBasedId> courseId, int numAssignments,
- Assignment assignment, List players) {
- this.courseId = courseId;
- this.numAssignments = numAssignments;
- this.assignment = assignment;
- this.students = players;
- }
- public ValueBasedId> getId() {
- return courseId;
- }
- List getStudents() {
- return students;
- }
- }
-
- @SuppressWarnings("unused")
- private static class Assignment {
- private final ValueBasedId> id;
- private final T data;
-
- private Assignment() {
- this(null, null);
- }
- public Assignment(ValueBasedId> id, T data) {
- this.id = id;
- this.data = data;
- }
- }
-
- @SuppressWarnings("unused")
- private static class HistoryCourse {
- int numClasses;
- }
-
- private static List createList(T ...items) {
- return Arrays.asList(items);
- }
-}
diff --git a/wsdef/src/test/java/com/google/gson/webservice/definition/CallPathTest.java b/wsdef/src/test/java/com/google/gson/webservice/definition/CallPathTest.java
deleted file mode 100644
index eae6d6db..00000000
--- a/wsdef/src/test/java/com/google/gson/webservice/definition/CallPathTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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 com.google.gson.rest.definition.ID;
-
-import junit.framework.TestCase;
-
-/**
- * Unit test for {@link CallPath}
- *
- * @author inder
- */
-public class CallPathTest extends TestCase {
-
- public void testVersionIsSkipped() {
- CallPath path = new CallPath("/1.0/rest/service1");
- assertEquals("/rest/service1", path.get());
- assertEquals(1D, path.getVersion());
- assertEquals(ID.INVALID_ID, path.getResourceId());
- }
-
- public void testVersionNotPresent() {
- CallPath path = new CallPath("/rest/service1");
- assertEquals("/rest/service1", path.get());
- assertEquals(CallPath.IGNORE_VERSION, path.getVersion());
- assertEquals(ID.INVALID_ID, path.getResourceId());
- }
-
- public void testResourceIdPresent() {
- CallPath path = new CallPath("/rest/service/3");
- assertEquals("/rest/service", path.get());
- assertEquals(3L, path.getResourceId());
- }
-
- public void testResourceIdWithEndSlashPresent() {
- CallPath path = new CallPath("/rest/service/3/");
- assertEquals("/rest/service", path.get());
- assertEquals(3L, path.getResourceId());
- }
-
- public void testVersionAndResourceIdPresent() {
- CallPath path = new CallPath("/3.1/rest/service53/323222");
- assertEquals(3.1D, path.getVersion());
- assertEquals("/rest/service53", path.get());
- assertEquals(323222L, path.getResourceId());
- }
-
- public void testNullPath() {
- CallPath path = new CallPath(null);
- assertEquals(CallPath.IGNORE_VERSION, path.getVersion());
- assertEquals(ID.INVALID_ID, path.getResourceId());
- assertNull(path.get());
- }
-
- public void testEmptyPath() {
- CallPath path = new CallPath("");
- assertEquals(CallPath.IGNORE_VERSION, path.getVersion());
- assertEquals(ID.INVALID_ID, path.getResourceId());
- assertEquals("", path.get());
- }
-
- public void testWhiteSpacePath() {
- CallPath path = new CallPath("\r\n");
- assertEquals(CallPath.IGNORE_VERSION, path.getVersion());
- assertEquals(ID.INVALID_ID, path.getResourceId());
- assertEquals("\r\n", path.get());
- }
-}
diff --git a/wsdef/src/test/java/com/google/gson/webservice/definition/TypedKeyTest.java b/wsdef/src/test/java/com/google/gson/webservice/definition/TypedKeyTest.java
deleted file mode 100644
index 309f3aa4..00000000
--- a/wsdef/src/test/java/com/google/gson/webservice/definition/TypedKeyTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2010 Google Inc. All Rights Reserved.
-
-package com.google.gson.webservice.definition;
-
-import junit.framework.TestCase;
-
-/**
- * Unit tests for {@link TypedKey}
- *
- * @author inder
- */
-public class TypedKeyTest extends TestCase {
-
- public void testEqualsForSameName() {
- assertEquals(new TypedKey("name", String.class),
- new TypedKey(new String("name"), String.class));
- }
-
- public void testEqualsFailsForDifferentClasses() {
- assertFalse(new TypedKey