@Override public String toString() { StringBuilder sb = new StringBuilder("PrivilegeBits: "); if (d.isSimple()) { sb.append(d.longValue()); } else { sb.append(Arrays.toString(d.longValues())); } return sb.toString(); }
@Override public String toString() { StringBuilder sb = new StringBuilder("PrivilegeBits: "); if (d.isSimple()) { sb.append(d.longValue()); } else { sb.append(Arrays.toString(d.longValues())); } return sb.toString(); }
@NotNull public PropertyState asPropertyState(String name) { return PropertyStates.createProperty(name, Longs.asList(d.longValues()), Type.LONGS); }
private void retain(Data other) { if (isSimple()) { bits[0] &= other.longValue(); } else { long[] lvs = longValues(); long[] bLvs = other.longValues(); long[] res = (lvs.length <= bLvs.length) ? new long[lvs.length] : new long[bLvs.length]; int compactSize = -1; for (int i = 0; i < res.length; i++) { res[i] = (lvs[i] & bLvs[i]); if (res[i] == 0) { if (compactSize == -1) { compactSize = i+1; } } else { compactSize = -1; } } if (compactSize != -1 && res.length > compactSize) { bits = Arrays.copyOfRange(res, 0, compactSize); } else { bits = res; } } }
private void retain(Data other) { if (isSimple()) { bits[0] &= other.longValue(); } else { long[] lvs = longValues(); long[] bLvs = other.longValues(); long[] res = (lvs.length <= bLvs.length) ? new long[lvs.length] : new long[bLvs.length]; int compactSize = -1; for (int i = 0; i < res.length; i++) { res[i] = (lvs[i] & bLvs[i]); if (res[i] == 0) { if (compactSize == -1) { compactSize = i+1; } } else { compactSize = -1; } } if (compactSize != -1 && res.length > compactSize) { bits = Arrays.copyOfRange(res, 0, compactSize); } else { bits = res; } } }
/** * Returns an unmodifiable instance. * * @return an unmodifiable {@code PrivilegeBits} instance. */ @Nonnull public PrivilegeBits unmodifiable() { if (d instanceof ModifiableData) { if (d.isSimple()) { return getInstance(d.longValue()); } else { long[] bits = d.longValues(); long[] copy = new long[bits.length]; System.arraycopy(bits, 0, copy, 0, bits.length); return getInstance(copy); } } else { return this; } }
/** * Returns an unmodifiable instance. * * @return an unmodifiable {@code PrivilegeBits} instance. */ @NotNull public PrivilegeBits unmodifiable() { if (d instanceof ModifiableData) { if (d.isSimple()) { return getInstance(d.longValue()); } else { long[] bits = d.longValues(); long[] copy = new long[bits.length]; System.arraycopy(bits, 0, copy, 0, bits.length); return getInstance(copy); } } else { return this; } }
/** * Add the diff between the specified Data a and b. * * @param a * @param b */ private void addDifference(Data a, Data b) { if (a.isSimple() && b.isSimple()) { bits[0] |= a.longValue() & ~b.longValue(); } else { long[] diff = diff(a.longValues(), b.longValues()); or(diff); } }
/** * Add the other Data to this instance. * * @param other */ private void add(Data other) { if (other != this) { if (bits.length == 1 && other.isSimple()) { bits[0] |= other.longValue(); } else { or(other.longValues()); } } }
/** * Add the diff between the specified Data a and b. * * @param a * @param b */ private void addDifference(Data a, Data b) { if (a.isSimple() && b.isSimple()) { bits[0] |= a.longValue() & ~b.longValue(); } else { long[] diff = diff(a.longValues(), b.longValues()); or(diff); } }
@Nonnull public PropertyState asPropertyState(String name) { return PropertyStates.createProperty(name, Longs.asList(d.longValues()), Type.LONGS); }
/** * Add the other Data to this instance. * * @param other */ private void add(Data other) { if (other != this) { if (bits.length == 1 && other.isSimple()) { bits[0] |= other.longValue(); } else { or(other.longValues()); } } }
@Override boolean includes(Data other) { if (bits.length == 1) { return other.isSimple() && includes(bits[0], other.longValue()); } else { return includes(bits, other.longValues()); } }
@Override boolean includes(Data other) { if (isSimple) { return (other.isSimple()) && includes(bits, other.longValue()); } else { return includes(bitsArr, other.longValues()); } }
/** * Subtract the other Data from this instance. * * @param other */ private void diff(Data other) { if (bits.length == 1 && other.isSimple()) { bits[0] = bits[0] & ~other.longValue(); } else { bits = diff(bits, other.longValues()); } }
/** * Subtract the other Data from this instance. * * @param other */ private void diff(Data other) { if (bits.length == 1 && other.isSimple()) { bits[0] = bits[0] & ~other.longValue(); } else { bits = diff(bits, other.longValues()); } }
@Override boolean includes(Data other) { if (bits.length == 1) { return other.isSimple() && includes(bits[0], other.longValue()); } else { return includes(bits, other.longValues()); } }
@Override boolean includes(Data other) { if (isSimple) { return (other.isSimple()) && includes(bits, other.longValue()); } else { return includes(bitsArr, other.longValues()); } }