Created
April 24, 2018 21:54
-
-
Save claudemartin/7f7da857c4530050be55917e44caafca to your computer and use it in GitHub Desktop.
Configurable bit position per enum [Example]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ch.claude_martin.enumbitset; | |
import static java.util.Arrays.asList; | |
import java.util.stream.Collectors; | |
public class Main { | |
enum Bla implements EnumBitSetHelper<Bla> { | |
A(-1), B(42), C(108); | |
final int i; | |
private Bla(int i) { | |
this.i = i; | |
} | |
public int toInt() { | |
return this.i; | |
} | |
} | |
public static void main(String[] args) { | |
var set = GeneralDomainBitSet.of(EnumDomain.of(Bla.class), asList(Bla.A)); | |
set.add(Bla.C); | |
var list = set.stream().map(Bla::toInt).collect(Collectors.toList()); | |
System.out.println(list); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment