TObject implements
        org.apache.thrift.TBase<TObject, TObject._Fields>,
        java.io.Serializable,
        Cloneable,
        Comparable<TObject> { public static Aliases alias(Operator operator, TObject... values) { Operator original = operator; switch (operator) { case LIKE: operator = Operator.REGEX; break; case NOT_LIKE: operator = Operator.NOT_REGEX; break; case LINKS_TO: operator = Operator.EQUALS; break; default: break; } TObject[] ovalues = new TObject[values.length]; for (int i = 0; i < ovalues.length; ++i) { TObject value = values[i]; try { switch (original) { case REGEX: case NOT_REGEX: case LIKE: case NOT_LIKE: value = Convert.javaToThrift( ((String) Convert.thriftToJava(value)).replaceAll( RegexPatterns.PERCENT_SIGN_WITHOUT_ESCAPE_CHAR, ".*").replaceAll( RegexPatterns.PERCENT_SIGN_WITH_ESCAPE_CHAR, "%")); break; case LINKS_TO: value = Convert.javaToThrift( Link.to(((Number) Convert.thriftToJava(value)) .longValue())); break; default: break; } } catch (ClassCastException e) {} ovalues[i] = value; } return new Aliases(operator, ovalues); } TObject();  TObject(ByteBuffer data, Type type);  TObject(TObject other); static Comparator<TObject> comparator(); static Aliases alias(Operator operator, TObject... values); ByteBuffer bufferForData(); @DoNotInvoke TObject cacheServerWrapper(Object serverValue); @Override void clear(); @Override int compareTo(TObject other); int compareToIgnoreCase(TObject other); TObject deepCopy(); @Override boolean equals(Object obj); _Fields fieldForId(int fieldId); byte[] getData(); Object getFieldValue(_Fields field); @Nullable Object getJavaFormat(); @Nullable @DoNotInvoke Object getServerWrapper(); Type getType(); @Override int hashCode(); boolean is(Operator operator, TObject... values); boolean isBlank(); boolean isCharSequenceType(); boolean isIgnoreCase(Operator operator, TObject... values); boolean isSet(_Fields field); boolean isSetData(); boolean isSetType(); boolean matches(TObject other); void read(org.apache.thrift.protocol.TProtocol iprot); TObject setData(byte[] data); TObject setData(ByteBuffer data); void setDataIsSet(boolean value); void setFieldValue(_Fields field, Object value); TObject setJavaFormat(Object java); TObject setType(Type type); void setTypeIsSet(boolean value); @Override String toString(); void unsetData(); void unsetType(); void validate(); void write(org.apache.thrift.protocol.TProtocol oprot); static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static final TObject NEGATIVE_INFINITY; static final TObject NULL; static final TObject POSITIVE_INFINITY; public ByteBuffer data; public Type type; }
@Test public void testNormalizeLinksToNotLong() { TObject value = Convert.javaToThrift(Random.getString()); Assert.assertEquals(value, TObject.alias(Operator.LINKS_TO, value).values()[0]); }
@Test @Theory public void testNormalizeOperator(Operator operator) { Operator expected = null; switch (operator) { case LIKE: expected = Operator.REGEX; break; case NOT_LIKE: expected = Operator.NOT_REGEX; break; case LINKS_TO: expected = Operator.EQUALS; break; default: expected = operator; break; } Assert.assertEquals(expected, TObject.alias(operator, Array.containing()).operator()); }
@Test @Theory public void testNormalizeValue(Operator operator) { long num = Random.getLong(); Object value = null; Object expected = null; switch (operator) { case REGEX: case NOT_REGEX: value = putNumberWithinPercentSign(num); expected = putNumberWithinStarSign(num); break; case LINKS_TO: value = num; expected = Link.to(num); break; default: value = num; expected = num; break; } Assert.assertEquals(Convert.javaToThrift(expected), TObject .alias(operator, Convert.javaToThrift(value)).values()[0]); }