001package com.nimbusds.oauth2.sdk.token; 002 003 004import net.jcip.annotations.Immutable; 005import net.minidev.json.JSONObject; 006 007import java.util.Objects; 008import java.util.Set; 009 010 011/** 012 * Typeless (generic) token. 013 */ 014@Immutable 015public class TypelessToken extends Token { 016 017 018 private static final long serialVersionUID = 1477117093355749547L; 019 020 021 /** 022 * Creates a new typeless token with the specified value. 023 * 024 * @param value The token value. Must not be {@code null} or empty 025 * string. 026 */ 027 public TypelessToken(final String value) { 028 super(value); 029 } 030 031 032 @Override 033 public Set<String> getParameterNames() { 034 return getCustomParameters().keySet(); 035 } 036 037 038 @Override 039 public JSONObject toJSONObject() { 040 JSONObject jsonObject = new JSONObject(); 041 jsonObject.putAll(getCustomParameters()); 042 return jsonObject; 043 } 044 045 046 @Override 047 public boolean equals(final Object other) { 048 049 return other instanceof Token && other.toString().equals(getValue()); 050 } 051 052 @Override 053 public int hashCode() { 054 return Objects.hashCode(getValue()); 055 } 056}