本文整理匯總了Java中com.fasterxml.jackson.databind.node.ObjectNode.deepCopy方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectNode.deepCopy方法的具體用法?Java ObjectNode.deepCopy怎麽用?Java ObjectNode.deepCopy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.fasterxml.jackson.databind.node.ObjectNode
的用法示例。
在下文中一共展示了ObjectNode.deepCopy方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateMetricData
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
private ObjectNode updateMetricData(long nowMs, String hostName, ObjectNode testData) {
ObjectNode data;
data = testData.deepCopy(); // copy test data, modify it
ObjectNode attNode = (ObjectNode) data.path( "attributes" );
attNode.put( "hostName", hostName );
attNode.put( "currentTimeMillis", nowMs );
ArrayNode timeStamps = (ArrayNode) data.path( "data" ).path( "timeStamp" );
for (int i = 0; i < timeStamps.size(); i++) {
long offset = i * 30000; // timeStamps in reverse order LIFO. latest
// time is first
timeStamps.set( i, LongNode.valueOf( nowMs - offset ) );
}
return data;
}
示例2: updateOrValidateSettings
import com.fasterxml.jackson.databind.node.ObjectNode; //導入方法依賴的package包/類
@RequestMapping ( value = "/settings" , produces = MediaType.APPLICATION_JSON_VALUE , method = RequestMethod.POST )
public ObjectNode updateOrValidateSettings (
@RequestParam ( "lifeToEdit" ) String lifeToEdit,
@RequestParam ( "definition" ) String definitionText,
@RequestParam ( value = "isUpdate" , required = false ) String isUpdate ) {
if ( lifeToEdit == null ) {
lifeToEdit = Application.getCurrentLifeCycle();
}
logger.info( "lifeToEdit: {} , isUpdate: {}", lifeToEdit, isUpdate );
logger.debug( "definitionText: \n{}", definitionText );
ObjectNode updateResultNode = jacksonMapper.createObjectNode();
try {
ObjectNode updatedSettingsDefinition = (ObjectNode) jacksonMapper.readTree( definitionText );
updatedSettingsDefinition.put( "lastModifiedBy", CsapUser.currentUsersID() );
ObjectNode modelNode = (ObjectNode) csapApp.getRootModel().getJsonModelDefinition();
ObjectNode testPackageModel = modelNode.deepCopy();
JsonNode currentLifeNode = testPackageModel.at( DefinitionParser.buildLifePtr( lifeToEdit ) );
((ObjectNode) currentLifeNode).set( DefinitionParser.PARSER_SETTINGS, updatedSettingsDefinition );
updateResultNode.put( "lifeToEdit", lifeToEdit );
logger.debug( "updateNode: \n{}", updatedSettingsDefinition.toString() );
ObjectNode validationResults = csapApp.checkDefinitionForParsingIssues(
testPackageModel.toString(),
csapApp.getRootModel().getReleasePackageName(),
"settingsUpdate" );
updateResultNode.set( "validationResults", validationResults );
boolean validatePassed = ((ArrayNode) validationResults.get( Application.VALIDATION_ERRORS )).size() == 0;
if ( validatePassed ) {
validateTrendingAndRealTimeDefinition( lifeToEdit, updatedSettingsDefinition, validationResults );
}
if ( isUpdate != null && validatePassed ) {
updateResultNode.put( "updatedHost", Application.getHOST_NAME() );
csapApp.getRootModel().setJsonModelDefinition( testPackageModel );
}
} catch (Throwable ex) {
logger.error( "Failed to parse", ex );
return buildEditingErrorResponse( ex, updateResultNode );
}
return updateResultNode;
}