List of usage examples for com.fasterxml.jackson.core.type TypeReference TypeReference
protected TypeReference()
From source file:com.vmware.photon.controller.api.client.resource.SystemStatusApi.java
/** * Get system status asynchronously.//from w ww . j av a2 s . c om * * @param responseCallback * @throws IOException */ public void getSystemStatusAsync(final FutureCallback<SystemStatus> responseCallback) throws IOException { String path = getBasePath(); getObjectByPathAsync(path, responseCallback, new TypeReference<SystemStatus>() { }); }
From source file:com.flipkart.bifrost.framework.impl.RabbitMQExecutionServerListener.java
@Override public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException { ProtocolResponse protocolResponse = null; ProtocolRequest<T> request = null; try {//from w w w . j a va2 s.c o m request = mapper.readValue(body, new TypeReference<ProtocolRequest<T>>() { }); T response = request.getCallable().call(); protocolResponse = new ProtocolResponse<T>(response); } catch (Exception e) { logger.error("Error: " + e); protocolResponse = new ProtocolResponse(BifrostException.ErrorCode.APPLICATION_ERROR, "Application level error: " + e.getMessage()); } try { if (null != request && request.isResponseReturned()) { AMQP.BasicProperties replyProperties = new AMQP.BasicProperties.Builder() .correlationId(properties.getCorrelationId()).build(); if (null != properties.getReplyTo()) { getChannel().basicPublish("", properties.getReplyTo(), replyProperties, mapper.writeValueAsBytes(protocolResponse)); } } getChannel().basicAck(envelope.getDeliveryTag(), false); } catch (Exception e) { logger.error("Error occurred returning: ", e); } }
From source file:org.apache.streams.data.util.JsonUtil.java
public static <T> List<T> jsoNodeToList(JsonNode node, Class<T> clazz) { return mapper.convertValue(node, new TypeReference<List<T>>() { });// ww w . jav a 2 s . co m }
From source file:com.twitter.ambrose.model.Workflow.java
/** * Derializes a JSON Workflow string into a Workflow object. Unrecognized properties will * be ignored./*from ww w . j ava 2s .c o m*/ * * @param workflowInfoJson the string to convert into a JSON object. * @return a Workflow object. * @throws IOException */ public static Workflow fromJSON(String workflowInfoJson) throws IOException { return JSONUtil.toObject(workflowInfoJson, new TypeReference<Workflow>() { }); }
From source file:com.omertron.slackbot.functions.Meetup.java
/** * Retrieve and process the MeetUps from the site. * * @param pageSize/*www . j a v a2s .com*/ * @throws ApiException */ public static void readMeetUp(int pageSize) throws ApiException { MEETUPS.clear(); if (StringUtils.isBlank(BASE_URL)) { throw new ApiException(ApiExceptionType.INVALID_URL, "Meetup URL is not set in the properties file! Use the property " + Constants.MEETUP_URL); } try { URL url = HttpTools.createUrl(BASE_URL + pageSize); List<MeetupDetails> meetups = MAPPER.readValue(url, new TypeReference<List<MeetupDetails>>() { }); MEETUPS.addAll(meetups); } catch (IOException ex) { LOG.warn("Failed to read MeetUp data: {}", ex.getMessage(), ex); return; } catch (ApiException ex) { LOG.warn("Failed to convert URL: {}", ex.getMessage(), ex); return; } LOG.info("Processed {} MeetUp events", MEETUPS.size()); }
From source file:com.evrythng.java.wrapper.service.RedirectorService.java
/** * Create or update Account level {@link RedirectorRules}. * <p>//w ww. ja va 2 s. co m * PUT {@value #PATH_ACCOUNT_REDIRECTOR} * * @param redirectorRules {@link RedirectorRules} object. * * @return a preconfigured {@link Builder}. */ public Builder<RedirectorRules> redirectorRulesUpdater(final RedirectorRules redirectorRules) throws EvrythngClientException { return put(PATH_ACCOUNT_REDIRECTOR, redirectorRules, new TypeReference<RedirectorRules>() { }); }
From source file:com.okta.sdk.clients.FactorsAdminApiClient.java
public OrgAuthFactor activateOrgFactor(String orgAuthFactorId, OrgAuthFactor orgAuthFactor) throws IOException { return post(getEncodedPath("/factors/%s/lifecycle/activate", orgAuthFactorId), orgAuthFactor, new TypeReference<OrgAuthFactor>() { });//from w w w .ja v a 2s. c o m }
From source file:org.springframework.cloud.config.monitor.GithubPropertyPathNotificationExtractorTests.java
@Test public void notAPushNotDetected() throws Exception { Map<String, Object> value = new ObjectMapper().readValue( new ClassPathResource("github.json").getInputStream(), new TypeReference<Map<String, Object>>() { });//from w w w . j a v a 2s . c o m this.headers.set("X-Github-Event", "issues"); PropertyPathNotification extracted = this.extractor.extract(this.headers, value); assertNull(extracted); }
From source file:io.stallion.secrets.SecretsVault.java
public static Map<String, String> loadIfExists(String appPath) { String rawPath = appPath + "/conf/secrets.json"; String encryptedPath = appPath + "/conf/secrets.json.aes"; File rawFile = new File(rawPath); if (rawFile.isFile()) { TypeReference<HashMap<String, String>> typeRef = new TypeReference<HashMap<String, String>>() { };//from w ww.j a v a 2 s . c o m String json = null; try { json = FileUtils.readFileToString(rawFile, UTF8); } catch (IOException e) { throw new RuntimeException(e); } return JSON.parse(json, typeRef); } if (new File(encryptedPath).isFile()) { // Get passphrase SecretsVault vault = new SecretsCommandLineManager().loadVault(appPath, secretsSettings); if (vault != null) { return vault.getSecrets(); } } return null; }
From source file:org.mayocat.accounts.store.jdbi.mapper.TenantMapper.java
@Override public Tenant map(int index, ResultSet result, StatementContext statementContext) throws SQLException { String slug = result.getString("slug"); String defaultHost = result.getString("default_host"); ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new GuavaModule()); Integer configurationVersion = result.getInt("configuration_version"); TenantConfiguration configuration;//w w w. j a v a 2 s. co m if (Strings.isNullOrEmpty(result.getString("configuration"))) { configuration = new TenantConfiguration(configurationVersion, Collections.<String, Serializable>emptyMap()); } else { try { Map<String, Serializable> data = mapper.readValue(result.getString("configuration"), new TypeReference<Map<String, Object>>() { }); configuration = new TenantConfiguration(configurationVersion, data); } catch (IOException e) { final Logger logger = LoggerFactory.getLogger(TenantMapper.class); logger.error("Failed to load configuration for tenant with slug [{}]", e); configuration = new TenantConfiguration(); } } Tenant tenant = new Tenant((UUID) result.getObject("id"), slug, configuration); tenant.setFeaturedImageId((UUID) result.getObject("featured_image_id")); tenant.setSlug(slug); tenant.setDefaultHost(defaultHost); tenant.setCreationDate(result.getTimestamp("creation_date")); tenant.setName(result.getString("name")); tenant.setDescription(result.getString("description")); tenant.setContactEmail(result.getString("contact_email")); return tenant; }