001package com.nimbusds.oauth2.sdk.id; 002 003 004import java.net.URI; 005import java.util.ArrayList; 006import java.util.List; 007 008import net.jcip.annotations.Immutable; 009 010 011/** 012 * Audience identifier. 013 */ 014@Immutable 015public final class Audience extends Identifier { 016 017 018 /** 019 * Creates a new audience identifier with the specified value. 020 * 021 * @param value The audience identifier value. Must not be {@code null} 022 * or empty string. 023 */ 024 public Audience(final String value) { 025 026 super(value); 027 } 028 029 030 /** 031 * Creates a new audience identifier with the specified URI value. 032 * 033 * @param value The URI value. Must not be {@code null}. 034 */ 035 public Audience(final URI value) { 036 037 super(value.toString()); 038 } 039 040 041 /** 042 * Creates a new audience identifier with the specified value. 043 * 044 * @param value The value. Must not be {@code null}. 045 */ 046 public Audience(final Identifier value) { 047 048 super(value.getValue()); 049 } 050 051 052 /** 053 * Returns a list consisting of this audience only. 054 * 055 * @return A list consisting of this audience only. 056 */ 057 public List<Audience> toSingleAudienceList() { 058 059 List<Audience> audienceList = new ArrayList<>(1); 060 audienceList.add(this); 061 return audienceList; 062 } 063 064 065 @Override 066 public boolean equals(final Object object) { 067 068 return object instanceof Audience && 069 this.toString().equals(object.toString()); 070 } 071}