public ByteArrayComparable build() { ByteArrayComparable comparator; switch (ComparatorType.valueOf(type)) { case BinaryComparator: comparator = new BinaryComparator(Base64.getDecoder().decode(value)); break; case BinaryPrefixComparator: comparator = new BinaryPrefixComparator(Base64.getDecoder().decode(value)); break; case BitComparator: comparator = new BitComparator(Base64.getDecoder().decode(value), BitComparator.BitwiseOp.valueOf(op)); break; case NullComparator: comparator = new NullComparator(); break; case RegexStringComparator: comparator = new RegexStringComparator(value); break; case SubstringComparator: comparator = new SubstringComparator(value); break; default: throw new RuntimeException("unhandled comparator type: " + type); } return comparator; }
public ByteArrayComparableModel( ByteArrayComparable comparator) { String typeName = comparator.getClass().getSimpleName(); ComparatorType type = ComparatorType.valueOf(typeName); this.type = typeName; switch (type) { case BinaryComparator: case BinaryPrefixComparator: this.value = Bytes.toString(Base64.getEncoder().encode(comparator.getValue())); break; case BitComparator: this.value = Bytes.toString(Base64.getEncoder().encode(comparator.getValue())); this.op = ((BitComparator)comparator).getOperator().toString(); break; case NullComparator: break; case RegexStringComparator: case SubstringComparator: this.value = Bytes.toString(comparator.getValue()); break; default: throw new RuntimeException("unhandled filter type: " + type); } }
public ByteArrayComparable build() { ByteArrayComparable comparator; switch (ComparatorType.valueOf(type)) { case BinaryComparator: comparator = new BinaryComparator(Base64.decode(value)); break; case BinaryPrefixComparator: comparator = new BinaryPrefixComparator(Base64.decode(value)); break; case BitComparator: comparator = new BitComparator(Base64.decode(value), BitComparator.BitwiseOp.valueOf(op)); break; case NullComparator: comparator = new NullComparator(); break; case RegexStringComparator: comparator = new RegexStringComparator(value); break; case SubstringComparator: comparator = new SubstringComparator(value); break; default: throw new RuntimeException("unhandled comparator type: " + type); } return comparator; }
public ByteArrayComparable build() { ByteArrayComparable comparator; switch (ComparatorType.valueOf(type)) { case BinaryComparator: comparator = new BinaryComparator(Base64.getDecoder().decode(value)); break; case BinaryPrefixComparator: comparator = new BinaryPrefixComparator(Base64.getDecoder().decode(value)); break; case BitComparator: comparator = new BitComparator(Base64.getDecoder().decode(value), BitComparator.BitwiseOp.valueOf(op)); break; case NullComparator: comparator = new NullComparator(); break; case RegexStringComparator: comparator = new RegexStringComparator(value); break; case SubstringComparator: comparator = new SubstringComparator(value); break; default: throw new RuntimeException("unhandled comparator type: " + type); } return comparator; }
public WritableByteArrayComparable build() { WritableByteArrayComparable comparator; switch (ComparatorType.valueOf(type)) { case BinaryComparator: comparator = new BinaryComparator(Base64.decode(value)); break; case BinaryPrefixComparator: comparator = new BinaryPrefixComparator(Base64.decode(value)); break; case BitComparator: comparator = new BitComparator(Base64.decode(value), BitComparator.BitwiseOp.valueOf(op)); break; case NullComparator: comparator = new NullComparator(); break; case RegexStringComparator: comparator = new RegexStringComparator(value); break; case SubstringComparator: comparator = new SubstringComparator(value); break; default: throw new RuntimeException("unhandled comparator type: " + type); } return comparator; }
public ByteArrayComparableModel( ByteArrayComparable comparator) { String typeName = comparator.getClass().getSimpleName(); ComparatorType type = ComparatorType.valueOf(typeName); this.type = typeName; switch (type) { case BinaryComparator: case BinaryPrefixComparator: this.value = Base64.encodeBytes(comparator.getValue()); break; case BitComparator: this.value = Base64.encodeBytes(comparator.getValue()); this.op = ((BitComparator)comparator).getOperator().toString(); break; case NullComparator: break; case RegexStringComparator: case SubstringComparator: this.value = Bytes.toString(comparator.getValue()); break; default: throw new RuntimeException("unhandled filter type: " + type); } }
public ByteArrayComparableModel( ByteArrayComparable comparator) { String typeName = comparator.getClass().getSimpleName(); ComparatorType type = ComparatorType.valueOf(typeName); this.type = typeName; switch (type) { case BinaryComparator: case BinaryPrefixComparator: this.value = Bytes.toString(Base64.getEncoder().encode(comparator.getValue())); break; case BitComparator: this.value = Bytes.toString(Base64.getEncoder().encode(comparator.getValue())); this.op = ((BitComparator)comparator).getOperator().toString(); break; case NullComparator: break; case RegexStringComparator: case SubstringComparator: this.value = Bytes.toString(comparator.getValue()); break; default: throw new RuntimeException("unhandled filter type: " + type); } }
public WritableByteArrayComparableModel( WritableByteArrayComparable comparator) { String typeName = comparator.getClass().getSimpleName(); ComparatorType type = ComparatorType.valueOf(typeName); this.type = typeName; switch (type) { case BinaryComparator: case BinaryPrefixComparator: this.value = Base64.encodeBytes(comparator.getValue()); break; case BitComparator: this.value = Base64.encodeBytes(comparator.getValue()); this.op = ((BitComparator)comparator).getOperator().toString(); break; case NullComparator: break; case RegexStringComparator: case SubstringComparator: this.value = Bytes.toString(comparator.getValue()); break; default: throw new RuntimeException("unhandled filter type: " + type); } }
/** * @param pbBytes A pb serialized {@link BitComparator} instance * @return An instance of {@link BitComparator} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static BitComparator parseFrom(final byte [] pbBytes) throws DeserializationException { ComparatorProtos.BitComparator proto; try { proto = ComparatorProtos.BitComparator.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } BitwiseOp bitwiseOp = BitwiseOp.valueOf(proto.getBitwiseOp().name()); return new BitComparator(proto.getComparable().getValue().toByteArray(),bitwiseOp); }
/** * @param pbBytes A pb serialized {@link BitComparator} instance * @return An instance of {@link BitComparator} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static BitComparator parseFrom(final byte [] pbBytes) throws DeserializationException { ComparatorProtos.BitComparator proto; try { proto = ComparatorProtos.BitComparator.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } BitwiseOp bitwiseOp = BitwiseOp.valueOf(proto.getBitwiseOp().name()); return new BitComparator(proto.getComparable().getValue().toByteArray(),bitwiseOp); }
/** * @param other * @return true if and only if the fields of the comparator that are serialized * are equal to the corresponding fields in other. Used for testing. */ boolean areSerializedFieldsEqual(ByteArrayComparable other) { if (other == this) return true; if (!(other instanceof BitComparator)) return false; BitComparator comparator = (BitComparator)other; return super.areSerializedFieldsEqual(other) && this.getOperator().equals(comparator.getOperator()); }
/** * @return The comparator serialized using pb */ @Override public byte [] toByteArray() { ComparatorProtos.BitComparator.Builder builder = ComparatorProtos.BitComparator.newBuilder(); builder.setComparable(ProtobufUtil.toByteArrayComparable(this.value)); ComparatorProtos.BitComparator.BitwiseOp bitwiseOpPb = ComparatorProtos.BitComparator.BitwiseOp.valueOf(bitOperator.name()); builder.setBitwiseOp(bitwiseOpPb); return builder.build().toByteArray(); }
/** * @param other * @return true if and only if the fields of the comparator that are serialized * are equal to the corresponding fields in other. Used for testing. */ @Override boolean areSerializedFieldsEqual(ByteArrayComparable other) { if (other == this) return true; if (!(other instanceof BitComparator)) return false; BitComparator comparator = (BitComparator)other; return super.areSerializedFieldsEqual(other) && this.getOperator().equals(comparator.getOperator()); }
@Override public void readFields(DataInput in) throws IOException { super.readFields(in); bitOperator = BitwiseOp.valueOf(in.readUTF()); }
@Override public void write(DataOutput out) throws IOException { super.write(out); out.writeUTF(bitOperator.name()); }
/** * @return The comparator serialized using pb */ public byte [] toByteArray() { ComparatorProtos.BitComparator.Builder builder = ComparatorProtos.BitComparator.newBuilder(); builder.setComparable(super.convert()); ComparatorProtos.BitComparator.BitwiseOp bitwiseOpPb = ComparatorProtos.BitComparator.BitwiseOp.valueOf(bitOperator.name()); builder.setBitwiseOp(bitwiseOpPb); return builder.build().toByteArray(); }
/** * @param pbBytes A pb serialized {@link BitComparator} instance * @return An instance of {@link BitComparator} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static BitComparator parseFrom(final byte [] pbBytes) throws DeserializationException { ComparatorProtos.BitComparator proto; try { proto = ComparatorProtos.BitComparator.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } BitwiseOp bitwiseOp = BitwiseOp.valueOf(proto.getBitwiseOp().name()); return new BitComparator(proto.getComparable().getValue().toByteArray(),bitwiseOp); }
/** * @return The comparator serialized using pb */ @Override public byte [] toByteArray() { ComparatorProtos.BitComparator.Builder builder = ComparatorProtos.BitComparator.newBuilder(); builder.setComparable(ProtobufUtil.toByteArrayComparable(this.value)); ComparatorProtos.BitComparator.BitwiseOp bitwiseOpPb = ComparatorProtos.BitComparator.BitwiseOp.valueOf(bitOperator.name()); builder.setBitwiseOp(bitwiseOpPb); return builder.build().toByteArray(); }
/** * @param other * @return true if and only if the fields of the comparator that are serialized * are equal to the corresponding fields in other. Used for testing. */ @Override boolean areSerializedFieldsEqual(ByteArrayComparable other) { if (other == this) return true; if (!(other instanceof BitComparator)) return false; BitComparator comparator = (BitComparator)other; return super.areSerializedFieldsEqual(other) && this.getOperator().equals(comparator.getOperator()); }
/** * @param pbBytes A pb serialized {@link BitComparator} instance * @return An instance of {@link BitComparator} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static BitComparator parseFrom(final byte [] pbBytes) throws DeserializationException { ComparatorProtos.BitComparator proto; try { proto = ComparatorProtos.BitComparator.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } BitwiseOp bitwiseOp = BitwiseOp.valueOf(proto.getBitwiseOp().name()); return new BitComparator(proto.getComparable().getValue().toByteArray(),bitwiseOp); }