Weight converts the enum types to a numerical value for easier comparisons. Easier than sets of if statements.
()
| 46 | // Weight converts the enum types to a numerical value for easier |
| 47 | // comparisons. Easier than sets of if statements. |
| 48 | func (e Entitlement) Weight() int { |
| 49 | switch e { |
| 50 | case EntitlementEntitled: |
| 51 | return 2 |
| 52 | case EntitlementGracePeriod: |
| 53 | return 1 |
| 54 | case EntitlementNotEntitled: |
| 55 | return -1 |
| 56 | default: |
| 57 | return -2 |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | // Addon represents a grouping of features used for additional license SKUs. |
| 62 | // It is complementary to FeatureSet and similar in implementation, allowing |