You can hash the string, like hashCode()
, which is available on any object and it returns an int
. Basically, the int
is a simple number which needs less storage space and has higher performance. However, the calculation of a hash needs some time.
I say "like", because you can't actually use that method. The method is not guaranteed to return the same result for different executions of the application, so you must not store it in a database.
But there are hash functions that guarantee the same result, e.g. simple ones like MD5. (How can I generate an MD5 hash?)
However, note that a hash is a one-way conversion. If, for whatever reason (possible an unknown reason at this point in time), you need the type as the name again, there's no way to do that.