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. This class is immutable. 011 * 012 * @author Vladimir Dzhuvinov 013 */ 014@Immutable 015public final class Resource { 016 017 018 /** 019 * The content. 020 */ 021 private final String content; 022 023 024 /** 025 * The content type. 026 */ 027 private final ContentType contentType; 028 029 030 /** 031 * Creates a new resource with optional associated content type. 032 * 033 * @param content The resource content, empty string if none. Must 034 * not be {@code null}. 035 * @param contentType The resource content type, {@code null} if not 036 * specified. 037 */ 038 public Resource(final String content, final ContentType contentType) { 039 040 if (content == null) 041 throw new IllegalArgumentException("The resource content must not be null"); 042 043 this.content = content; 044 045 this.contentType = contentType; 046 } 047 048 049 /** 050 * Gets the content of this resource. 051 * 052 * @return The content, empty string if none. 053 */ 054 public String getContent() { 055 056 return content; 057 } 058 059 060 /** 061 * Gets the content type of this resource. 062 * 063 * @return The content type, {@code null} if not specified. 064 */ 065 public ContentType getContentType() { 066 067 return contentType; 068 } 069}