GovernmentBodyAnnualOutcomeSummary.java

  1. /*
  2.  * Copyright 2010-2019 James Pether Sörling
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *   http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  *
  16.  *  $Id$
  17.  *  $HeadURL$
  18. */
  19. package com.hack23.cia.service.external.esv.api;

  20. import java.io.Serializable;
  21. import java.util.Date;
  22. import java.util.GregorianCalendar;
  23. import java.util.HashMap;
  24. import java.util.Map;

  25. import org.apache.commons.lang3.builder.EqualsBuilder;
  26. import org.apache.commons.lang3.builder.HashCodeBuilder;
  27. import org.apache.commons.lang3.builder.ToStringBuilder;
  28. import org.apache.commons.lang3.builder.ToStringStyle;

  29. /**
  30.  * The Class GovernmentBodyAnnualOutcomeSummary.
  31.  */
  32. public final class GovernmentBodyAnnualOutcomeSummary implements Serializable {

  33.     /** The Constant serialVersionUID. */
  34.     private static final long serialVersionUID = 1L;

  35.     /** The goverment body. */
  36.     private final String govermentBody;

  37.     /** The org number. */
  38.     private final String orgNumber;
  39.    
  40.     /** The ministry. */
  41.     private final String ministry;

  42.     /** The year. */
  43.     private final int year;
  44.    
  45.     /** The year total. */
  46.     private double yearTotal;

  47.     /** The value map. */
  48.     private final Map<Date, Double> valueMap = new HashMap<>();

  49.     /** The description fields. */
  50.     private final Map<String, String> descriptionFields = new HashMap<>();

  51.     /**
  52.      * Instantiates a new government body annual outcome summary.
  53.      *
  54.      * @param govermentBody the goverment body
  55.      * @param orgNumber     the org number
  56.      * @param ministry      the ministry
  57.      * @param year          the year
  58.      */
  59.     public GovernmentBodyAnnualOutcomeSummary(final String govermentBody, final String orgNumber, final String ministry, final int year) {
  60.         super();
  61.         this.govermentBody = govermentBody;
  62.         this.orgNumber = orgNumber;
  63.         this.ministry = ministry;
  64.         this.year = year;
  65.     }

  66.     /**
  67.      * Gets the goverment body id.
  68.      *
  69.      * @return the goverment body id
  70.      */
  71.     public String getGovermentBody() {
  72.         return govermentBody;
  73.     }

  74.     /**
  75.      * Gets the org number.
  76.      *
  77.      * @return the org number
  78.      */
  79.     public String getOrgNumber() {
  80.         return orgNumber;
  81.     }

  82.     /**
  83.      * Gets the year.
  84.      *
  85.      * @return the year
  86.      */
  87.     public int getYear() {
  88.         return year;
  89.     }

  90.     /**
  91.      * Gets the ministry.
  92.      *
  93.      * @return the ministry
  94.      */
  95.     public String getMinistry() {
  96.         return ministry;
  97.     }

  98.     /**
  99.      * Adds the data.
  100.      *
  101.      * @param month
  102.      *            the month
  103.      * @param value
  104.      *            the value
  105.      */
  106.     public void addData(final int month, final Double value) {
  107.         yearTotal = yearTotal + value;
  108.         final Date date = new GregorianCalendar(year, month, 1).getTime();
  109.         valueMap.put(date, value);
  110.     }

  111.     /**
  112.      * Gets the year total.
  113.      *
  114.      * @return the year total
  115.      */
  116.     public double getYearTotal() {
  117.         return yearTotal;
  118.     }

  119.     /**
  120.      * Adds the description field.
  121.      *
  122.      * @param field
  123.      *            the field
  124.      * @param value
  125.      *            the value
  126.      */
  127.     public void addDescriptionField(final String field, final String value) {
  128.         descriptionFields.put(field, value);
  129.     }

  130.    
  131.     /**
  132.      * Gets the value map.
  133.      *
  134.      * @return the value map
  135.      */
  136.     public Map<Date, Double> getValueMap() {
  137.         return valueMap;
  138.     }

  139.     /**
  140.      * Gets the description fields.
  141.      *
  142.      * @return the description fields
  143.      */
  144.     public Map<String, String> getDescriptionFields() {
  145.         return descriptionFields;
  146.     }

  147.     /* (non-Javadoc)
  148.      * @see java.lang.Object#equals(java.lang.Object)
  149.      */
  150.     @Override
  151.     public boolean equals(final Object obj) {
  152.         return EqualsBuilder.reflectionEquals(this, obj);
  153.     }

  154.     @Override
  155.     public int hashCode() {
  156.         return HashCodeBuilder.reflectionHashCode(this);
  157.     }

  158.     @Override
  159.     public String toString() {
  160.         return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
  161.     }

  162. }