Realize the subscription of different messages
<p>I have many kinds of messages to be sent and the user can subscribe to some of them.</p>

<p>I plan to use binary and &amp; set operation to decide whether messages to be sent.</p>

<p>for example: </p>

<p>there are three messages: message A message B and message C</p>

<p>if someone subscribe all of them, the binary number is 111 for this user. Now a message A will be sent(100) and  I will use this number(100) &amp; 111. if I don`t get a zero, I will send it to the use.</p>

<pre><code>public class TestBinary {

    static final int USER_DEFINED_NUM = 7; // 111
    static final int REQUEST_NUM = 8;      //1000

    public static void main(String[] args) {
       boolean result = (USER_DEFINED_NUM &amp; REQUEST_NUM) != 0;
       if(result) {
           System.out.println("send");
       } else {
           System.out.println("not send");
       }
    }
}
</code></pre>

<p>This method will fail, if there are more than 32 kinds of messages, because the int type can only represent 32 message types.</p>

<p>Do you have better way? thanks:)</p>
