cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r916913 - /cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/GenericEntity.java
Date Sat, 27 Feb 2010 06:14:44 GMT
Author: bluk
Date: Sat Feb 27 06:14:44 2010
New Revision: 916913

URL: http://svn.apache.org/viewvc?rev=916913&view=rev
Log:
Add JAX-RS Generic Entity

Added:
    cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/GenericEntity.java
  (with props)

Added: cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/GenericEntity.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/GenericEntity.java?rev=916913&view=auto
==============================================================================
--- cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/GenericEntity.java
(added)
+++ cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/GenericEntity.java
Sat Feb 27 06:14:44 2010
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 javax.ws.rs.core;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+public abstract class GenericEntity<T> {
+    private final T    entity;
+    private final Type genericType;
+
+    protected GenericEntity(T entity) {
+        if (entity == null) {
+            throw new IllegalArgumentException();
+        }
+        this.entity = entity;
+
+        Type superclass = this.getClass().getGenericSuperclass();
+        this.genericType = ((ParameterizedType)superclass).getActualTypeArguments()[0];
+
+        // TODO: what if the user extends their GenericEntity superclass?
+    }
+
+    public GenericEntity(T entity, Type genericType) {
+        if (entity == null) {
+            throw new IllegalArgumentException();
+        }
+
+        if (genericType == null) {
+            throw new IllegalArgumentException();
+        }
+
+        this.entity = entity;
+        this.genericType = genericType;
+    }
+
+    public T getEntity() {
+        return entity;
+    }
+
+    public java.lang.Class<?> getRawType() {
+        return entity.getClass();
+    }
+
+    public java.lang.reflect.Type getType() {
+        return genericType;
+    }
+}

Propchange: cxf/sandbox/geronimo-jaxrs_1.0_spec/src/main/java/javax/ws/rs/core/GenericEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message