本文整理汇总了Java中org.apache.avro.reflect.ReflectData.get方法的典型用法代码示例。如果您正苦于以下问题:Java ReflectData.get方法的具体用法?Java ReflectData.get怎么用?Java ReflectData.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.avro.reflect.ReflectData
的用法示例。
在下文中一共展示了ReflectData.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyToConfiguration
import org.apache.avro.reflect.ReflectData; //导入方法依赖的package包/类
/**
* Applies endpoint parameters to configuration & resolves protocol and other required configuration properties.
*/
private void applyToConfiguration(AvroConfiguration config, URI endpointUri, Map<String, Object> parameters) throws Exception {
config.parseURI(endpointUri, parameters, this);
setProperties(config, parameters);
if (config.getProtocol() == null && config.getProtocolClassName() != null) {
Class<?> protocolClass = getCamelContext().getClassResolver().resolveClass(config.getProtocolClassName());
if (protocolClass != null) {
try {
Field f = protocolClass.getField("PROTOCOL");
if (f != null) {
Protocol protocol = (Protocol)f.get(null);
config.setProtocol(protocol);
}
} catch (NoSuchFieldException e) {
ReflectData reflectData = ReflectData.get();
config.setProtocol(reflectData.getProtocol(protocolClass));
config.setReflectionProtocol(true);
}
}
}
if (config.getProtocol() == null) {
throw new IllegalArgumentException("Avro configuration does not contain protocol");
}
if (config.getMessageName() != null && !config.getProtocol().getMessages().containsKey(config.getMessageName())) {
throw new IllegalArgumentException("Message " + config.getMessageName() + " is not defined in protocol");
}
if (config.isSingleParameter()) {
Map<String, Protocol.Message> messageMap = config.getProtocol().getMessages();
Iterable<Protocol.Message> messagesToCheck = config.getMessageName() == null
? messageMap.values()
: Collections.singleton(messageMap.get(config.getMessageName()));
for (Protocol.Message message : messagesToCheck) {
if (message.getRequest().getFields().size() != 1) {
throw new IllegalArgumentException("Single parameter option can't be used with message "
+ message.getName() + " because it has " + message.getRequest().getFields().size()
+ " parameters defined"
);
}
}
}
}
示例2: get
import org.apache.avro.reflect.ReflectData; //导入方法依赖的package包/类
@Override
public GenericData get() {
return ReflectData.get();
}