public List<ScanFilterData> createScanFilterDataForBeaconParser(BeaconParser beaconParser, List<Identifier> identifiers) {
        ArrayList<ScanFilterData> scanFilters = new ArrayList<ScanFilterData>();
        long typeCode = beaconParser.getMatchingBeaconTypeCode();
        int startOffset = beaconParser.getMatchingBeaconTypeCodeStartOffset();
        int endOffset = beaconParser.getMatchingBeaconTypeCodeEndOffset();
        byte[] typeCodeBytes = BeaconParser.longToByteArray(typeCode, endOffset-startOffset+1);
        if (identifiers != null && identifiers.size() > 0 && identifiers.get(0) != null && beaconParser.getMatchingBeaconTypeCode() == 0x0215) {
            // If type code 0215 ibeacon, we allow also adding identifiers to the filter
            for (int manufacturer : beaconParser.getHardwareAssistManufacturers()) {
                ScanFilterData sfd = new ScanFilterData();
                sfd.manufacturer = manufacturer;
                int length = 18;
                if (identifiers.size() == 2) {
                    length = 20;
                }
                if (identifiers.size() == 3) {
                    length = 22;
                }
                sfd.filter = new byte[length];
                sfd.filter[0] = typeCodeBytes[0];
                sfd.filter[1] = typeCodeBytes[1];
                byte[] idBytes = identifiers.get(0).toByteArray();
                for (int i = 0; i < idBytes.length; i++) {
                    sfd.filter[i+2] = idBytes[i];
                }
                if (identifiers.size() > 1 && identifiers.get(1) != null) {
                    idBytes = identifiers.get(1).toByteArray();
                    for (int i = 0; i < idBytes.length; i++) {
                        sfd.filter[i+18] = idBytes[i];
                    }
                }
                if (identifiers.size() > 2  && identifiers.get(2) != null) {
                    idBytes = identifiers.get(2).toByteArray();
                    for (int i = 0; i < idBytes.length; i++) {
                        sfd.filter[i+20] = idBytes[i];
                    }
                }
                sfd.mask = new byte[length];
                for (int i = 0 ; i < length; i++) {
                    sfd.mask[i] = (byte) 0xff;
                }
                sfd.serviceUuid = null;
                sfd.serviceUuid128Bit = new byte[0];
                scanFilters.add(sfd);
                return scanFilters;
            }
        }
        for (int manufacturer : beaconParser.getHardwareAssistManufacturers()) {
            ScanFilterData sfd = new ScanFilterData();
            Long serviceUuid = beaconParser.getServiceUuid();

            // Note: the -2 here is because we want the filter and mask to start after the
            // two-byte manufacturer code, and the beacon parser expression is based on offsets
            // from the start of the two byte code
            int length = endOffset + 1 - 2;
            byte[] filter = new byte[0];
            byte[] mask = new byte[0];
            if (length > 0) {
                filter = new byte[length];
                mask = new byte[length];
                for (int layoutIndex = 2; layoutIndex <= endOffset; layoutIndex++) {
                    int filterIndex = layoutIndex-2;
                    if (layoutIndex < startOffset) {
                        filter[filterIndex] = 0;
                        mask[filterIndex] = 0;
                    } else {
                        filter[filterIndex] = typeCodeBytes[layoutIndex-startOffset];
                        mask[filterIndex] = (byte) 0xff;
                    }
                }
            }
            sfd.manufacturer = manufacturer;
            sfd.filter = filter;
            sfd.mask = mask;
            sfd.serviceUuid = serviceUuid;
            sfd.serviceUuid128Bit = beaconParser.getServiceUuid128Bit();
            scanFilters.add(sfd);

        }
        return scanFilters;
    }
@Test
    public void testEddystoneScanFilterData() throws Exception {
        org.robolectric.shadows.ShadowLog.stream = System.err;
        BeaconParser parser = new BeaconParser();
        parser.setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT);
        BeaconManager.setManifestCheckingDisabled(true); // no manifest available in robolectric
        List<ScanFilterUtils.ScanFilterData> scanFilterDatas = new ScanFilterUtils().createScanFilterDataForBeaconParser(parser, null);
        assertEquals("scanFilters should be of correct size", 1, scanFilterDatas.size());
        ScanFilterUtils.ScanFilterData sfd = scanFilterDatas.get(0);
        assertEquals("serviceUuid should be right", new Long(0xfeaa), sfd.serviceUuid);
    }