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