A set of NvPair name and value pairs describing one item, used both to define which fields to collect and to hold the values that were collected. That dual role is the thing to watch. A group holds an NvSet describing the custom fields it wants captured, and each profile or group membership holds its own NvSet containing the answers, and both are the same class. Sets are versioned rather than edited in place: duplicate copies a set, leaves the original untouched and links the copy back to it through previousSetId, so the chain of previous sets is the change history for that data. Lookups scan the pairs rather than indexing them, so read a whole set into a map instead of calling get repeatedly.
Group: Database Entities
Implements: Serializable
Properties
| Property | Returns | Description |
|---|---|---|
| createdDate | Date | When this version of the set was created. Required. |
| empty | boolean | Whether this set holds no pairs at all. True both when the pair collection is null and when it is present but empty. |
| id | Long | The database-assigned unique identifier for this set. |
| nvPairs | Set<NvPair> | The name and value pairs in this set, held as an unordered set, so do not rely on iteration order. Use getPairsOrdered when the order the fields were added in matters. Null on a set that has just been constructed rather than loaded. |
| pairsOrdered | List<NvPair> | The pairs in this set ordered by row id, which is the order they were added in. Use this instead of getNvPairs whenever the fields have to be shown in a stable order. Returns an empty list when there are no pairs. |
| previousSetId | Long | Row id of the set this one was copied from, which is what links the versions of the same data together. Null for the first set in a chain. It is a plain id rather than a mapped relationship, so read it back with previous rather than by navigating a property. |
Methods
getId() · getPreviousSetId() · getCreatedDate() · getNvPairs() · get(String name) · addPair(String name, String propValue) · isEmpty() · addOrUpdatePair(String name, String value) · isDirty(NvSet previous) · toMap() · getPairsOrdered()
getId()
Returns: Long
The database-assigned unique identifier for this set.
getPreviousSetId()
Returns: Long
Row id of the set this one was copied from, which is what links the versions of the same data together. Null for the first set in a chain. It is a plain id rather than a mapped relationship, so read it back with previous rather than by navigating a property.
getCreatedDate()
Returns: Date
When this version of the set was created. Required.
getNvPairs()
Returns: Set<NvPair>
The name and value pairs in this set, held as an unordered set, so do not rely on iteration order. Use getPairsOrdered when the order the fields were added in matters. Null on a set that has just been constructed rather than loaded.
get(String name)
Returns: String
Value of the named pair. This scans the pairs in the set rather than using an index, so if you need several values read the whole set with toMap instead of calling this repeatedly.
| Parameter | Description |
|---|---|
name | the field name to look for, matched exactly |
addPair(String name, String propValue)
Returns: NvPair
Adds a pair with the given name and value, or updates the existing pair if the set already has one with that name. The pair is linked to this set but not saved, so the caller has to persist it.
| Parameter | Description |
|---|---|
name | the field name to add or update |
propValue | the value to store against that name |
isEmpty()
Returns: boolean
Whether this set holds no pairs at all. True both when the pair collection is null and when it is present but empty.
addOrUpdatePair(String name, String value)
Returns: NvPair
Sets the value of the named pair, adding it if the set does not have one yet. If the set somehow holds more than one pair with that name, the first is updated and the duplicates are removed. As with addPair the result is not saved.
| Parameter | Description |
|---|---|
name | the field name to set |
value | the value to store against that name |
isDirty(NvSet previous)
Returns: boolean
Compares this set against an earlier version and reports whether anything has actually changed, so an unchanged set need not be saved as a new version. A null previous set always counts as changed, as does any difference in the number of pairs, and a value that is missing from the previous set counts as changed only if the new value is not empty.
| Parameter | Description |
|---|---|
previous | the earlier version of this set to compare against, may be null |
toMap()
Returns: Map<String,String>
The pairs in this set as a map of field name to value, which is the cheap way to read several fields at once. Returns an empty map when the set has no pairs, and if the set somehow holds duplicate names only one value survives.
getPairsOrdered()
Returns: List<NvPair>
The pairs in this set ordered by row id, which is the order they were added in. Use this instead of getNvPairs whenever the fields have to be shown in a stable order. Returns an empty list when there are no pairs.