Java 类org.apache.thrift.TUnion 实例源码

项目:Mastering-Mesos    文件:GsonMessageBodyHandler.java   
@SuppressWarnings({"unchecked", "rawtypes"})
private static TUnion<?, ?> createUnion(
    Class<?> unionType,
    TFieldIdEnum setField,
    Object fieldValue) throws IllegalAccessException, InstantiationException {

  TUnion union = (TUnion) unionType.newInstance();
  union.setFieldValue(setField, fieldValue);
  return union;
}
项目:Mastering-Mesos    文件:StorageEntityUtil.java   
private static void assertFullyPopulated(String name, Object object, Set<Field> ignoredFields) {
  if (object instanceof Collection) {
    Object[] values = ((Collection<?>) object).toArray();
    assertFalse("Collection is empty: " + name, values.length == 0);
    for (int i = 0; i < values.length; i++) {
      assertFullyPopulated(name + "[" + i + "]", values[i], ignoredFields);
    }
  } else if (object instanceof Map) {
    Map<?, ?> map = (Map<?, ?>) object;
    assertFalse("Map is empty: " + name, map.isEmpty());
    for (Map.Entry<?, ?> entry : map.entrySet()) {
      assertFullyPopulated(name + " key", entry.getKey(), ignoredFields);
      assertFullyPopulated(name + "[" + entry.getKey() + "]", entry.getValue(), ignoredFields);
    }
  } else if (object instanceof TUnion) {
    TUnion<?, ?> union = (TUnion<?, ?>) object;
    assertFullyPopulated(
        name + "." + union.getSetField().getFieldName(),
        union.getFieldValue(),
        ignoredFields);
  } else if (!(object instanceof String) && !(object instanceof Enum)) {
    for (Field field : object.getClass().getDeclaredFields()) {
      if (!Modifier.isStatic(field.getModifiers())) {
        validateField(name, object, field, ignoredFields);
      }
    }
  }
}
项目:bdelab    文件:SplitDataPailStructure.java   
public void fillTarget(List<String> ret, Object val) {
  ret.add("" + ((TUnion) ((TBase)val)
          .getFieldValue(valueId))
          .getSetField()
          .getThriftFieldId());
}
项目:bdelab    文件:SplitDataPailStructure.java   
public void fillTarget(List<String> ret, Object val) {
  ret.add("" + ((TUnion) ((TBase)val)
          .getFieldValue(valueId))
          .getSetField()
          .getThriftFieldId());
}
项目:parquet-mr    文件:ThriftSchemaConverter.java   
public static <T extends TBase<?,?>> StructOrUnionType structOrUnionType(Class<T> klass) {
  return TUnion.class.isAssignableFrom(klass) ? StructOrUnionType.UNION : StructOrUnionType.STRUCT;
}