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 023import java.util.Objects; 024 025 026/** 027 * Resource with optional associated content type. 028 */ 029@Immutable 030public class Resource { 031 032 033 /** 034 * The content. 035 */ 036 private final String content; 037 038 039 /** 040 * The content type. 041 */ 042 private final String contentType; 043 044 045 /** 046 * Creates a new resource with optional associated content type. 047 * 048 * @param content The resource content, empty string if none. Must 049 * not be {@code null}. 050 * @param contentType The resource content type, {@code null} if not 051 * specified. 052 */ 053 public Resource(final String content, final String contentType) { 054 055 this.content = Objects.requireNonNull(content); 056 this.contentType = contentType; 057 } 058 059 060 /** 061 * Gets the content of this resource. 062 * 063 * @return The content, empty string if none. 064 */ 065 public String getContent() { 066 067 return content; 068 } 069 070 071 /** 072 * Gets the content type of this resource. 073 * 074 * @return The content type, {@code null} if not specified. 075 */ 076 public String getContentType() { 077 078 return contentType; 079 } 080}