public boolean hasFlag(int flags, int flag) {
        System.out.println("Total flags: " + Integer.toBinaryString(flags) + " " + Integer.toBinaryString(flag) + " " + flag);
        boolean hasFlag = false;
        boolean finished = false;
        int waarde = 2048;
        int newFlag = flags;
        while (!finished) {
            System.out.println("Waarde: " + waarde + " newFlag " + newFlag);
            newFlag -= waarde;
            if (waarde < flag) {
                finished = true;
            } else {
                if (newFlag <= 0) {
                    if (waarde == 1) {
                        finished = true;
                    }
                    newFlag = flags;
                    waarde /= 2;
                } else if (flag == newFlag) {
                    hasFlag = true;
                    finished = true;
                } else {
                    flags = newFlag;
                    if (waarde == flag) {
                        hasFlag = true;
                        finished = true;
                    } else {
                        waarde /= 2;
                    }
                }
            }
        }
        System.out.println(hasFlag);
        return hasFlag;
    }