code: void preventTrackingLevelAbuse(Workitem workitem) {
          TrackingLevel level = getTrackingLevel(workitem);
  
          if (workitem instanceof PrimaryWorkitem) {
  
              if (level == TrackingLevel.SecondaryWorkitem) {
                  throw new IllegalStateException("You cannot set DetailEstimate "
                          + "or ToDo on this item, nor can you log effort, because"
                          + " the system is configured to track Detail Estimate "
                          + "and ToDo at the Task/Test level.");
              }
          } else if (level == TrackingLevel.PrimaryWorkitem) {
              throw new IllegalStateException("You cannot set DetailEstimate or "
                      + "ToDo on this item, nor can you log effort, because the "
                      + "system is configured to track Detail Estimate and ToDo "
                      + "at the Story/Defect level.");
          }
      }
docs: Call this before setting DetailEstimate or ToDo on a workitem.
  
  @param workitem DetailEstimate or ToDo will be set for.
  @throws IllegalStateException If setting DetailEstimate is not allowed at
  this level.