private boolean needsCodec(ThriftFieldMetadata fieldMetadata) { if (ReflectionHelper.isArray(fieldMetadata.getThriftType().getJavaType())) { return false; } ThriftProtocolType protocolType = fieldMetadata.getThriftType().getProtocolType(); return protocolType == ENUM || protocolType == STRUCT || protocolType == SET || protocolType == LIST || protocolType == MAP; }
@Override public ThriftMethodInjection apply(MethodInjection injection) { return new ThriftMethodInjection(injection.getMethod(), buildParameterInjections(injection.getParameters())); } });
@Override public ThriftConstructorInjection apply(ConstructorInjection injection) { return new ThriftConstructorInjection(injection.getConstructor(), buildParameterInjections(injection.getParameters())); } }));
@Override public ThriftParameterInjection apply(ParameterInjection injection) { return new ThriftParameterInjection( injection.getId(), injection.getName(), injection.getParameterIndex(), injection.getJavaType() ); } });
@Test public void testGenericBuilder() { Type structType = new TypeToken<GenericStruct<String>>() {}.getType(); ThriftStructMetadataBuilder builder = new ThriftStructMetadataBuilder(new ThriftCatalog(), structType); builder.build(); }
@Test public void testNonFinalStructsOk() { ThriftStructMetadataBuilder builder = new ThriftStructMetadataBuilder(new ThriftCatalog(), NotFinalStruct.class); builder.build(); }
@Override public Short apply(ThriftFieldMetadata input) { return input.getId(); } }));
public static ThriftType array(ThriftTypeReference valueTypeReference) { checkNotNull(valueTypeReference, "valueTypeReference is null"); Class<?> javaType = ReflectionHelper.getArrayOfType(valueTypeReference.getJavaType()); return new ThriftType(ThriftProtocolType.LIST, javaType, null, valueTypeReference); }
public boolean isInternal() { switch (getType()) { // These are normal thrift fields (i.e. they should be emitted by the swift2thrift generator) case THRIFT_FIELD: return false; // Other fields types are used internally in swift, but do not make up part of the external // thrift interface default: return true; } }
@Override public ThriftProtocolType getProtocolType() { return thriftType.getProtocolType(); }
public CoercionThriftCodec(ThriftCodec<?> codec, TypeCoercion typeCoercion) { this.codec = (ThriftCodec<Object>) codec; this.typeCoercion = typeCoercion; this.thriftType = typeCoercion.getThriftType(); }
@Override public String toString() { if (isResolved()) { return "Resolved reference to " + get(); } else { return "Unresolved reference to ThriftType for " + javaType; } }
public RecursiveThriftTypeReference(ThriftCatalog catalog, Type javaType) { this.catalog = catalog; this.javaType = javaType; this.protocolType = catalog.getThriftProtocolType(javaType); }
private boolean isResolved() { return catalog.getThriftTypeFromCache(javaType) != null; } }
private ThriftStructMetadata testStructMetadataBuild( Class<?> structClass, int expectedConstructorParameters, int expectedMethodInjections) throws Exception { return testMetadataBuild( ThriftStructMetadataBuilder.class, structClass, expectedConstructorParameters, expectedMethodInjections); }
@Override public ThriftParameterInjection apply(ParameterInjection injection) { return new ThriftParameterInjection( injection.getId(), injection.getName(), injection.getParameterIndex(), injection.getJavaType() ); } });
@Override public ThriftMethodInjection apply(MethodInjection injection) { return new ThriftMethodInjection(injection.getMethod(), buildParameterInjections(injection.getParameters())); } });
@Override public ThriftConstructorInjection apply(ConstructorInjection injection) { return new ThriftConstructorInjection(injection.getConstructor(), buildParameterInjections(injection.getParameters())); } }));
public boolean isInternal() { switch (getType()) { // These are normal thrift fields (i.e. they should be emitted by the swift2thrift generator) case THRIFT_FIELD: return false; // Other fields types are used internally in swift, but do not make up part of the external // thrift interface default: return true; } }
protected final ThriftMethodInjection buildBuilderConstructorInjections() { ThriftMethodInjection builderMethodInjection = null; if (builderType != null) { MethodInjection builderMethod = builderMethodInjections.get(0); builderMethodInjection = new ThriftMethodInjection(builderMethod.getMethod(), buildParameterInjections(builderMethod.getParameters())); } return builderMethodInjection; }