org.apache.thrift.TFieldRequirementType Java Examples

The following examples show how to use org.apache.thrift.TFieldRequirementType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MockResult.java    From thrift-mock with Apache License 2.0 6 votes vote down vote up
public MockResult(String methodName, TBase value) {
  this.methodName = methodName;
  this.success = value;
  this.structDesc = new TStruct(methodName+"_result");

  //init metaDatMap
  Map<_Fields, FieldMetaData> tmpMap = new EnumMap<>(_Fields.class);
  tmpMap.put(_Fields.SUCCESS,
             new FieldMetaData(SUCCESS_NAME, TFieldRequirementType.DEFAULT,
                               new FieldValueMetaData(TType.STRUCT          , value.getClass().getCanonicalName())));
  metaDataMap = Collections.unmodifiableMap(tmpMap);
  FieldMetaData.addStructMetaDataMap(MockResult.class, metaDataMap);

  schemes.put(StandardScheme.class, new MockResultStandardSchemeFactory(structDesc));
  schemes.put(TupleScheme.class, new MockResultTupleSchemeFactory());

}
 
Example #2
Source File: ThriftDocServicePlugin.java    From armeria with Apache License 2.0 5 votes vote down vote up
private static FieldRequirement convertRequirement(byte value) {
    switch (value) {
        case TFieldRequirementType.REQUIRED:
            return FieldRequirement.REQUIRED;
        case TFieldRequirementType.OPTIONAL:
            return FieldRequirement.OPTIONAL;
        case TFieldRequirementType.DEFAULT:
            // Convert to unspecified for consistency with gRPC and AnnotatedService.
            return FieldRequirement.UNSPECIFIED;
        default:
            throw new IllegalArgumentException("unknown requirement type: " + value);
    }
}
 
Example #3
Source File: ThriftDocServicePluginTest.java    From armeria with Apache License 2.0 5 votes vote down vote up
@Test
void testNewExceptionInfo() {
    final ExceptionInfo exception = newExceptionInfo(FooServiceException.class);

    assertThat(exception).isEqualTo(new ExceptionInfo(
            FooServiceException.class.getName(),
            ImmutableList.of(newFieldInfo(
                    FooServiceException.class,
                    new FieldMetaData("stringVal", TFieldRequirementType.DEFAULT,
                                      new FieldValueMetaData(TType.STRING, false))))));
}