@Test public void testMapConversionWhenNestedStructsEnabled() throws DescriptorValidationException { ThriftToDynamicProto<MapStruct> thriftToProto = new ThriftToDynamicProto<MapStruct>(MapStruct.class, true, false); MapStruct mapStruct = genMapStruct(); Message msg = thriftToProto.convert(mapStruct); Map<Integer, String> expected = mapStruct.entries; List<?> entries = (List)Protobufs.getFieldByName(msg, "entries"); Set<?> expectedKeys = Sets.newHashSet(expected.keySet()); for (Object entry : entries) { Message entryMsg = (Message) entry; Object key = Protobufs.getFieldByName(entryMsg, "key"); assertTrue(expectedKeys.remove(key)); Object value = Protobufs.getFieldByName(entryMsg, "value"); assertEquals(expected.get(key), value); } assertEquals(0, expectedKeys.size()); }
@SuppressWarnings("unchecked") public Message convert(T thriftObj) { return doConvert((TBase<?, ?>) Preconditions.checkNotNull(thriftObj, "Can not convert a null object")); }
ThriftToDynamicProto { @SuppressWarnings("unchecked") public Message convert(T thriftObj) { return doConvert((TBase<?, ?>) Preconditions.checkNotNull(thriftObj, "Can not convert a null object")); } }
ThriftToDynamicProto { @SuppressWarnings("unchecked") public Message convert(T thriftObj) { return doConvert((TBase<?, ?>) Preconditions.checkNotNull(thriftObj, "Can not convert a null object")); } ThriftToDynamicProto(Class<T> thriftClass);  ThriftToDynamicProto(Class<T> thriftClass,
                              boolean supportNestedObjects,
                              boolean ignoreUnsupportedTypes);  ThriftToDynamicProto(Class<T> thriftClass, List<Pair<String, Type>> extraFields);  ThriftToDynamicProto(Class<T> thriftClass,
                              List<Pair<String, Type>> extraFields,
                              boolean supportNestedObjects,
                              boolean ignoreUnsupportedTypes); }
ThriftToDynamicProto { @SuppressWarnings("unchecked") public Message convert(T thriftObj) { return doConvert((TBase<?, ?>) Preconditions.checkNotNull(thriftObj, "Can not convert a null object")); } ThriftToDynamicProto(Class<T> thriftClass);  ThriftToDynamicProto(Class<T> thriftClass,
                              boolean supportNestedObjects,
                              boolean ignoreUnsupportedTypes);  ThriftToDynamicProto(Class<T> thriftClass, List<Pair<String, Type>> extraFields);  ThriftToDynamicProto(Class<T> thriftClass,
                              List<Pair<String, Type>> extraFields,
                              boolean supportNestedObjects,
                              boolean ignoreUnsupportedTypes); Message.Builder getBuilder(Class<? extends TBase<?, ?>> thriftClass); @SuppressWarnings("unchecked") Message convert(T thriftObj); @SuppressWarnings("unchecked") Message doConvert(TBase<?, F> thriftObj); FieldDescriptor getFieldDescriptor(Class<? extends TBase<?, ?>> thriftClass,
                                            String fieldName); Descriptors.FileDescriptor getFileDescriptor(); }
ThriftToDynamicProto { @SuppressWarnings("unchecked") public Message convert(T thriftObj) { return doConvert((TBase<?, ?>) Preconditions.checkNotNull(thriftObj, "Can not convert a null object")); } ThriftToDynamicProto(Class<T> thriftClass);  ThriftToDynamicProto(Class<T> thriftClass,
                              boolean supportNestedObjects,
                              boolean ignoreUnsupportedTypes);  ThriftToDynamicProto(Class<T> thriftClass, List<Pair<String, Type>> extraFields);  ThriftToDynamicProto(Class<T> thriftClass,
                              List<Pair<String, Type>> extraFields,
                              boolean supportNestedObjects,
                              boolean ignoreUnsupportedTypes); Message.Builder getBuilder(Class<? extends TBase<?, ?>> thriftClass); @SuppressWarnings("unchecked") Message convert(T thriftObj); @SuppressWarnings("unchecked") Message doConvert(TBase<?, F> thriftObj); FieldDescriptor getFieldDescriptor(Class<? extends TBase<?, ?>> thriftClass,
                                            String fieldName); Descriptors.FileDescriptor getFileDescriptor();  }