本文整理汇总了Java中org.yaml.snakeyaml.nodes.NodeId.mapping方法的典型用法代码示例。如果您正苦于以下问题:Java NodeId.mapping方法的具体用法?Java NodeId.mapping怎么用?Java NodeId.mapping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.yaml.snakeyaml.nodes.NodeId
的用法示例。
在下文中一共展示了NodeId.mapping方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: representJavaBeanProperty
import org.yaml.snakeyaml.nodes.NodeId; //导入方法依赖的package包/类
/**
* Represent one JavaBean property.
*
* @param javaBean
* - the instance to be represented
* @param property
* - the property of the instance
* @param propertyValue
* - value to be represented
* @param customTag
* - user defined Tag
* @return NodeTuple to be used in a MappingNode. Return null to skip the
* property
*/
protected NodeTuple representJavaBeanProperty(Object javaBean, Property property,
Object propertyValue, Tag customTag) {
ScalarNode nodeKey = (ScalarNode) representData(property.getName());
// the first occurrence of the node must keep the tag
boolean hasAlias = this.representedObjects.containsKey(propertyValue);
Node nodeValue = representData(propertyValue);
if (propertyValue != null && !hasAlias) {
NodeId nodeId = nodeValue.getNodeId();
if (customTag == null) {
if (nodeId == NodeId.scalar) {
if (propertyValue instanceof Enum<?>) {
nodeValue.setTag(Tag.STR);
}
} else {
if (nodeId == NodeId.mapping) {
if (property.getType() == propertyValue.getClass()) {
if (!(propertyValue instanceof Map<?, ?>)) {
if (!nodeValue.getTag().equals(Tag.SET)) {
nodeValue.setTag(Tag.MAP);
}
}
}
}
checkGlobalTag(property, nodeValue, propertyValue);
}
}
}
return new NodeTuple(nodeKey, nodeValue);
}
示例2: representJavaBeanProperty
import org.yaml.snakeyaml.nodes.NodeId; //导入方法依赖的package包/类
/**
* Represent one JavaBean property.
*
* @param javaBean
* - the instance to be represented
* @param property
* - the property of the instance
* @param propertyValue
* - value to be represented
* @param customTag
* - user defined Tag
* @return NodeTuple to be used in a MappingNode. Return null to skip the
* property
*/
protected NodeTuple representJavaBeanProperty(Object javaBean, Property property,
Object propertyValue, Tag customTag) {
ScalarNode nodeKey = (ScalarNode) representData(property.getName());
// the first occurrence of the node must keep the tag
boolean hasAlias = this.representedObjects.containsKey(propertyValue);
Node nodeValue = representData(propertyValue);
if (propertyValue != null && !hasAlias) {
NodeId nodeId = nodeValue.getNodeId();
if (customTag == null) {
if (nodeId == NodeId.scalar) {
if (propertyValue instanceof Enum<?>) {
nodeValue.setTag(Tag.STR);
}
} else {
if (nodeId == NodeId.mapping) {
if (property.getType() == propertyValue.getClass()) {
if (!(propertyValue instanceof Map<?, ?>)) {
if (!nodeValue.getTag().equals(Tag.SET)) {
nodeValue.setTag(Tag.MAP);
}
}
}
}
checkGlobalTag(property, nodeValue, propertyValue);
}
}
}
return new NodeTuple(nodeKey, nodeValue);
}
示例3: representJavaBeanProperty
import org.yaml.snakeyaml.nodes.NodeId; //导入方法依赖的package包/类
/**
* Represent one JavaBean property.
*
* @param javaBean
* - the instance to be represented
* @param property
* - the property of the instance
* @param propertyValue
* - value to be represented
* @param customTag
* - user defined Tag
*
* @return NodeTuple to be used in a MappingNode. Return null to skip the property
*/
@Nullable
protected NodeTuple representJavaBeanProperty(Object javaBean, Property property, @Nullable Object propertyValue, @Nullable Tag customTag)
{
ScalarNode nodeKey = (ScalarNode) this.representData(property.getName());
// the first occurrence of the node must keep the tag
boolean hasAlias = this.representedObjects.containsKey(propertyValue);
Node nodeValue = this.representData(propertyValue);
if ((propertyValue != null) && ! hasAlias)
{
NodeId nodeId = nodeValue.getNodeId();
if (customTag == null)
{
if (nodeId == NodeId.scalar)
{
if (propertyValue instanceof Enum<?>)
{
nodeValue.setTag(Tag.STR);
}
}
else
{
if (nodeId == NodeId.mapping)
{
if (property.getType() == propertyValue.getClass())
{
if (! (propertyValue instanceof Map<?, ?>))
{
if (! nodeValue.getTag().equals(Tag.SET))
{
nodeValue.setTag(Tag.MAP);
}
}
}
}
this.checkGlobalTag(property, nodeValue, propertyValue);
}
}
}
return new NodeTuple(nodeKey, nodeValue);
}