use of io.mantisrx.shaded.com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project syndesis-qe by syndesisio.
the class AbstractStep method generateStepAction.
// Small hack -> the Action doesn't provide setters for input/output data shape
public Action generateStepAction(Action action, ConnectorDescriptor connectorDescriptor) {
ObjectMapper mapper = new ObjectMapper().registerModules(new Jdk8Module());
Action ts = null;
try {
JSONObject json = new JSONObject(mapper.writeValueAsString(action));
JSONObject inputDataType = new JSONObject(mapper.writeValueAsString(connectorDescriptor.getInputDataShape().get()));
JSONObject outputDataType = new JSONObject(mapper.writeValueAsString(connectorDescriptor.getOutputDataShape().get()));
JSONArray propertyDefinitionSteps = new JSONArray(mapper.writeValueAsString(connectorDescriptor.getPropertyDefinitionSteps()));
json.getJSONObject("descriptor").put("inputDataShape", inputDataType);
json.getJSONObject("descriptor").put("outputDataShape", outputDataType);
json.getJSONObject("descriptor").put("propertyDefinitionSteps", propertyDefinitionSteps);
ts = Json.reader().forType(Action.class).readValue(json.toString());
} catch (IOException ex) {
log.error("Error: " + ex);
}
return ts;
}
use of io.mantisrx.shaded.com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project ninja by ninjaframework.
the class ObjectMapperProvider method get.
@Override
public ObjectMapper get() {
ObjectMapper objectMapper = new ObjectMapper();
// Afterburner optimizes performance of Pojo to Json mapper
objectMapper.registerModule(new AfterburnerModule());
// Java 8 data type
objectMapper.registerModule(new JavaTimeModule());
objectMapper.registerModule(new Jdk8Module());
// Joda
objectMapper.registerModule(new JodaModule());
return objectMapper;
}
use of io.mantisrx.shaded.com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project Rosetta by HubSpot.
the class StoredAsJsonTest method setup.
@Before
public void setup() {
Rosetta.addModule(new Jdk8Module());
bean = new StoredAsJsonBean();
inner = new InnerBean();
inner.setStringProperty("value");
ConcreteStoredAsJsonTypeInfo concrete = new ConcreteStoredAsJsonTypeInfo();
concrete.setGeneralValue("General");
concrete.setConcreteValue("internal");
typeInfoBean = concrete;
}
use of io.mantisrx.shaded.com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project immutables by immutables.
the class IdAnnotationModuleTest method mappers.
static List<ObjectMapper> mappers() {
ObjectMapper template = new ObjectMapper().registerModule(new Jdk8Module()).registerModule(new GuavaModule()).registerModule(new JavaTimeModule());
ObjectMapper mapper1 = template.copy().registerModule(new IdAnnotationModule());
ObjectMapper mapper2 = template.copy().registerModule(IdAnnotationModule.fromPredicate(m -> ((AnnotatedElement) m).isAnnotationPresent(Criteria.Id.class)));
ObjectMapper mapper3 = template.copy().registerModule(IdAnnotationModule.fromAnnotation(Criteria.Id.class));
return Arrays.asList(mapper1, mapper2, mapper3);
}
use of io.mantisrx.shaded.com.fasterxml.jackson.datatype.jdk8.Jdk8Module in project Anserini by castorini.
the class BackgroundLinkingTopicReader method extractArticlePlainText.
// Note that there's code duplication here with the WashingtonPostCollection. We can't just call a method there
// because the version of the code inside WashingtonPostCollection.Document modifies internal state (e.g., "kicker"
// and "caption"). Haven't thought of a good solution for this yet.
private static String extractArticlePlainText(String record) {
WashingtonPostCollection.Document.WashingtonPostObject wapoObj;
ObjectMapper mapper = new ObjectMapper();
try {
wapoObj = mapper.disable(// Ignore unrecognized properties
DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).registerModule(// Deserialize Java 8 Optional: http://www.baeldung.com/jackson-optional
new Jdk8Module()).readValue(record, WashingtonPostCollection.Document.WashingtonPostObject.class);
} catch (IOException e) {
// Something is wrong... abort!
throw new RuntimeException(e);
}
StringBuilder contentBuilder = new StringBuilder();
contentBuilder.append(wapoObj.getTitle()).append("\n");
wapoObj.getContents().ifPresent(contents -> {
for (WashingtonPostCollection.Document.WashingtonPostObject.Content contentObj : contents) {
if (contentObj == null)
continue;
if (contentObj.getType().isPresent() && contentObj.getContent().isPresent()) {
contentObj.getType().ifPresent(type -> {
contentObj.getContent().ifPresent(content -> {
if (WashingtonPostCollection.Document.CONTENT_TYPE_TAG.contains(type)) {
contentBuilder.append(Jsoup.parse(content).text()).append("\n");
}
});
});
}
contentObj.getFullCaption().ifPresent(caption -> {
String fullCaption = contentObj.getFullCaption().get();
contentBuilder.append(Jsoup.parse(fullCaption).text()).append("\n");
});
}
});
return contentBuilder.toString();
}
Aggregations