Package common.money

Examples of common.money.Percentage


  /**
   * 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


     */
    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%.
   */
  @Transient
  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

   */
  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);
    restaurant.setBenefitAvailabilityPolicy(mapBenefitAvailabilityPolicy(rs));
    return restaurant;
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

        Beneficiary beneficiary = new Beneficiary();
       
        beneficiary.setEntityId(rs.getLong("id"));
        beneficiary.setName(rs.getString("name"));
       
        Percentage percentage = new Percentage(rs.getDouble("allocation_percentage"));
        beneficiary.setAllocationPercentage(percentage);
       
        MonetaryAmount amount = new MonetaryAmount(rs.getDouble("savings"));
        beneficiary.setSavings(amount);
       
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

   */
  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

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.