use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project ratpack by ratpack.
the class DefaultConfigData method getAsConfigObject.
@Override
public <O> ConfigObject<O> getAsConfigObject(String pointer, TypeToken<O> type) {
JsonNode node = pointer != null ? rootNode.at(pointer) : rootNode;
if (node.isMissingNode()) {
node = emptyNode;
}
try {
JavaType javaType = objectMapper.getTypeFactory().constructType(type.getType());
O value = objectMapper.readValue(new TreeTraversingParser(node, objectMapper), javaType);
return new DefaultConfigObject<>(pointer, type, value);
} catch (IOException ex) {
throw Exceptions.uncheck(ex);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project Gaffer by gchq.
the class GraphConfigurationService method getSerialisedFields.
@SuppressFBWarnings(value = "REC_CATCH_EXCEPTION", justification = "Need to wrap all runtime exceptions before they are given to the user")
@Override
public Set<String> getSerialisedFields(final String className) {
final Class<?> clazz;
try {
clazz = Class.forName(className);
} catch (final Exception e) {
throw new IllegalArgumentException("Class name was not recognised: " + className, e);
}
final ObjectMapper mapper = new ObjectMapper();
final JavaType type = mapper.getTypeFactory().constructType(clazz);
final BeanDescription introspection = mapper.getSerializationConfig().introspect(type);
final List<BeanPropertyDefinition> properties = introspection.findProperties();
final Set<String> fields = new HashSet<>();
for (final BeanPropertyDefinition property : properties) {
fields.add(property.getName());
}
return fields;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project rskj by rsksmart.
the class GenesisLoader method loadGenesis.
public static Genesis loadGenesis(RskSystemProperties config, BigInteger initialNonce, InputStream genesisJsonIS, boolean isRsk) {
try {
String json = new String(ByteStreams.toByteArray(genesisJsonIS));
ObjectMapper mapper = new ObjectMapper();
JavaType type = mapper.getTypeFactory().constructType(GenesisJson.class);
GenesisJson genesisJson = new ObjectMapper().readValue(json, type);
Genesis genesis = new GenesisMapper().mapFromJson(genesisJson, isRsk);
Map<RskAddress, InitialAddressState> premine = generatePreMine(config, initialNonce, genesisJson.getAlloc());
genesis.setPremine(premine);
byte[] rootHash = generateRootHash(premine);
genesis.setStateRoot(rootHash);
genesis.flushRLP();
return genesis;
} catch (Exception e) {
System.err.println("Genesis block configuration is corrupted or not found ./resources/genesis/...");
logger.error("Genesis block configuration is corrupted or not found ./resources/genesis/...", e);
System.exit(-1);
return null;
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project incubator-servicecomb-java-chassis by apache.
the class ClassUtils method getOrCreateClass.
// 获取modelImpl对应的class
public static Class<?> getOrCreateClass(ClassLoader classLoader, String packageName, Swagger swagger, Map<String, Property> properties, String clsName) {
Class<?> cls = getClassByName(classLoader, clsName);
if (cls != null) {
return cls;
}
ClassConfig classConfig = new ClassConfig();
classConfig.setClassName(clsName);
if (null != properties) {
for (Entry<String, Property> entry : properties.entrySet()) {
JavaType propertyJavaType = ConverterMgr.findJavaType(classLoader, packageName, swagger, entry.getValue());
classConfig.addField(entry.getKey(), propertyJavaType);
}
}
cls = JavassistUtils.createClass(classLoader, classConfig);
return cls;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project incubator-servicecomb-java-chassis by apache.
the class ClassUtils method getOrCreateBodyClass.
// 将一系列body parameter包装成一个class
public static Class<?> getOrCreateBodyClass(OperationGenerator operationGenerator, List<BodyParameter> bodyParameters) {
SwaggerGenerator swaggerGenerator = operationGenerator.getSwaggerGenerator();
Method method = operationGenerator.getProviderMethod();
String clsName = swaggerGenerator.ensureGetPackageName() + "." + method.getName() + "Body";
Class<?> cls = getClassByName(swaggerGenerator.getClassLoader(), clsName);
if (cls != null) {
return cls;
}
ClassConfig classConfig = new ClassConfig();
classConfig.setClassName(clsName);
// 2.预备body与明确body混合
for (BodyParameter bp : bodyParameters) {
JavaType javaType = ConverterMgr.findJavaType(swaggerGenerator.getClassLoader(), swaggerGenerator.ensureGetPackageName(), swaggerGenerator.getSwagger(), bp);
classConfig.addField(bp.getName(), javaType);
}
return JavassistUtils.createClass(swaggerGenerator.getClassLoader(), classConfig);
}
Aggregations