# Revision history [back]

### Could "Choices" be used in YANG of opendaylight?

when I read the YANG specification document: YANG specification

I found this:

    4.2.7. Choices
YANG allows the data model to segregate incompatible nodes into
distinct choices using the "choice" and "case" statements. The
"choice" statement contains a set of "case" statements that define
sets of schema nodes that cannot appear together. Each "case" may
contain multiple nodes, but each node may appear in only one "case"
under a "choice".
When an element from one case is created, all elements from all other
cases are implicitly deleted. The device handles the enforcement of
the constraint, preventing incompatibilities from existing in the
configuration.
The choice and case nodes appear only in the schema tree, not in the
data tree or NETCONF messages. The additional levels of hierarchy
are not needed beyond the conceptual schema.

YANG Example:
container food {
choice snack {
case sports-arena {
leaf pretzel {
type empty;
}
leaf beer {
type empty;
}
}
case late-night {
leaf chocolate {
type enumeration {
enum dark;
enum milk;
enum first-available;
}
}
}
}
}

NETCONF XML Example:
<food>
<pretzel/>
<beer/>
</food>
The "choice" statement is covered in Section 7.9.


What I want to ask is whether "Choices" could be used in YANG of opendaylight and how to use it. Thanks.