001/*
002 * nimbus-jose-jwt
003 *
004 * Copyright 2012-2016, Connect2id Ltd.
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use
007 * this file except in compliance with the License. You may obtain a copy of the
008 * License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software distributed
013 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
014 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
015 * specific language governing permissions and limitations under the License.
016 */
017
018package com.nimbusds.jose.util;
019
020
021import net.jcip.annotations.Immutable;
022
023
024/**
025 * Resource with optional associated content type.
026 */
027@Immutable
028public class Resource {
029
030
031        /**
032         * The content.
033         */
034        private final String content;
035
036
037        /**
038         * The content type.
039         */
040        private final String contentType;
041
042
043        /**
044         * Creates a new resource with optional associated content type.
045         *
046         * @param content     The resource content, empty string if none. Must 
047         *                    not be {@code null}.
048         * @param contentType The resource content type, {@code null} if not
049         *                    specified.
050         */
051        public Resource(final String content, final String contentType) {
052
053                if (content == null) {
054                        throw new IllegalArgumentException("The resource content must not be null");
055                }
056
057                this.content = content;
058                this.contentType = contentType;
059        }
060
061
062        /**
063         * Gets the content of this resource.
064         *
065         * @return The content, empty string if none.
066         */
067        public String getContent() {
068
069                return content;
070        }
071
072
073        /**
074         * Gets the content type of this resource.
075         *
076         * @return The content type, {@code null} if not specified.
077         */
078        public String getContentType() {
079
080                return contentType;
081        }
082}