/** * Returns the default content type for the given type. Called when {@link #write} * is invoked without a specified content type parameter. * <p>By default, this returns the first element of the * {@link #setSupportedMediaTypes(List) supportedMediaTypes} property, if any. * Can be overridden in subclasses. * @param t the type to return the content type for * @return the content type, or {@code null} if not known */ @Nullable protected MediaType getDefaultContentType(T t) throws IOException { List<MediaType> mediaTypes = getSupportedMediaTypes(); return (!mediaTypes.isEmpty() ? mediaTypes.get(0) : null); }
/** * Returns {@code true} if any of the {@linkplain #setSupportedMediaTypes(List) * supported} media types {@link MediaType#includes(MediaType) include} the * given media type. * @param mediaType the media type to read, can be {@code null} if not specified. * Typically the value of a {@code Content-Type} header. * @return {@code true} if the supported media types include the media type, * or if the media type is {@code null} */ protected boolean canRead(@Nullable MediaType mediaType) { if (mediaType == null) { return true; } for (MediaType supportedMediaType : getSupportedMediaTypes()) { if (supportedMediaType.includes(mediaType)) { return true; } } return false; }
/** * Returns the default content type for the given type. Called when {@link #write} * is invoked without a specified content type parameter. * <p>By default, this returns the first element of the * {@link #setSupportedMediaTypes(List) supportedMediaTypes} property, if any. * Can be overridden in subclasses. * @param t the type to return the content type for * @return the content type, or {@code null} if not known */ @Nullable protected MediaType getDefaultContentType(T t) throws IOException { List<MediaType> mediaTypes = getSupportedMediaTypes(); return (!mediaTypes.isEmpty() ? mediaTypes.get(0) : null); }
/** * Returns {@code true} if the given media type includes any of the * {@linkplain #setSupportedMediaTypes(List) supported media types}. * @param mediaType the media type to write, can be {@code null} if not specified. * Typically the value of an {@code Accept} header. * @return {@code true} if the supported media types are compatible with the media type, * or if the media type is {@code null} */ protected boolean canWrite(@Nullable MediaType mediaType) { if (mediaType == null || MediaType.ALL.equalsTypeAndSubtype(mediaType)) { return true; } for (MediaType supportedMediaType : getSupportedMediaTypes()) { if (supportedMediaType.isCompatibleWith(mediaType)) { return true; } } return false; }
/** * Returns {@code true} if any of the {@linkplain #setSupportedMediaTypes(List) * supported} media types {@link MediaType#includes(MediaType) include} the * given media type. * @param mediaType the media type to read, can be {@code null} if not specified. * Typically the value of a {@code Content-Type} header. * @return {@code true} if the supported media types include the media type, * or if the media type is {@code null} */ protected boolean canRead(@Nullable MediaType mediaType) { if (mediaType == null) { return true; } for (MediaType supportedMediaType : getSupportedMediaTypes()) { if (supportedMediaType.includes(mediaType)) { return true; } } return false; }
/** * Returns {@code true} if the given media type includes any of the * {@linkplain #setSupportedMediaTypes(List) supported media types}. * @param mediaType the media type to write, can be {@code null} if not specified. * Typically the value of an {@code Accept} header. * @return {@code true} if the supported media types are compatible with the media type, * or if the media type is {@code null} */ protected boolean canWrite(@Nullable MediaType mediaType) { if (mediaType == null || MediaType.ALL.equalsTypeAndSubtype(mediaType)) { return true; } for (MediaType supportedMediaType : getSupportedMediaTypes()) { if (supportedMediaType.isCompatibleWith(mediaType)) { return true; } } return false; }
/** * Returns the default content type for the given type. Called when {@link #write} * is invoked without a specified content type parameter. * <p>By default, this returns the first element of the * {@link #setSupportedMediaTypes(List) supportedMediaTypes} property, if any. * Can be overridden in subclasses. * @param t the type to return the content type for * @return the content type, or <code>null</code> if not known */ protected MediaType getDefaultContentType(T t) throws IOException { List<MediaType> mediaTypes = getSupportedMediaTypes(); return (!mediaTypes.isEmpty() ? mediaTypes.get(0) : null); }
/** * Returns the default content type for the given type. Called when {@link #write} * is invoked without a specified content type parameter. * <p>By default, this returns the first element of the * {@link #setSupportedMediaTypes(List) supportedMediaTypes} property, if any. * Can be overridden in subclasses. * @param t the type to return the content type for * @return the content type, or {@code null} if not known */ @Nullable protected MediaType getDefaultContentType(T t) throws IOException { List<MediaType> mediaTypes = getSupportedMediaTypes(); return (!mediaTypes.isEmpty() ? mediaTypes.get(0) : null); }
/** * Returns the default content type for the given type. Called when {@link #write} * is invoked without a specified content type parameter. * <p>By default, this returns the first element of the * {@link #setSupportedMediaTypes(List) supportedMediaTypes} property, if any. * Can be overridden in subclasses. * @param t the type to return the content type for * @return the content type, or {@code null} if not known */ @Nullable protected MediaType getDefaultContentType(T t) throws IOException { List<MediaType> mediaTypes = getSupportedMediaTypes(); return (!mediaTypes.isEmpty() ? mediaTypes.get(0) : null); }
/** * Returns {@code true} if any of the {@linkplain #setSupportedMediaTypes(List) * supported} media types {@link MediaType#includes(MediaType) include} the * given media type. * @param mediaType the media type to read, can be {@code null} if not specified. * Typically the value of a {@code Content-Type} header. * @return {@code true} if the supported media types include the media type, * or if the media type is {@code null} */ protected boolean canRead(@Nullable MediaType mediaType) { if (mediaType == null) { return true; } for (MediaType supportedMediaType : getSupportedMediaTypes()) { if (supportedMediaType.includes(mediaType)) { return true; } } return false; }
/** * Returns {@code true} if any of the {@linkplain #setSupportedMediaTypes(List) * supported} media types {@link MediaType#includes(MediaType) include} the * given media type. * @param mediaType the media type to read, can be {@code null} if not specified. * Typically the value of a {@code Content-Type} header. * @return {@code true} if the supported media types include the media type, * or if the media type is {@code null} */ protected boolean canRead(@Nullable MediaType mediaType) { if (mediaType == null) { return true; } for (MediaType supportedMediaType : getSupportedMediaTypes()) { if (supportedMediaType.includes(mediaType)) { return true; } } return false; }
/** * Returns true if any of the {@linkplain #setSupportedMediaTypes(List) supported media types} * include the given media type. * @param mediaType the media type to read, can be {@code null} if not specified. * Typically the value of a {@code Content-Type} header. * @return true if the supported media types include the media type, * or if the media type is {@code null} */ protected boolean canRead(MediaType mediaType) { if (mediaType == null) { return true; } for (MediaType supportedMediaType : getSupportedMediaTypes()) { if (supportedMediaType.includes(mediaType)) { return true; } } return false; }
/** * Returns {@code true} if the given media type includes any of the * {@linkplain #setSupportedMediaTypes(List) supported media types}. * @param mediaType the media type to write, can be {@code null} if not specified. * Typically the value of an {@code Accept} header. * @return {@code true} if the supported media types are compatible with the media type, * or if the media type is {@code null} */ protected boolean canWrite(@Nullable MediaType mediaType) { if (mediaType == null || MediaType.ALL.equals(mediaType)) { return true; } for (MediaType supportedMediaType : getSupportedMediaTypes()) { if (supportedMediaType.isCompatibleWith(mediaType)) { return true; } } return false; }
/** * Returns {@code true} if the given media type includes any of the * {@linkplain #setSupportedMediaTypes(List) supported media types}. * @param mediaType the media type to write, can be {@code null} if not specified. * Typically the value of an {@code Accept} header. * @return {@code true} if the supported media types are compatible with the media type, * or if the media type is {@code null} */ protected boolean canWrite(@Nullable MediaType mediaType) { if (mediaType == null || MediaType.ALL.equals(mediaType)) { return true; } for (MediaType supportedMediaType : getSupportedMediaTypes()) { if (supportedMediaType.isCompatibleWith(mediaType)) { return true; } } return false; }
/** * Returns true if the given media type includes any of the * {@linkplain #setSupportedMediaTypes(List) supported media types}. * @param mediaType the media type to write, can be {@code null} if not specified. * Typically the value of an {@code Accept} header. * @return true if the supported media types are compatible with the media type, * or if the media type is {@code null} */ protected boolean canWrite(MediaType mediaType) { if (mediaType == null || MediaType.ALL.equals(mediaType)) { return true; } for (MediaType supportedMediaType : getSupportedMediaTypes()) { if (supportedMediaType.isCompatibleWith(mediaType)) { return true; } } return false; }