You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by rm...@apache.org on 2017/12/19 11:39:15 UTC
svn commit: r1818654 [4/6] - in
/geronimo/specs/trunk/geronimo-jaxrs_2.1_spec: ./
src/main/java/javax/ws/rs/ src/main/java/javax/ws/rs/client/
src/main/java/javax/ws/rs/container/ src/main/java/javax/ws/rs/core/
src/main/java/javax/ws/rs/ext/ src/main/...
Modified: geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/CacheControl.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/CacheControl.java?rev=1818654&r1=1818653&r2=1818654&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/CacheControl.java (original)
+++ geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/CacheControl.java Tue Dec 19 11:39:13 2017
@@ -1,234 +1,263 @@
-/*
- * #%L
- * Apache Geronimo JAX-RS Spec 2.0
- * %%
- * Copyright (C) 2003 - 2014 The Apache Software Foundation
- * %%
- * 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.
- * #L%
- */
-
-package javax.ws.rs.core;
-
-import javax.ws.rs.ext.RuntimeDelegate;
-import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-
-public class CacheControl {
-
- private static final HeaderDelegate<CacheControl> HEADER_DELEGATE = RuntimeDelegate.getInstance().createHeaderDelegate(CacheControl.class);
- private boolean privateFlag;
- private List<String> privateFields;
- private boolean noCache;
- private List<String> noCacheFields;
- private boolean noStore;
- private boolean noTransform;
- private boolean mustRevalidate;
- private boolean proxyRevalidate;
- private int maxAge = -1;
- private int sMaxAge = -1;
- private Map<String, String> cacheExtension;
-
-
- public CacheControl() {
- privateFlag = false;
- noCache = false;
- noStore = false;
- noTransform = true;
- mustRevalidate = false;
- proxyRevalidate = false;
- }
-
-
- public static CacheControl valueOf(final String value) {
- return HEADER_DELEGATE.fromString(value);
- }
-
-
- public boolean isMustRevalidate() {
- return mustRevalidate;
- }
-
-
- public void setMustRevalidate(final boolean mustRevalidate) {
- this.mustRevalidate = mustRevalidate;
- }
-
-
- public boolean isProxyRevalidate() {
- return proxyRevalidate;
- }
-
-
- public void setProxyRevalidate(final boolean proxyRevalidate) {
- this.proxyRevalidate = proxyRevalidate;
- }
-
-
- public int getMaxAge() {
- return maxAge;
- }
-
-
- public void setMaxAge(final int maxAge) {
- this.maxAge = maxAge;
- }
-
-
- public int getSMaxAge() {
- return sMaxAge;
- }
-
-
- public void setSMaxAge(final int sMaxAge) {
- this.sMaxAge = sMaxAge;
- }
-
-
- public List<String> getNoCacheFields() {
- if (noCacheFields == null) {
- noCacheFields = new ArrayList<String>();
- }
- return noCacheFields;
- }
-
-
- public void setNoCache(final boolean noCache) {
- this.noCache = noCache;
- }
-
-
- public boolean isNoCache() {
- return noCache;
- }
-
-
- public boolean isPrivate() {
- return privateFlag;
- }
-
-
- public List<String> getPrivateFields() {
- if (privateFields == null) {
- privateFields = new ArrayList<String>();
- }
- return privateFields;
- }
-
-
- public void setPrivate(final boolean flag) {
- this.privateFlag = flag;
- }
-
-
- public boolean isNoTransform() {
- return noTransform;
- }
-
-
- public void setNoTransform(final boolean noTransform) {
- this.noTransform = noTransform;
- }
-
-
- public boolean isNoStore() {
- return noStore;
- }
-
-
- public void setNoStore(final boolean noStore) {
- this.noStore = noStore;
- }
-
-
- public Map<String, String> getCacheExtension() {
- if (cacheExtension == null) {
- cacheExtension = new HashMap<String, String>();
- }
- return cacheExtension;
- }
-
-
- @Override
- public String toString() {
- return HEADER_DELEGATE.toString(this);
- }
-
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 41 * hash + (this.privateFlag ? 1 : 0);
- hash = 41 * hash + (this.privateFields != null ? this.privateFields.hashCode() : 0);
- hash = 41 * hash + (this.noCache ? 1 : 0);
- hash = 41 * hash + (this.noCacheFields != null ? this.noCacheFields.hashCode() : 0);
- hash = 41 * hash + (this.noStore ? 1 : 0);
- hash = 41 * hash + (this.noTransform ? 1 : 0);
- hash = 41 * hash + (this.mustRevalidate ? 1 : 0);
- hash = 41 * hash + (this.proxyRevalidate ? 1 : 0);
- hash = 41 * hash + this.maxAge;
- hash = 41 * hash + this.sMaxAge;
- hash = 41 * hash + (this.cacheExtension != null ? this.cacheExtension.hashCode() : 0);
- return hash;
- }
-
-
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final CacheControl other = (CacheControl) obj;
- if (this.privateFlag != other.privateFlag) {
- return false;
- }
- if (this.privateFields != other.privateFields && (this.privateFields == null || !this.privateFields.equals(other.privateFields))) {
- return false;
- }
- if (this.noCache != other.noCache) {
- return false;
- }
- if (this.noCacheFields != other.noCacheFields && (this.noCacheFields == null || !this.noCacheFields.equals(other.noCacheFields))) {
- return false;
- }
- if (this.noStore != other.noStore) {
- return false;
- }
- if (this.noTransform != other.noTransform) {
- return false;
- }
- if (this.mustRevalidate != other.mustRevalidate) {
- return false;
- }
- if (this.proxyRevalidate != other.proxyRevalidate) {
- return false;
- }
- if (this.maxAge != other.maxAge) {
- return false;
- }
- if (this.sMaxAge != other.sMaxAge) {
- return false;
- }
- if (this.cacheExtension != other.cacheExtension && (this.cacheExtension == null || !this.cacheExtension.equals(other.cacheExtension))) {
- return false;
- }
- return true;
- }
-}
+/*
+ * #%L
+ * Apache Geronimo JAX-RS Spec 2.0
+ * %%
+ * Copyright (C) 2003 - 2014 The Apache Software Foundation
+ * %%
+ * 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.
+ * #L%
+ */
+
+package javax.ws.rs.core;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.ext.RuntimeDelegate;
+import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
+
+public class CacheControl {
+
+ private static final HeaderDelegate<CacheControl> HEADER_DELEGATE = RuntimeDelegate.getInstance()
+ .createHeaderDelegate(CacheControl.class);
+
+ private List<String> privateFields;
+
+ private List<String> noCacheFields;
+
+ private Map<String, String> cacheExtension;
+
+ private boolean privateFlag;
+
+ private boolean noCache;
+
+ private boolean noStore;
+
+ private boolean noTransform;
+
+ private boolean mustRevalidate;
+
+ private boolean proxyRevalidate;
+
+ private int maxAge = -1;
+
+ private int sMaxAge = -1;
+
+ public CacheControl() {
+ privateFlag = false;
+ noCache = false;
+ noStore = false;
+ noTransform = true;
+ mustRevalidate = false;
+ proxyRevalidate = false;
+ }
+
+ public static CacheControl valueOf(final String value) {
+ return HEADER_DELEGATE.fromString(value);
+ }
+
+ public boolean isMustRevalidate() {
+ return mustRevalidate;
+ }
+
+ public void setMustRevalidate(final boolean mustRevalidate) {
+ this.mustRevalidate = mustRevalidate;
+ }
+
+ public boolean isProxyRevalidate() {
+ return proxyRevalidate;
+ }
+
+ public void setProxyRevalidate(final boolean proxyRevalidate) {
+ this.proxyRevalidate = proxyRevalidate;
+ }
+
+ public int getMaxAge() {
+ return maxAge;
+ }
+
+ public void setMaxAge(final int maxAge) {
+ this.maxAge = maxAge;
+ }
+
+ public int getSMaxAge() {
+ return sMaxAge;
+ }
+
+ public void setSMaxAge(final int sMaxAge) {
+ this.sMaxAge = sMaxAge;
+ }
+
+ public List<String> getNoCacheFields() {
+ if (noCacheFields == null) {
+ noCacheFields = new ArrayList<String>();
+ }
+ return noCacheFields;
+ }
+
+ public void setNoCache(final boolean noCache) {
+ this.noCache = noCache;
+ }
+
+ public boolean isNoCache() {
+ return noCache;
+ }
+
+ public boolean isPrivate() {
+ return privateFlag;
+ }
+
+ public List<String> getPrivateFields() {
+ if (privateFields == null) {
+ privateFields = new ArrayList<String>();
+ }
+ return privateFields;
+ }
+
+ public void setPrivate(final boolean flag) {
+ this.privateFlag = flag;
+ }
+
+ public boolean isNoTransform() {
+ return noTransform;
+ }
+
+ public void setNoTransform(final boolean noTransform) {
+ this.noTransform = noTransform;
+ }
+
+ public boolean isNoStore() {
+ return noStore;
+ }
+
+ public void setNoStore(final boolean noStore) {
+ this.noStore = noStore;
+ }
+
+ public Map<String, String> getCacheExtension() {
+ if (cacheExtension == null) {
+ cacheExtension = new HashMap<String, String>();
+ }
+ return cacheExtension;
+ }
+
+ @Override
+ public String toString() {
+ return HEADER_DELEGATE.toString(this);
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 41 * hash + (this.privateFlag ? 1 : 0);
+ hash = 41 * hash + (this.noCache ? 1 : 0);
+ hash = 41 * hash + (this.noStore ? 1 : 0);
+ hash = 41 * hash + (this.noTransform ? 1 : 0);
+ hash = 41 * hash + (this.mustRevalidate ? 1 : 0);
+ hash = 41 * hash + (this.proxyRevalidate ? 1 : 0);
+ hash = 41 * hash + this.maxAge;
+ hash = 41 * hash + this.sMaxAge;
+ hash = 41 * hash + hashCodeOf(this.privateFields);
+ hash = 41 * hash + hashCodeOf(this.noCacheFields);
+ hash = 41 * hash + hashCodeOf(this.cacheExtension);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final CacheControl other = (CacheControl) obj;
+ if (this.privateFlag != other.privateFlag) {
+ return false;
+ }
+ if (this.noCache != other.noCache) {
+ return false;
+ }
+ if (this.noStore != other.noStore) {
+ return false;
+ }
+ if (this.noTransform != other.noTransform) {
+ return false;
+ }
+ if (this.mustRevalidate != other.mustRevalidate) {
+ return false;
+ }
+ if (this.proxyRevalidate != other.proxyRevalidate) {
+ return false;
+ }
+ if (this.maxAge != other.maxAge) {
+ return false;
+ }
+ if (this.sMaxAge != other.sMaxAge) {
+ return false;
+ }
+ if (notEqual(this.privateFields, other.privateFields)) {
+ return false;
+ }
+ if (notEqual(this.noCacheFields, other.noCacheFields)) {
+ return false;
+ }
+ if (notEqual(this.cacheExtension, other.cacheExtension)) {
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean notEqual(Collection<?> first, Collection<?> second) {
+ if (first == second) {
+ return false;
+ }
+ if (first == null) {
+ // if first is 'null', consider equal to empty
+ return !second.isEmpty();
+ }
+ if (second == null) {
+ // if second is 'null', consider equal to empty
+ return !first.isEmpty();
+ }
+
+ return !first.equals(second);
+ }
+
+ private static boolean notEqual(Map<?, ?> first, Map<?, ?> second) {
+ if (first == second) {
+ return false;
+ }
+ if (first == null) {
+ // if first is 'null', consider equal to empty
+ return !second.isEmpty();
+ }
+ if (second == null) {
+ // if second is 'null', consider equal to empty
+ return !first.isEmpty();
+ }
+
+ return !first.equals(second);
+ }
+
+ private static int hashCodeOf(Collection<?> instance) {
+ return (instance == null || instance.isEmpty()) ? 0 : instance.hashCode();
+ }
+
+ private static int hashCodeOf(Map<?, ?> instance) {
+ return (instance == null || instance.isEmpty()) ? 0 : instance.hashCode();
+ }
+}
Modified: geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Configurable.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Configurable.java?rev=1818654&r1=1818653&r2=1818654&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Configurable.java (original)
+++ geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Configurable.java Tue Dec 19 11:39:13 2017
@@ -1,57 +1,46 @@
-/*
- * #%L
- * Apache Geronimo JAX-RS Spec 2.0
- * %%
- * Copyright (C) 2003 - 2014 The Apache Software Foundation
- * %%
- * 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.
- * #L%
- */
-
-package javax.ws.rs.core;
-
-import java.util.Map;
-
-
-public interface Configurable<C extends Configurable> {
-
-
- Configuration getConfiguration();
-
-
- C property(String name, Object value);
-
-
- C register(Class<?> componentClass);
-
-
- C register(Class<?> componentClass, int priority);
-
-
- C register(Class<?> componentClass, Class<?>... contracts);
-
-
- C register(Class<?> componentClass, Map<Class<?>, Integer> contracts);
-
-
- C register(Object component);
-
-
- C register(Object component, int priority);
-
-
- C register(Object component, Class<?>... contracts);
-
-
- C register(Object component, Map<Class<?>, Integer> contracts);
-}
+/*
+ * #%L
+ * Apache Geronimo JAX-RS Spec 2.0
+ * %%
+ * Copyright (C) 2003 - 2014 The Apache Software Foundation
+ * %%
+ * 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.
+ * #L%
+ */
+
+package javax.ws.rs.core;
+
+import java.util.Map;
+
+public interface Configurable<C extends Configurable> {
+
+ public Configuration getConfiguration();
+
+ public C property(String name, Object value);
+
+ public C register(Class<?> componentClass);
+
+ public C register(Class<?> componentClass, int priority);
+
+ public C register(Class<?> componentClass, Class<?>... contracts);
+
+ public C register(Class<?> componentClass, Map<Class<?>, Integer> contracts);
+
+ public C register(Object component);
+
+ public C register(Object component, int priority);
+
+ public C register(Object component, Class<?>... contracts);
+
+ public C register(Object component, Map<Class<?>, Integer> contracts);
+}
Modified: geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Configuration.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Configuration.java?rev=1818654&r1=1818653&r2=1818654&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Configuration.java (original)
+++ geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Configuration.java Tue Dec 19 11:39:13 2017
@@ -1,63 +1,52 @@
-/*
- * #%L
- * Apache Geronimo JAX-RS Spec 2.0
- * %%
- * Copyright (C) 2003 - 2014 The Apache Software Foundation
- * %%
- * 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.
- * #L%
- */
-
-package javax.ws.rs.core;
-
-import javax.ws.rs.RuntimeType;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-
-public interface Configuration {
-
-
- public RuntimeType getRuntimeType();
-
-
- public Map<String, Object> getProperties();
-
-
- public Object getProperty(String name);
-
-
- public Collection<String> getPropertyNames();
-
-
- public boolean isEnabled(Feature feature);
-
-
- public boolean isEnabled(Class<? extends Feature> featureClass);
-
-
- public boolean isRegistered(Object component);
-
-
- public boolean isRegistered(Class<?> componentClass);
-
-
- public Map<Class<?>, Integer> getContracts(Class<?> componentClass);
-
-
- public Set<Class<?>> getClasses();
-
-
- public Set<Object> getInstances();
-}
+/*
+ * #%L
+ * Apache Geronimo JAX-RS Spec 2.0
+ * %%
+ * Copyright (C) 2003 - 2014 The Apache Software Foundation
+ * %%
+ * 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.
+ * #L%
+ */
+
+package javax.ws.rs.core;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ws.rs.RuntimeType;
+
+public interface Configuration {
+
+ public RuntimeType getRuntimeType();
+
+ public Map<String, Object> getProperties();
+
+ public Object getProperty(String name);
+
+ public Collection<String> getPropertyNames();
+
+ public boolean isEnabled(Feature feature);
+
+ public boolean isEnabled(Class<? extends Feature> featureClass);
+
+ public boolean isRegistered(Object component);
+
+ public boolean isRegistered(Class<?> componentClass);
+
+ public Map<Class<?>, Integer> getContracts(Class<?> componentClass);
+
+ public Set<Class<?>> getClasses();
+
+ public Set<Object> getInstances();
+}
Modified: geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Context.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Context.java?rev=1818654&r1=1818653&r2=1818654&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Context.java (original)
+++ geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Context.java Tue Dec 19 11:39:13 2017
@@ -8,7 +8,7 @@
* 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
+ * 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,
@@ -17,18 +17,17 @@
* limitations under the License.
* #L%
*/
-
-package javax.ws.rs.core;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-
-@Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface Context {
-}
+
+package javax.ws.rs.core;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface Context {
+}
Modified: geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Cookie.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Cookie.java?rev=1818654&r1=1818653&r2=1818654&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Cookie.java (original)
+++ geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Cookie.java Tue Dec 19 11:39:13 2017
@@ -1,136 +1,130 @@
-/*
- * #%L
- * Apache Geronimo JAX-RS Spec 2.0
- * %%
- * Copyright (C) 2003 - 2014 The Apache Software Foundation
- * %%
- * 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.
- * #L%
- */
-
-package javax.ws.rs.core;
-
-import javax.ws.rs.ext.RuntimeDelegate;
-import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
-
-
-public class Cookie {
-
-
- public static final int DEFAULT_VERSION = 1;
- private static final HeaderDelegate<Cookie> HEADER_DELEGATE = RuntimeDelegate.getInstance().createHeaderDelegate(Cookie.class);
- private final String name;
- private final String value;
- private final int version;
- private final String path;
- private final String domain;
-
-
- public Cookie(final String name, final String value, final String path, final String domain, final int version) throws IllegalArgumentException {
- if (name == null) {
- throw new IllegalArgumentException("name==null");
- }
- this.name = name;
- this.value = value;
- this.version = version;
- this.domain = domain;
- this.path = path;
- }
-
-
- public Cookie(final String name, final String value, final String path, final String domain) throws IllegalArgumentException {
- this(name, value, path, domain, DEFAULT_VERSION);
- }
-
-
- public Cookie(final String name, final String value) throws IllegalArgumentException {
- this(name, value, null, null);
- }
-
-
- public static Cookie valueOf(final String value) {
- return HEADER_DELEGATE.fromString(value);
- }
-
-
- public String getName() {
- return name;
- }
-
-
- public String getValue() {
- return value;
- }
-
-
- public int getVersion() {
- return version;
- }
-
-
- public String getDomain() {
- return domain;
- }
-
-
- public String getPath() {
- return path;
- }
-
-
- @Override
- public String toString() {
- return HEADER_DELEGATE.toString(this);
- }
-
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 97 * hash + (this.name != null ? this.name.hashCode() : 0);
- hash = 97 * hash + (this.value != null ? this.value.hashCode() : 0);
- hash = 97 * hash + this.version;
- hash = 97 * hash + (this.path != null ? this.path.hashCode() : 0);
- hash = 97 * hash + (this.domain != null ? this.domain.hashCode() : 0);
- return hash;
- }
-
-
- @SuppressWarnings({"StringEquality", "RedundantIfStatement"})
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Cookie other = (Cookie) obj;
- if (this.name != other.name && (this.name == null || !this.name.equals(other.name))) {
- return false;
- }
- if (this.value != other.value && (this.value == null || !this.value.equals(other.value))) {
- return false;
- }
- if (this.version != other.version) {
- return false;
- }
- if (this.path != other.path && (this.path == null || !this.path.equals(other.path))) {
- return false;
- }
- if (this.domain != other.domain && (this.domain == null || !this.domain.equals(other.domain))) {
- return false;
- }
- return true;
- }
-}
+/*
+ * #%L
+ * Apache Geronimo JAX-RS Spec 2.0
+ * %%
+ * Copyright (C) 2003 - 2014 The Apache Software Foundation
+ * %%
+ * 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.
+ * #L%
+ */
+
+package javax.ws.rs.core;
+
+import javax.ws.rs.ext.RuntimeDelegate;
+import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
+
+public class Cookie {
+
+ public static final int DEFAULT_VERSION = 1;
+
+ private static final HeaderDelegate<Cookie> HEADER_DELEGATE = RuntimeDelegate.getInstance()
+ .createHeaderDelegate(Cookie.class);
+
+ private final String name;
+
+ private final String value;
+
+ private final int version;
+
+ private final String path;
+
+ private final String domain;
+
+ public Cookie(final String name, final String value, final String path, final String domain, final int version)
+ throws IllegalArgumentException {
+ if (name == null) {
+ throw new IllegalArgumentException("name==null");
+ }
+ this.name = name;
+ this.value = value;
+ this.version = version;
+ this.domain = domain;
+ this.path = path;
+ }
+
+ public Cookie(final String name, final String value, final String path, final String domain) throws IllegalArgumentException {
+ this(name, value, path, domain, DEFAULT_VERSION);
+ }
+
+ public Cookie(final String name, final String value) throws IllegalArgumentException {
+ this(name, value, null, null);
+ }
+
+ public static Cookie valueOf(final String value) {
+ return HEADER_DELEGATE.fromString(value);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public int getVersion() {
+ return version;
+ }
+
+ public String getDomain() {
+ return domain;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ @Override
+ public String toString() {
+ return HEADER_DELEGATE.toString(this);
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 97 * hash + (this.name != null ? this.name.hashCode() : 0);
+ hash = 97 * hash + (this.value != null ? this.value.hashCode() : 0);
+ hash = 97 * hash + this.version;
+ hash = 97 * hash + (this.path != null ? this.path.hashCode() : 0);
+ hash = 97 * hash + (this.domain != null ? this.domain.hashCode() : 0);
+ return hash;
+ }
+
+ @SuppressWarnings({ "StringEquality", "RedundantIfStatement" })
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Cookie other = (Cookie) obj;
+ if (this.name != other.name && (this.name == null || !this.name.equals(other.name))) {
+ return false;
+ }
+ if (this.value != other.value && (this.value == null || !this.value.equals(other.value))) {
+ return false;
+ }
+ if (this.version != other.version) {
+ return false;
+ }
+ if (this.path != other.path && (this.path == null || !this.path.equals(other.path))) {
+ return false;
+ }
+ if (this.domain != other.domain && (this.domain == null || !this.domain.equals(other.domain))) {
+ return false;
+ }
+ return true;
+ }
+}
Modified: geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/EntityTag.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/EntityTag.java?rev=1818654&r1=1818653&r2=1818654&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/EntityTag.java (original)
+++ geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/EntityTag.java Tue Dec 19 11:39:13 2017
@@ -1,92 +1,86 @@
-/*
- * #%L
- * Apache Geronimo JAX-RS Spec 2.0
- * %%
- * Copyright (C) 2003 - 2014 The Apache Software Foundation
- * %%
- * 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.
- * #L%
- */
-
-package javax.ws.rs.core;
-
-import javax.ws.rs.ext.RuntimeDelegate;
-import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
-
-
-public class EntityTag {
-
- private static final HeaderDelegate<EntityTag> HEADER_DELEGATE = RuntimeDelegate.getInstance().createHeaderDelegate(EntityTag.class);
- private String value;
- private boolean weak;
-
-
- public EntityTag(final String value) {
- this(value, false);
- }
-
-
- public EntityTag(final String value, final boolean weak) {
- if (value == null) {
- throw new IllegalArgumentException("value==null");
- }
- this.value = value;
- this.weak = weak;
- }
-
-
- public static EntityTag valueOf(final String value) {
- return HEADER_DELEGATE.fromString(value);
- }
-
-
- public boolean isWeak() {
- return weak;
- }
-
-
- public String getValue() {
- return value;
- }
-
-
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof EntityTag)) {
- return super.equals(obj);
- }
- EntityTag other = (EntityTag) obj;
- if (value.equals(other.getValue()) && weak == other.isWeak()) {
- return true;
- }
- return false;
- }
-
-
- @Override
- public int hashCode() {
- int hash = 3;
- hash = 17 * hash + (this.value != null ? this.value.hashCode() : 0);
- hash = 17 * hash + (this.weak ? 1 : 0);
- return hash;
- }
-
-
- @Override
- public String toString() {
- return HEADER_DELEGATE.toString(this);
- }
-}
+/*
+ * #%L
+ * Apache Geronimo JAX-RS Spec 2.0
+ * %%
+ * Copyright (C) 2003 - 2014 The Apache Software Foundation
+ * %%
+ * 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.
+ * #L%
+ */
+
+package javax.ws.rs.core;
+
+import javax.ws.rs.ext.RuntimeDelegate;
+import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
+
+public class EntityTag {
+
+ private static final HeaderDelegate<EntityTag> HEADER_DELEGATE = RuntimeDelegate.getInstance()
+ .createHeaderDelegate(EntityTag.class);
+
+ private String value;
+
+ private boolean weak;
+
+ public EntityTag(final String value) {
+ this(value, false);
+ }
+
+ public EntityTag(final String value, final boolean weak) {
+ if (value == null) {
+ throw new IllegalArgumentException("value==null");
+ }
+ this.value = value;
+ this.weak = weak;
+ }
+
+ public static EntityTag valueOf(final String value) {
+ return HEADER_DELEGATE.fromString(value);
+ }
+
+ public boolean isWeak() {
+ return weak;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (!(obj instanceof EntityTag)) {
+ return super.equals(obj);
+ }
+ EntityTag other = (EntityTag) obj;
+ if (value.equals(other.getValue()) && weak == other.isWeak()) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 3;
+ hash = 17 * hash + (this.value != null ? this.value.hashCode() : 0);
+ hash = 17 * hash + (this.weak ? 1 : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ return HEADER_DELEGATE.toString(this);
+ }
+}
Modified: geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Feature.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Feature.java?rev=1818654&r1=1818653&r2=1818654&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Feature.java (original)
+++ geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Feature.java Tue Dec 19 11:39:13 2017
@@ -8,7 +8,7 @@
* 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
+ * 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,
@@ -20,9 +20,7 @@
package javax.ws.rs.core;
-
public interface Feature {
-
- boolean configure(FeatureContext context);
+ public boolean configure(FeatureContext context);
}
Modified: geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/FeatureContext.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/FeatureContext.java?rev=1818654&r1=1818653&r2=1818654&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/FeatureContext.java (original)
+++ geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/FeatureContext.java Tue Dec 19 11:39:13 2017
@@ -8,7 +8,7 @@
* 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
+ * 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,
@@ -17,9 +17,8 @@
* limitations under the License.
* #L%
*/
-
-package javax.ws.rs.core;
-
-
-public interface FeatureContext extends Configurable<FeatureContext> {
-}
+
+package javax.ws.rs.core;
+
+public interface FeatureContext extends Configurable<FeatureContext> {
+}
Modified: geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Form.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Form.java?rev=1818654&r1=1818653&r2=1818654&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Form.java (original)
+++ geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Form.java Tue Dec 19 11:39:13 2017
@@ -1,60 +1,55 @@
-/*
- * #%L
- * Apache Geronimo JAX-RS Spec 2.0
- * %%
- * Copyright (C) 2003 - 2014 The Apache Software Foundation
- * %%
- * 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.
- * #L%
- */
-
-package javax.ws.rs.core;
-
-import java.util.LinkedHashMap;
-import java.util.List;
-
-
-public class Form {
- private final MultivaluedMap<String, String> parameters;
-
-
- public Form() {
- this(new AbstractMultivaluedMap<String, String>(new LinkedHashMap<String, List<String>>()) {
-
- });
- }
-
-
- public Form(final String parameterName, final String parameterValue) {
- this();
-
- parameters.add(parameterName, parameterValue);
- }
-
-
- public Form(final MultivaluedMap<String, String> store) {
- this.parameters = store;
- }
-
-
- public Form param(final String name, final String value) {
- parameters.add(name, value);
-
- return this;
- }
-
-
- public MultivaluedMap<String, String> asMap() {
- return parameters;
- }
-}
+/*
+ * #%L
+ * Apache Geronimo JAX-RS Spec 2.0
+ * %%
+ * Copyright (C) 2003 - 2014 The Apache Software Foundation
+ * %%
+ * 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.
+ * #L%
+ */
+
+package javax.ws.rs.core;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+
+public class Form {
+
+ private final MultivaluedMap<String, String> parameters;
+
+ public Form() {
+ this(new AbstractMultivaluedMap<String, String>(new LinkedHashMap<String, List<String>>()) {
+ // by default, the items in a Form are iterable based on their insertion order.
+ });
+ }
+
+ public Form(final String parameterName, final String parameterValue) {
+ this();
+
+ parameters.add(parameterName, parameterValue);
+ }
+
+ public Form(final MultivaluedMap<String, String> store) {
+ this.parameters = store;
+ }
+
+ public Form param(final String name, final String value) {
+ parameters.add(name, value);
+
+ return this;
+ }
+
+ public MultivaluedMap<String, String> asMap() {
+ return parameters;
+ }
+}
Modified: geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/GenericEntity.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/GenericEntity.java?rev=1818654&r1=1818653&r2=1818654&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/GenericEntity.java (original)
+++ geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/GenericEntity.java Tue Dec 19 11:39:13 2017
@@ -1,110 +1,105 @@
-/*
- * #%L
- * Apache Geronimo JAX-RS Spec 2.0
- * %%
- * Copyright (C) 2003 - 2014 The Apache Software Foundation
- * %%
- * 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.
- * #L%
- */
-
-package javax.ws.rs.core;
-
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-
-
-public class GenericEntity<T> {
-
- private final Class<?> rawType;
- private final Type type;
- private final T entity;
-
-
- protected GenericEntity(final T entity) {
- if (entity == null) {
- throw new IllegalArgumentException("The entity must not be null");
- }
- this.entity = entity;
- this.type = GenericType.getTypeArgument(getClass(), GenericEntity.class);
- this.rawType = entity.getClass();
- }
-
-
- public GenericEntity(final T entity, final Type genericType) {
- if (entity == null || genericType == null) {
- throw new IllegalArgumentException("Arguments must not be null.");
- }
- this.entity = entity;
- this.rawType = entity.getClass();
- checkTypeCompatibility(this.rawType, genericType);
- this.type = genericType;
- }
-
- private void checkTypeCompatibility(final Class<?> c, final Type t) {
- if (t instanceof Class) {
- Class<?> ct = (Class<?>) t;
- if (ct.isAssignableFrom(c)) {
- return;
- }
- } else if (t instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType) t;
- Type rt = pt.getRawType();
- checkTypeCompatibility(c, rt);
- return;
- } else if (c.isArray() && (t instanceof GenericArrayType)) {
- GenericArrayType at = (GenericArrayType) t;
- Type rt = at.getGenericComponentType();
- checkTypeCompatibility(c.getComponentType(), rt);
- return;
- }
- throw new IllegalArgumentException("The type is incompatible with the class of the entity.");
- }
-
-
- public final Class<?> getRawType() {
- return rawType;
- }
-
-
- public final Type getType() {
- return type;
- }
-
-
- public final T getEntity() {
- return entity;
- }
-
- @Override
- public boolean equals(Object obj) {
- boolean result = this == obj;
- if (!result && obj instanceof GenericEntity) {
-
- GenericEntity<?> that = (GenericEntity<?>) obj;
- return this.type.equals(that.type) && this.entity.equals(that.entity);
- }
- return result;
- }
-
- @Override
- public int hashCode() {
- return entity.hashCode() + type.hashCode() * 37 + 5;
- }
-
- @Override
- public String toString() {
- return "GenericEntity{" + entity.toString() + ", " + type.toString() + "}";
- }
-}
+/*
+ * #%L
+ * Apache Geronimo JAX-RS Spec 2.0
+ * %%
+ * Copyright (C) 2003 - 2014 The Apache Software Foundation
+ * %%
+ * 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.
+ * #L%
+ */
+package javax.ws.rs.core;
+
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+public class GenericEntity<T> {
+
+ private final Class<?> rawType;
+
+ private final Type type;
+
+ private final T entity;
+
+ protected GenericEntity(final T entity) {
+ if (entity == null) {
+ throw new IllegalArgumentException("The entity must not be null");
+ }
+ this.entity = entity;
+ this.type = GenericType.getTypeArgument(getClass(), GenericEntity.class);
+ this.rawType = entity.getClass();
+ }
+
+ public GenericEntity(final T entity, final Type genericType) {
+ if (entity == null || genericType == null) {
+ throw new IllegalArgumentException("Arguments must not be null.");
+ }
+ this.entity = entity;
+ this.rawType = entity.getClass();
+ checkTypeCompatibility(this.rawType, genericType);
+ this.type = genericType;
+ }
+
+ private void checkTypeCompatibility(final Class<?> c, final Type t) {
+ if (t instanceof Class) {
+ Class<?> ct = (Class<?>) t;
+ if (ct.isAssignableFrom(c)) {
+ return;
+ }
+ } else if (t instanceof ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType) t;
+ Type rt = pt.getRawType();
+ checkTypeCompatibility(c, rt);
+ return;
+ } else if (c.isArray() && (t instanceof GenericArrayType)) {
+ GenericArrayType at = (GenericArrayType) t;
+ Type rt = at.getGenericComponentType();
+ checkTypeCompatibility(c.getComponentType(), rt);
+ return;
+ }
+ throw new IllegalArgumentException("The type is incompatible with the class of the entity.");
+ }
+
+ public final Class<?> getRawType() {
+ return rawType;
+ }
+
+ public final Type getType() {
+ return type;
+ }
+
+ public final T getEntity() {
+ return entity;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ boolean result = this == obj;
+ if (!result && obj instanceof GenericEntity) {
+ // Compare inner type for equality
+ GenericEntity<?> that = (GenericEntity<?>) obj;
+ return this.type.equals(that.type) && this.entity.equals(that.entity);
+ }
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ return entity.hashCode() + type.hashCode() * 37 + 5;
+ }
+
+ @Override
+ public String toString() {
+ return "GenericEntity{" + entity.toString() + ", " + type.toString() + "}";
+ }
+}
Modified: geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/GenericType.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/GenericType.java?rev=1818654&r1=1818653&r2=1818654&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/GenericType.java (original)
+++ geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/GenericType.java Tue Dec 19 11:39:13 2017
@@ -1,159 +1,160 @@
-/*
- * #%L
- * Apache Geronimo JAX-RS Spec 2.0
- * %%
- * Copyright (C) 2003 - 2014 The Apache Software Foundation
- * %%
- * 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.
- * #L%
- */
-
-package javax.ws.rs.core;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.util.Arrays;
-import java.util.Stack;
-
-
-public class GenericType<T> {
-
-
- private final Type type;
-
- private final Class<?> rawType;
-
-
- protected GenericType() {
-
- type = getTypeArgument(getClass(), GenericType.class);
- rawType = getClass(type);
- }
-
-
- public GenericType(Type genericType) {
- if (genericType == null) {
- throw new IllegalArgumentException("Type must not be null");
- }
-
- type = genericType;
- rawType = getClass(type);
- }
-
-
- public final Type getType() {
- return type;
- }
-
-
- public final Class<?> getRawType() {
- return rawType;
- }
-
-
- private static Class getClass(Type type) {
- if (type instanceof Class) {
- return (Class) type;
- } else if (type instanceof ParameterizedType) {
- ParameterizedType parameterizedType = (ParameterizedType) type;
- if (parameterizedType.getRawType() instanceof Class) {
- return (Class) parameterizedType.getRawType();
- }
- } else if (type instanceof GenericArrayType) {
- GenericArrayType array = (GenericArrayType) type;
- final Class<?> componentRawType = getClass(array.getGenericComponentType());
- return getArrayClass(componentRawType);
- }
- throw new IllegalArgumentException("Type parameter " + type.toString() + " not a class or " +
- "parameterized type whose raw type is a class");
- }
-
-
- private static Class getArrayClass(Class c) {
- try {
- Object o = Array.newInstance(c, 0);
- return o.getClass();
- } catch (Exception e) {
- throw new IllegalArgumentException(e);
- }
- }
-
-
- static Type getTypeArgument(Class<?> clazz, Class<?> baseClass) {
-
- Stack<Type> superclasses = new Stack<Type>();
- Type currentType;
- Class<?> currentClass = clazz;
- do {
- currentType = currentClass.getGenericSuperclass();
- superclasses.push(currentType);
- if (currentType instanceof Class) {
- currentClass = (Class) currentType;
- } else if (currentType instanceof ParameterizedType) {
- currentClass = (Class) ((ParameterizedType) currentType).getRawType();
- }
- } while (!currentClass.equals(baseClass));
-
-
- TypeVariable tv = baseClass.getTypeParameters()[0];
- while (!superclasses.isEmpty()) {
- currentType = superclasses.pop();
-
- if (currentType instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType) currentType;
- Class<?> rawType = (Class) pt.getRawType();
- int argIndex = Arrays.asList(rawType.getTypeParameters()).indexOf(tv);
- if (argIndex > -1) {
- Type typeArg = pt.getActualTypeArguments()[argIndex];
- if (typeArg instanceof TypeVariable) {
-
-
- tv = (TypeVariable) typeArg;
- continue;
- } else {
-
- return typeArg;
- }
- }
- }
-
-
- break;
- }
- throw new IllegalArgumentException(currentType + " does not specify the type parameter T of GenericType<T>");
- }
-
- @Override
- public boolean equals(Object obj) {
- boolean result = this == obj;
- if (!result && obj instanceof GenericType) {
-
- GenericType<?> that = (GenericType<?>) obj;
- return this.type.equals(that.type);
- }
- return result;
- }
-
- @Override
- public int hashCode() {
- return type.hashCode();
- }
-
- @Override
- public String toString() {
- return "GenericType{" + type.toString() + "}";
- }
-}
+/*
+ * #%L
+ * Apache Geronimo JAX-RS Spec 2.0
+ * %%
+ * Copyright (C) 2003 - 2014 The Apache Software Foundation
+ * %%
+ * 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.
+ * #L%
+ */
+
+package javax.ws.rs.core;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.util.Arrays;
+import java.util.Stack;
+
+public class GenericType<T> {
+
+ private final Type type;
+
+ private final Class<?> rawType;
+
+ public static GenericType forInstance(final Object instance) {
+ final GenericType genericType;
+ if (instance instanceof GenericEntity) {
+ genericType = new GenericType(((GenericEntity) instance).getType());
+ } else {
+ genericType = (instance == null) ? null : new GenericType(instance.getClass());
+ }
+ return genericType;
+ }
+
+ protected GenericType() {
+ // Get the type parameter of GenericType<T> (aka the T value)
+ type = getTypeArgument(getClass(), GenericType.class);
+ rawType = getClass(type);
+ }
+
+ public GenericType(Type genericType) {
+ if (genericType == null) {
+ throw new IllegalArgumentException("Type must not be null");
+ }
+
+ type = genericType;
+ rawType = getClass(type);
+ }
+
+ public final Type getType() {
+ return type;
+ }
+
+ public final Class<?> getRawType() {
+ return rawType;
+ }
+
+ private static Class getClass(Type type) {
+ if (type instanceof Class) {
+ return (Class) type;
+ } else if (type instanceof ParameterizedType) {
+ ParameterizedType parameterizedType = (ParameterizedType) type;
+ if (parameterizedType.getRawType() instanceof Class) {
+ return (Class) parameterizedType.getRawType();
+ }
+ } else if (type instanceof GenericArrayType) {
+ GenericArrayType array = (GenericArrayType) type;
+ final Class<?> componentRawType = getClass(array.getGenericComponentType());
+ return getArrayClass(componentRawType);
+ }
+ throw new IllegalArgumentException(
+ "Type parameter " + type.toString() + " not a class or " + "parameterized type whose raw type is a class");
+ }
+
+ private static Class getArrayClass(Class c) {
+ try {
+ Object o = Array.newInstance(c, 0);
+ return o.getClass();
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ static Type getTypeArgument(Class<?> clazz, Class<?> baseClass) {
+ // collect superclasses
+ Stack<Type> superclasses = new Stack<Type>();
+ Type currentType;
+ Class<?> currentClass = clazz;
+ do {
+ currentType = currentClass.getGenericSuperclass();
+ superclasses.push(currentType);
+ if (currentType instanceof Class) {
+ currentClass = (Class) currentType;
+ } else if (currentType instanceof ParameterizedType) {
+ currentClass = (Class) ((ParameterizedType) currentType).getRawType();
+ }
+ } while (!currentClass.equals(baseClass));
+
+ // find which one supplies type argument and return it
+ TypeVariable tv = baseClass.getTypeParameters()[0];
+ while (!superclasses.isEmpty()) {
+ currentType = superclasses.pop();
+
+ if (currentType instanceof ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType) currentType;
+ Class<?> rawType = (Class) pt.getRawType();
+ int argIndex = Arrays.asList(rawType.getTypeParameters()).indexOf(tv);
+ if (argIndex > -1) {
+ Type typeArg = pt.getActualTypeArguments()[argIndex];
+ if (typeArg instanceof TypeVariable) {
+ // type argument is another type variable - look for the value of that
+ // variable in subclasses
+ tv = (TypeVariable) typeArg;
+ continue;
+ } else {
+ // found the value - return it
+ return typeArg;
+ }
+ }
+ }
+
+ // needed type argument not supplied - break and throw exception
+ break;
+ }
+ throw new IllegalArgumentException(currentType + " does not specify the type parameter T of GenericType<T>");
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ boolean result = this == obj;
+ if (!result && obj instanceof GenericType) {
+ // Compare inner type for equality
+ GenericType<?> that = (GenericType<?>) obj;
+ return this.type.equals(that.type);
+ }
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ return type.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return "GenericType{" + type.toString() + "}";
+ }
+}
Modified: geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/HttpHeaders.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/HttpHeaders.java?rev=1818654&r1=1818653&r2=1818654&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/HttpHeaders.java (original)
+++ geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/HttpHeaders.java Tue Dec 19 11:39:13 2017
@@ -1,123 +1,113 @@
-/*
- * #%L
- * Apache Geronimo JAX-RS Spec 2.0
- * %%
- * Copyright (C) 2003 - 2014 The Apache Software Foundation
- * %%
- * 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.
- * #L%
- */
-
-package javax.ws.rs.core;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-
-public interface HttpHeaders {
-
-
- List<String> getRequestHeader(String name);
-
-
- String getHeaderString(String name);
-
-
- MultivaluedMap<String, String> getRequestHeaders();
-
-
- List<MediaType> getAcceptableMediaTypes();
-
-
- List<Locale> getAcceptableLanguages();
-
-
- MediaType getMediaType();
-
-
- Locale getLanguage();
-
-
- Map<String, Cookie> getCookies();
-
-
- Date getDate();
-
-
- int getLength();
-
-
- static final String ACCEPT = "Accept";
-
- static final String ACCEPT_CHARSET = "Accept-Charset";
-
- static final String ACCEPT_ENCODING = "Accept-Encoding";
-
- static final String ACCEPT_LANGUAGE = "Accept-Language";
-
- static final String ALLOW = "Allow";
-
- static final String AUTHORIZATION = "Authorization";
-
- static final String CACHE_CONTROL = "Cache-Control";
-
- static final String CONTENT_DISPOSITION = "Content-Disposition";
-
- static final String CONTENT_ENCODING = "Content-Encoding";
-
- static final String CONTENT_ID = "Content-ID";
-
- static final String CONTENT_LANGUAGE = "Content-Language";
-
- static final String CONTENT_LENGTH = "Content-Length";
-
- static final String CONTENT_LOCATION = "Content-Location";
-
- static final String CONTENT_TYPE = "Content-Type";
-
- static final String DATE = "Date";
-
- static final String ETAG = "ETag";
-
- static final String EXPIRES = "Expires";
-
- static final String HOST = "Host";
-
- static final String IF_MATCH = "If-Match";
-
- static final String IF_MODIFIED_SINCE = "If-Modified-Since";
-
- static final String IF_NONE_MATCH = "If-None-Match";
-
- static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since";
-
- static final String LAST_MODIFIED = "Last-Modified";
-
- static final String LOCATION = "Location";
-
- static final String LINK = "Link";
-
- static final String RETRY_AFTER = "Retry-After";
-
- static final String USER_AGENT = "User-Agent";
-
- static final String VARY = "Vary";
-
- static final String WWW_AUTHENTICATE = "WWW-Authenticate";
-
- static final String COOKIE = "Cookie";
-
- static final String SET_COOKIE = "Set-Cookie";
-}
+/*
+ * #%L
+ * Apache Geronimo JAX-RS Spec 2.0
+ * %%
+ * Copyright (C) 2003 - 2014 The Apache Software Foundation
+ * %%
+ * 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.
+ * #L%
+ */
+
+package javax.ws.rs.core;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+public interface HttpHeaders {
+
+ public List<String> getRequestHeader(String name);
+
+ public String getHeaderString(String name);
+
+ public MultivaluedMap<String, String> getRequestHeaders();
+
+ public List<MediaType> getAcceptableMediaTypes();
+
+ public List<Locale> getAcceptableLanguages();
+
+ public MediaType getMediaType();
+
+ public Locale getLanguage();
+
+ public Map<String, Cookie> getCookies();
+
+ public Date getDate();
+
+ public int getLength();
+
+ public static final String ACCEPT = "Accept";
+
+ public static final String ACCEPT_CHARSET = "Accept-Charset";
+
+ public static final String ACCEPT_ENCODING = "Accept-Encoding";
+
+ public static final String ACCEPT_LANGUAGE = "Accept-Language";
+
+ public static final String ALLOW = "Allow";
+
+ public static final String AUTHORIZATION = "Authorization";
+
+ public static final String CACHE_CONTROL = "Cache-Control";
+
+ public static final String CONTENT_DISPOSITION = "Content-Disposition";
+
+ public static final String CONTENT_ENCODING = "Content-Encoding";
+
+ public static final String CONTENT_ID = "Content-ID";
+
+ public static final String CONTENT_LANGUAGE = "Content-Language";
+
+ public static final String CONTENT_LENGTH = "Content-Length";
+
+ public static final String CONTENT_LOCATION = "Content-Location";
+
+ public static final String CONTENT_TYPE = "Content-Type";
+
+ public static final String DATE = "Date";
+
+ public static final String ETAG = "ETag";
+
+ public static final String EXPIRES = "Expires";
+
+ public static final String HOST = "Host";
+
+ public static final String IF_MATCH = "If-Match";
+
+ public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
+
+ public static final String IF_NONE_MATCH = "If-None-Match";
+
+ public static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since";
+
+ public static final String LAST_MODIFIED = "Last-Modified";
+
+ public static final String LOCATION = "Location";
+
+ public static final String LINK = "Link";
+
+ public static final String RETRY_AFTER = "Retry-After";
+
+ public static final String USER_AGENT = "User-Agent";
+
+ public static final String VARY = "Vary";
+
+ public static final String WWW_AUTHENTICATE = "WWW-Authenticate";
+
+ public static final String COOKIE = "Cookie";
+
+ public static final String SET_COOKIE = "Set-Cookie";
+
+ public static final String LAST_EVENT_ID_HEADER = "Last-Event-ID";
+}
Modified: geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Link.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Link.java?rev=1818654&r1=1818653&r2=1818654&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Link.java (original)
+++ geronimo/specs/trunk/geronimo-jaxrs_2.1_spec/src/main/java/javax/ws/rs/core/Link.java Tue Dec 19 11:39:13 2017
@@ -1,225 +1,228 @@
-/*
- * #%L
- * Apache Geronimo JAX-RS Spec 2.0
- * %%
- * Copyright (C) 2003 - 2014 The Apache Software Foundation
- * %%
- * 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.
- * #L%
- */
-
-package javax.ws.rs.core;
-
-import javax.ws.rs.ext.RuntimeDelegate;
-import javax.xml.bind.annotation.XmlAnyAttribute;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-import javax.xml.namespace.QName;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-
-public abstract class Link {
-
-
- public static final String TITLE = "title";
-
-
- public static final String REL = "rel";
-
-
- public static final String TYPE = "type";
-
-
- public abstract URI getUri();
-
-
- public abstract UriBuilder getUriBuilder();
-
-
- public abstract String getRel();
-
-
- public abstract List<String> getRels();
-
-
- public abstract String getTitle();
-
-
- public abstract String getType();
-
-
- public abstract Map<String, String> getParams();
-
-
- @Override
- public abstract String toString();
-
-
- public static Link valueOf(String value) {
- Builder b = RuntimeDelegate.getInstance().createLinkBuilder();
- b.link(value);
- return b.build();
- }
-
-
- public static Builder fromUri(URI uri) {
- Builder b = RuntimeDelegate.getInstance().createLinkBuilder();
- b.uri(uri);
- return b;
- }
-
-
- public static Builder fromUri(String uri) {
- Builder b = RuntimeDelegate.getInstance().createLinkBuilder();
- b.uri(uri);
- return b;
- }
-
-
- public static Builder fromUriBuilder(UriBuilder uriBuilder) {
- Builder b = RuntimeDelegate.getInstance().createLinkBuilder();
- b.uriBuilder(uriBuilder);
- return b;
- }
-
-
- public static Builder fromLink(Link link) {
- Builder b = RuntimeDelegate.getInstance().createLinkBuilder();
- b.link(link);
- return b;
- }
-
-
- public static Builder fromPath(String path) {
- return fromUriBuilder(UriBuilder.fromPath(path));
- }
-
-
- public static Builder fromResource(Class<?> resource) {
- return fromUriBuilder(UriBuilder.fromResource(resource));
- }
-
-
- public static Builder fromMethod(Class<?> resource, String method) {
- return fromUriBuilder(UriBuilder.fromMethod(resource, method));
- }
-
-
- public interface Builder {
-
-
- public Builder link(Link link);
-
-
- public Builder link(String link);
-
-
- public Builder uri(URI uri);
-
-
- public Builder uri(String uri);
-
-
- public Builder baseUri(URI uri);
-
-
- public Builder baseUri(String uri);
-
-
- public Builder uriBuilder(UriBuilder uriBuilder);
-
-
- public Builder rel(String rel);
-
-
- public Builder title(String title);
-
-
- public Builder type(String type);
-
-
- public Builder param(String name, String value);
-
-
- public Link build(Object... values);
-
-
- public Link buildRelativized(URI uri, Object... values);
- }
-
-
- public static class JaxbLink {
-
- private URI uri;
- private Map<QName, Object> params;
-
-
- public JaxbLink() {
- }
-
-
- public JaxbLink(URI uri) {
- this.uri = uri;
- }
-
-
- public JaxbLink(URI uri, Map<QName, Object> params) {
- this.uri = uri;
- this.params = params;
- }
-
-
- @XmlAttribute(name = "href")
- public URI getUri() {
- return uri;
- }
-
-
- @XmlAnyAttribute
- public Map<QName, Object> getParams() {
- if (params == null) {
- params = new HashMap<QName, Object>();
- }
- return params;
- }
- }
-
-
- public static class JaxbAdapter extends XmlAdapter<JaxbLink, Link> {
-
-
- @Override
- public Link unmarshal(JaxbLink v) {
- Link.Builder lb = Link.fromUri(v.getUri());
- for (Entry<QName, Object> e : v.getParams().entrySet()) {
- lb.param(e.getKey().getLocalPart(), e.getValue().toString());
- }
- return lb.build();
- }
-
-
- @Override
- public JaxbLink marshal(Link v) {
- JaxbLink jl = new JaxbLink(v.getUri());
- for (Entry<String, String> e : v.getParams().entrySet()) {
- final String name = e.getKey();
- jl.getParams().put(new QName("", name), e.getValue());
- }
- return jl;
- }
- }
-}
+/*
+ * #%L
+ * Apache Geronimo JAX-RS Spec 2.0
+ * %%
+ * Copyright (C) 2003 - 2014 The Apache Software Foundation
+ * %%
+ * 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.
+ * #L%
+ */
+
+package javax.ws.rs.core;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.ws.rs.ext.RuntimeDelegate;
+import javax.xml.bind.annotation.XmlAnyAttribute;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import javax.xml.namespace.QName;
+
+public abstract class Link {
+
+ public static final String TITLE = "title";
+
+ public static final String REL = "rel";
+
+ public static final String TYPE = "type";
+
+ public abstract URI getUri();
+
+ public abstract UriBuilder getUriBuilder();
+
+ public abstract String getRel();
+
+ public abstract List<String> getRels();
+
+ public abstract String getTitle();
+
+ public abstract String getType();
+
+ public abstract Map<String, String> getParams();
+
+ @Override
+ public abstract String toString();
+
+ public static Link valueOf(String value) {
+ Builder b = RuntimeDelegate.getInstance().createLinkBuilder();
+ b.link(value);
+ return b.build();
+ }
+
+ public static Builder fromUri(URI uri) {
+ Builder b = RuntimeDelegate.getInstance().createLinkBuilder();
+ b.uri(uri);
+ return b;
+ }
+
+ public static Builder fromUri(String uri) {
+ Builder b = RuntimeDelegate.getInstance().createLinkBuilder();
+ b.uri(uri);
+ return b;
+ }
+
+ public static Builder fromUriBuilder(UriBuilder uriBuilder) {
+ Builder b = RuntimeDelegate.getInstance().createLinkBuilder();
+ b.uriBuilder(uriBuilder);
+ return b;
+ }
+
+ public static Builder fromLink(Link link) {
+ Builder b = RuntimeDelegate.getInstance().createLinkBuilder();
+ b.link(link);
+ return b;
+ }
+
+ public static Builder fromPath(String path) {
+ return fromUriBuilder(UriBuilder.fromPath(path));
+ }
+
+ public static Builder fromResource(Class<?> resource) {
+ return fromUriBuilder(UriBuilder.fromResource(resource));
+ }
+
+ public static Builder fromMethod(Class<?> resource, String method) {
+ return fromUriBuilder(UriBuilder.fromMethod(resource, method));
+ }
+
+ public interface Builder {
+
+ public Builder link(Link link);
+
+ public Builder link(String link);
+
+ public Builder uri(URI uri);
+
+ public Builder uri(String uri);
+
+ public Builder baseUri(URI uri);
+
+ public Builder baseUri(String uri);
+
+ public Builder uriBuilder(UriBuilder uriBuilder);
+
+ public Builder rel(String rel);
+
+ public Builder title(String title);
+
+ public Builder type(String type);
+
+ public Builder param(String name, String value);
+
+ public Link build(Object... values);
+
+ public Link buildRelativized(URI uri, Object... values);
+ }
+
+ public static class JaxbLink {
+
+ private URI uri;
+
+ private Map<QName, Object> params;
+
+ public JaxbLink() {
+ }
+
+ public JaxbLink(URI uri) {
+ this.uri = uri;
+ }
+
+ public JaxbLink(URI uri, Map<QName, Object> params) {
+ this.uri = uri;
+ this.params = params;
+ }
+
+ @XmlAttribute(name = "href")
+ public URI getUri() {
+ return uri;
+ }
+
+ @XmlAnyAttribute
+ public Map<QName, Object> getParams() {
+ if (params == null) {
+ params = new HashMap<QName, Object>();
+ }
+ return params;
+ }
+
+ void setUri(URI uri) {
+ this.uri = uri;
+ }
+
+ void setParams(Map<QName, Object> params) {
+ this.params = params;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (!(o instanceof JaxbLink))
+ return false;
+
+ JaxbLink jaxbLink = (JaxbLink) o;
+
+ if (uri != null ? !uri.equals(jaxbLink.uri) : jaxbLink.uri != null) {
+ return false;
+ }
+
+ if (params == jaxbLink.params) {
+ return true;
+ }
+ if (params == null) {
+ // if this.params is 'null', consider other.params equal to empty
+ return jaxbLink.params.isEmpty();
+ }
+ if (jaxbLink.params == null) {
+ // if other.params is 'null', consider this.params equal to empty
+ return params.isEmpty();
+ }
+
+ return params.equals(jaxbLink.params);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = uri != null ? uri.hashCode() : 0;
+ result = 31 * result + (params != null && !params.isEmpty() ? params.hashCode() : 0);
+ return result;
+ }
+
+ }
+
+ public static class JaxbAdapter extends XmlAdapter<JaxbLink, Link> {
+
+ @Override
+ public Link unmarshal(JaxbLink v) {
+ Link.Builder lb = Link.fromUri(v.getUri());
+ for (Entry<QName, Object> e : v.getParams().entrySet()) {
+ lb.param(e.getKey().getLocalPart(), e.getValue().toString());
+ }
+ return lb.build();
+ }
+
+ @Override
+ public JaxbLink marshal(Link v) {
+ JaxbLink jl = new JaxbLink(v.getUri());
+ for (Entry<String, String> e : v.getParams().entrySet()) {
+ final String name = e.getKey();
+ jl.getParams().put(new QName("", name), e.getValue());
+ }
+ return jl;
+ }
+ }
+}