Object readResolve() {
   if (amountTypeString != null) {
     amountType = AmountType.valueOf(amountTypeString);
   }
   if (buildCountTypeString != null) {
     buildCountType = BuildCountType.valueOf(buildCountTypeString);
   }
   return super.readResolve();
 }
 @DataBoundConstructor
 public AbstractBuildTrendFilter(
     String buildCountTypeString,
     float amount,
     String amountTypeString,
     String includeExcludeTypeString) {
   super(includeExcludeTypeString);
   this.buildCountTypeString = buildCountTypeString;
   this.buildCountType = BuildCountType.valueOf(buildCountTypeString);
   this.amount = amount;
   this.amountTypeString = amountTypeString;
   this.amountType = AmountType.valueOf(amountTypeString);
 }
 public ReportEntry(
     AgentRecipient beneficiary,
     String rosterTypeCode,
     AmountType amountType,
     YearMonth fundingPeriod,
     BigDecimal amount) {
   this.beneficiary = beneficiary;
   this.rosterTypeCode = rosterTypeCode;
   this.amountType = amountType;
   this.type = amountType.name();
   this.fundingPeriod = fundingPeriod;
   this.amount = amount;
 }
 public ReportEntry(
     AgentRecipient beneficiary,
     String rosterTypeCode,
     String amountType,
     Integer fundingYear,
     Integer fundingMonth,
     BigDecimal amount) {
   this.beneficiary = beneficiary;
   this.rosterTypeCode = rosterTypeCode;
   this.amountType = AmountType.valueOf(amountType);
   this.type = amountType;
   this.fundingPeriod = YearMonth.of(fundingYear, fundingMonth);
   this.amount = amount;
 }
  @SuppressWarnings("unchecked")
  protected boolean matches(TopLevelItem item) {
    if (item instanceof Job) {
      Job job = (Job) item;

      // iterate over runs and check conditions
      Run run = job.getLastBuild();
      boolean oneMatched = false;
      int count = 0;

      while (run != null) {
        // check the different types of durations to see if we've checked back far enough
        if (amount > 0 && amountType != AmountType.Builds) {
          // get the amount of time since it last built
          long now = System.currentTimeMillis();
          long then = run.getTimeInMillis();
          float diff = now - then;
          diff = amountType.convertMillisToAmount(diff);
          if (diff > amount) {
            break;
          }
        }
        // now evaluate the build status
        boolean runMatches = matchesRun(run);
        if (runMatches) {
          if (buildCountType == BuildCountType.AtLeastOne
              || buildCountType == BuildCountType.Latest) {
            return true;
          }
        } else {
          if (buildCountType == BuildCountType.All) {
            return false;
          }
        }

        // if we got this far, and the type is for "latest" then it's not going to match
        if (buildCountType == BuildCountType.Latest) {
          return false;
        }

        oneMatched = true;
        if (amount > 0 && amountType == AmountType.Builds) {
          if (++count >= amount) {
            break;
          }
        }
        run = run.getPreviousBuild();
      }
      // if we're talking about "all builds" and there was at least one build, then
      // it means no builds didn't match the filter
      if (buildCountType == BuildCountType.All && oneMatched) {
        return true;
      }

      // means we ran out of builds to check and did not find a match
      return false;
    } else {
      // wasn't of type "job"
      return false;
    }
  }