Beispiel #1
0
func labelFor(node graph.Node) string {
	switch node := node.(type) {
	case CollectionNode:
		return node.Name
	case RuleNode:
		return fmt.Sprintf("rule %d", node.num)
	case FieldNode:
		return fmt.Sprintf("%s.%s", node.collectionName, node.field)
	default:
		return fmt.Sprint(node.ID())
	}
}
Beispiel #2
0
func nameFor(node graph.Node) string {
	switch node := node.(type) {
	case CollectionNode:
		return node.Name
	case RuleNode:
		return fmt.Sprintf("rule%d", node.num)
	case FieldNode:
		fieldName := node.field
		if fieldName[0] == '@' {
			fieldName = node.field[1:]
		}
		return fmt.Sprintf("%s_%s", node.collectionName, fieldName)
	default:
		return fmt.Sprint(node.ID())
	}
}