View Javadoc
1   /**
2    * This file is part of Indicators.
3    *
4    * Indicators is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * Indicators is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with Indicators. If not, see <https://www.gnu.org/licenses/>.
16   */
17  package fr.inrae.agroclim.indicators.model.result;
18  
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  import fr.inrae.agroclim.indicators.model.AnnualPhase;
23  import lombok.Getter;
24  import lombok.Setter;
25  import lombok.ToString;
26  
27  /**
28   * Normalized value of a phase for a year and values of composed indicators.
29   *
30   * Last changed : $Date$
31   *
32   * @author Olivier Maury
33   * @author $Author$
34   * @version $Revision$
35   */
36  @ToString
37  public final class PhaseResult extends Result {
38  
39      /**
40       * Phase details.
41       */
42      @Getter
43      @Setter
44      private AnnualPhase annualPhase;
45  
46      /**
47       * Values of indicators.
48       */
49      @Getter
50      private final List<IndicatorResult> indicatorResults = new ArrayList<>();
51  
52      /**
53       * @return phase id with "+" and "-" replaced.
54       */
55      public String getEncodedPhaseId() {
56          if (annualPhase == null) {
57              return null;
58          }
59          String phaseId = annualPhase.getUid();
60          return phaseId.replace("+", "p").replace("-", "m");
61      }
62  
63      /**
64       * @return phase id
65       */
66      public String getPhaseId() {
67          if (annualPhase == null) {
68              return null;
69          }
70          return annualPhase.getUid();
71      }
72  }