private ObjectNode objectNodeFromElement ( final AtlasElement element ) { final boolean isEdge = element instanceof AtlasEdge ; final boolean showTypes = mode == AtlasGraphSONMode . EXTENDED ; final List < String > propertyKeys = isEdge ? this . edgePropertyKeys : this . vertexPropertyKeys ; final ElementPropertiesRule elementPropertyConfig = isEdge ? this . edgePropertiesRule : this . vertexPropertiesRule ; final ObjectNode jsonElement = createJSONMap ( createPropertyMap ( element , propertyKeys , elementPropertyConfig , normalized ) , propertyKeys , showTypes ) ; if ( ( isEdge && this . includeReservedEdgeId ) || ( ! isEdge && this . includeReservedVertexId ) ) { putObject ( jsonElement , AtlasGraphSONTokens . INTERNAL_ID , element . getId ( ) ) ; } // it's important to keep the order of these straight. check AtlasEdge first and then AtlasVertex because there // are graph implementations that have AtlasEdge extend from AtlasVertex if ( element instanceof AtlasEdge ) { final AtlasEdge edge = ( AtlasEdge ) element ; if ( this . includeReservedEdgeId ) { putObject ( jsonElement , AtlasGraphSONTokens . INTERNAL_ID , element . getId ( ) ) ; } if ( this . includeReservedEdgeType ) { jsonElement . put ( AtlasGraphSONTokens . INTERNAL_TYPE , AtlasGraphSONTokens . EDGE ) ; } if ( this . includeReservedEdgeOutV ) { putObject ( jsonElement , AtlasGraphSONTokens . INTERNAL_OUT_V , edge . getOutVertex ( ) . getId ( ) ) ; } if ( this . includeReservedEdgeInV ) { putObject ( jsonElement , AtlasGraphSONTokens . INTERNAL_IN_V , edge . getInVertex ( ) . getId ( ) ) ; } if ( this . includeReservedEdgeLabel ) { jsonElement . put ( AtlasGraphSONTokens . INTERNAL_LABEL , edge . getLabel ( ) ) ; } } else if ( element instanceof AtlasVertex ) { if ( this . includeReservedVertexId ) { putObject ( jsonElement , AtlasGraphSONTokens . INTERNAL_ID , element . getId ( ) ) ; } if ( this . includeReservedVertexType ) { jsonElement . put ( AtlasGraphSONTokens . INTERNAL_TYPE , AtlasGraphSONTokens . VERTEX ) ; } } return jsonElement ; }
Creates GraphSON for a single graph element .