Java

자바 EnumBitSet 사용하기

[하마] 이승현 (wowlsh93@gmail.com) 2015. 9. 1. 11:50

http://claude-martin.ch/enumbitset/  참조 (라이브러리 여기있음)


Project EnumBitSet

This is the project home for EnumBitSet. It's a small project offering more functionality with enum types in Java.

Java 8 is needed to use any of the code!!

Is EnumBitSet the right thing for you?

Do you know this situation: You have created some enum types in Java and now you want to use them but you don't know how to store them in a database? Hibernate and JPA can help you but ORM isn't always the best approach. Maybe you just want to have more control on how the data is stored to the database. 
EnumBitSet can help you working with sets of enum constants and storing those sets in one single database field. Just use the method toLong() if you are sure that there are not more than 64 elements in the enum type. Or use toBigInteger() for enum types of any size. 
This library also offers a more general interface to bit sets that are restricted by a domain (universe). Three implementations exist:

  • EnumBitSet (for enum types, mutable)
  • GeneralDomainBitSet (for all types, mutable)
  • SmallDomainBitSet (for up to 64 elements of any type, immutable)