Package common.money

Examples of common.money.Percentage


   * @throws SQLException an exception occurred extracting data from the result set
   */
  private Beneficiary mapBeneficiary(ResultSet rs) throws SQLException {
    String name = rs.getString("BENEFICIARY_NAME");
    MonetaryAmount savings = MonetaryAmount.valueOf(rs.getString("BENEFICIARY_SAVINGS"));
    Percentage allocationPercentage = Percentage.valueOf(rs.getString("BENEFICIARY_ALLOCATION_PERCENTAGE"));
    return new Beneficiary(name, allocationPercentage, savings);
  }
View Full Code Here


   */
  private Restaurant mapRestaurant(ResultSet rs) throws SQLException {
    // get the row column data
    String name = rs.getString("NAME");
    String number = rs.getString("MERCHANT_NUMBER");
    Percentage benefitPercentage = Percentage.valueOf(rs.getString("BENEFIT_PERCENTAGE"));
    // map to the object
    Restaurant restaurant = new Restaurant(number, name);
    restaurant.setBenefitPercentage(benefitPercentage);
    restaurant.setBenefitAvailabilityPolicy(mapBenefitAvailabilityPolicy(rs));
    return restaurant;
View Full Code Here

   */
  private Restaurant mapRestaurant(ResultSet rs) throws SQLException {
    // get the row column data
    String name = rs.getString("NAME");
    String number = rs.getString("MERCHANT_NUMBER");
    Percentage benefitPercentage = Percentage.valueOf(rs.getString("BENEFIT_PERCENTAGE"));
    // map to the object
    Restaurant restaurant = new Restaurant(number, name);
    restaurant.setBenefitPercentage(benefitPercentage);
    return restaurant;
  }
View Full Code Here

    if (name == null) {
      // apparently no beneficiary for this
      return null;
    }   
    MonetaryAmount savings = MonetaryAmount.valueOf(rs.getString("BENEFICIARY_SAVINGS"));
    Percentage allocationPercentage = Percentage.valueOf(rs.getString("BENEFICIARY_ALLOCATION_PERCENTAGE"));
    return new Beneficiary(name, allocationPercentage, savings);
  }
View Full Code Here

  /**
   * Validation check that returns true only if the total beneficiary allocation adds up to 100%.
   */
  public boolean isValid() {
    Percentage totalPercentage = Percentage.zero();
    for (Beneficiary b : beneficiaries) {
      try {
        totalPercentage = totalPercentage.add(b.getAllocationPercentage());
      } catch (IllegalArgumentException e) {
        // total would have been over 100% - return invalid
        return false;
      }
    }
    if (totalPercentage.equals(Percentage.oneHundred())) {
      return true;
    } else {
      return false;
    }
  }
View Full Code Here

   * @throws SQLException an exception occurred extracting data from the result set
   */
  private Beneficiary mapBeneficiary(ResultSet rs) throws SQLException {
    String name = rs.getString("BENEFICIARY_NAME");
    MonetaryAmount savings = MonetaryAmount.valueOf(rs.getString("BENEFICIARY_SAVINGS"));
    Percentage allocationPercentage = Percentage.valueOf(rs.getString("BENEFICIARY_ALLOCATION_PERCENTAGE"));
    return new Beneficiary(name, allocationPercentage, savings);
  }
View Full Code Here

  /**
   * Validation check that returns true only if the total beneficiary allocation adds up to 100%.
   */
  public boolean isValid() {
    Percentage totalPercentage = Percentage.zero();
    for (Beneficiary b : beneficiaries) {
      totalPercentage = totalPercentage.add(b.getAllocationPercentage());
    }
    if (totalPercentage.equals(Percentage.oneHundred())) {
      return true;
    } else {
      return false;
    }
  }
View Full Code Here

  /**
   * Validation check that returns true only if the total beneficiary allocation adds up to 100%.
   */
  //TODO 8: Add annotation indicating that there is an attribute to persist.
  public boolean isValid() {
    Percentage totalPercentage = Percentage.zero();
    for (Beneficiary b : beneficiaries) {
      try {
        totalPercentage = totalPercentage.add(b.getAllocationPercentage());
      } catch (IllegalArgumentException e) {
        // total would have been over 100% - return invalid
        return false;
      }
    }
    if (totalPercentage.equals(Percentage.oneHundred())) {
      return true;
    } else {
      return false;
    }
  }
View Full Code Here

  @Override
  public Object getResult(ResultSet rs, String columnName)
      throws SQLException {
   
    double d = rs.getDouble(columnName);
        return new Percentage(d);
  }
View Full Code Here

  @Override
  public Object getResult(CallableStatement cs, int columnIndex)
      throws SQLException {
   
    double d = cs.getDouble(columnIndex);
        return new Percentage(d);
  }
View Full Code Here

TOP

Related Classes of common.money.Percentage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.