001package com.nimbusds.openid.connect.sdk.util;
002
003
004import javax.mail.internet.ContentType;
005
006import net.jcip.annotations.Immutable;
007
008
009/**
010 * Resource with optional associated content type.
011 */
012@Immutable
013public class Resource {
014
015
016        /**
017         * The content.
018         */
019        private final String content;
020
021
022        /**
023         * The content type.
024         */
025        private final ContentType contentType;
026
027
028        /**
029         * Creates a new resource with optional associated content type.
030         *
031         * @param content     The resource content, empty string if none. Must 
032         *                    not be {@code null}.
033         * @param contentType The resource content type, {@code null} if not
034         *                    specified.
035         */
036        public Resource(final String content, final ContentType contentType) {
037
038                if (content == null)
039                        throw new IllegalArgumentException("The resource content must not be null");
040
041                this.content = content;
042
043                this.contentType = contentType;
044        }
045
046
047        /**
048         * Gets the content of this resource.
049         *
050         * @return The content, empty string if none.
051         */
052        public String getContent() {
053
054                return content;
055        }
056
057
058        /**
059         * Gets the content type of this resource.
060         *
061         * @return The content type, {@code null} if not specified.
062         */
063        public ContentType getContentType() {
064
065                return contentType;
066        }
067}