Пример #1
1
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public boolean eIsSet(int featureID) {
   switch (featureID) {
     case ModelPackage.PTC_RESISTANCE__LOGGER:
       return LOGGER_EDEFAULT == null ? logger != null : !LOGGER_EDEFAULT.equals(logger);
     case ModelPackage.PTC_RESISTANCE__UID:
       return UID_EDEFAULT == null ? uid != null : !UID_EDEFAULT.equals(uid);
     case ModelPackage.PTC_RESISTANCE__POLL:
       return poll != POLL_EDEFAULT;
     case ModelPackage.PTC_RESISTANCE__ENABLED_A:
       return ENABLED_A_EDEFAULT == null ? enabledA != null : !ENABLED_A_EDEFAULT.equals(enabledA);
     case ModelPackage.PTC_RESISTANCE__SUB_ID:
       return SUB_ID_EDEFAULT == null ? subId != null : !SUB_ID_EDEFAULT.equals(subId);
     case ModelPackage.PTC_RESISTANCE__MBRICK:
       return getMbrick() != null;
     case ModelPackage.PTC_RESISTANCE__SENSOR_VALUE:
       return sensorValue != null;
     case ModelPackage.PTC_RESISTANCE__TF_CONFIG:
       return tfConfig != null;
     case ModelPackage.PTC_RESISTANCE__CALLBACK_PERIOD:
       return callbackPeriod != CALLBACK_PERIOD_EDEFAULT;
     case ModelPackage.PTC_RESISTANCE__DEVICE_TYPE:
       return DEVICE_TYPE_EDEFAULT == null
           ? deviceType != null
           : !DEVICE_TYPE_EDEFAULT.equals(deviceType);
     case ModelPackage.PTC_RESISTANCE__THRESHOLD:
       return THRESHOLD_EDEFAULT == null
           ? threshold != null
           : !THRESHOLD_EDEFAULT.equals(threshold);
   }
   return super.eIsSet(featureID);
 }
  public void testNumeric() throws Throwable {

    CallableStatement call = con.prepareCall("{ call Numeric_Proc(?,?,?) }");

    call.registerOutParameter(1, Types.NUMERIC, 15);
    call.registerOutParameter(2, Types.NUMERIC, 15);
    call.registerOutParameter(3, Types.NUMERIC, 15);

    call.executeUpdate();
    java.math.BigDecimal ret = call.getBigDecimal(1);
    assertTrue(
        "correct return from getNumeric () should be 999999999999999.000000000000000 but returned "
            + ret.toString(),
        ret.equals(new java.math.BigDecimal("999999999999999.000000000000000")));

    ret = call.getBigDecimal(2);
    assertTrue(
        "correct return from getNumeric ()",
        ret.equals(new java.math.BigDecimal("0.000000000000001")));
    try {
      ret = call.getBigDecimal(3);
    } catch (NullPointerException ex) {
      assertTrue("This should be null", call.wasNull());
    }
  }
Пример #3
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   final OrderProduct other = (OrderProduct) obj;
   if (finalPrice == null) {
     if (other.finalPrice != null) return false;
   } else if (!finalPrice.equals(other.finalPrice)) return false;
   if (onetimeCharge == null) {
     if (other.onetimeCharge != null) return false;
   } else if (!onetimeCharge.equals(other.onetimeCharge)) return false;
   if (orderId != other.orderId) return false;
   if (orderProductId != other.orderProductId) return false;
   if (productId != other.productId) return false;
   if (productIsFree != other.productIsFree) return false;
   if (productModel == null) {
     if (other.productModel != null) return false;
   } else if (!productModel.equals(other.productModel)) return false;
   if (productName == null) {
     if (other.productName != null) return false;
   } else if (!productName.equals(other.productName)) return false;
   if (productPrice == null) {
     if (other.productPrice != null) return false;
   } else if (!productPrice.equals(other.productPrice)) return false;
   if (productQuantity != other.productQuantity) return false;
   if (productTax == null) {
     if (other.productTax != null) return false;
   } else if (!productTax.equals(other.productTax)) return false;
   return true;
 }
Пример #4
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (!super.equals(obj)) return false;
   if (getClass() != obj.getClass()) return false;
   Bar other = (Bar) obj;
   if (close == null) {
     if (other.close != null) return false;
   } else if (!close.equals(other.close)) return false;
   if (high == null) {
     if (other.high != null) return false;
   } else if (!high.equals(other.high)) return false;
   if (interval == null) {
     if (other.interval != null) return false;
   } else if (!interval.equals(other.interval)) return false;
   if (low == null) {
     if (other.low != null) return false;
   } else if (!low.equals(other.low)) return false;
   if (open == null) {
     if (other.open != null) return false;
   } else if (!open.equals(other.open)) return false;
   if (volume == null) {
     if (other.volume != null) return false;
   } else if (!volume.equals(other.volume)) return false;
   return true;
 }
  /**
   * Receives a List of values that have been processed and compares them against this instance's
   * operatorsList, comparator, and constant members. First, operators are applied and the
   * appropriate math is executed. Next, the comparator is evaluated with the previous operation and
   * the constant member. Finally, The result of that comparison is returned.
   *
   * @param achievementValues
   * @return boolean
   */
  public boolean processRuleEvaluation(List<Integer> achievementValues) {

    // achievementValues are the values from the object being evaluated
    // get the first, in case it is the only entry.
    boolean achievementGranted = false;
    if (achievementValues != null && !achievementValues.isEmpty()) {
      BigDecimal total = new BigDecimal(achievementValues.get(0));
      int operatorCount = 0;
      for (Integer value : achievementValues.subList(1, achievementValues.size())) {

        // for the rest of the list, get an operator and do the math.
        Operators operator = operatorsList.get(operatorCount);
        BigDecimal valueBigDecimal = new BigDecimal(value);
        switch (operator) {
          case ADD:
            total = total.add(valueBigDecimal);
            break;
          case DIVIDE:
            if (!valueBigDecimal.equals(new BigDecimal(0))) {
              total = total.divide(valueBigDecimal, 2, RoundingMode.HALF_UP);
              break;
            }
          case MULTIPLY:
            total = total.multiply(valueBigDecimal);
            break;
          case SUBTRACT:
            total = total.subtract(valueBigDecimal);
            break;
        }
        operatorCount++;
      }

      // Depending on the comparator, do a different evaluation to the constant
      switch (comparator) {
        case EQUAL:
          achievementGranted = total.equals(constant);
          break;
        case GREATER_THAN:
          achievementGranted = total.compareTo(constant) == 1;
          break;
        case GREATER_THAN_OR_EQUAL:
          achievementGranted = total.compareTo(constant) == 0 || total.compareTo(constant) == 1;
          break;
        case LESS_THAN:
          achievementGranted = total.compareTo(constant) == -1;
          break;
        case LESS_THAN_OR_EQUAL:
          achievementGranted = total.compareTo(constant) == 0 || total.compareTo(constant) == -1;
          break;
        case NOT_EQUAL:
          achievementGranted = !total.equals(constant);
          break;
      }
    }
    return achievementGranted;
  }
Пример #6
0
  private static boolean _equalsForBigDecimal(BigDecimal a, Number b, Class<?> bc) {
    if (bc == BigInteger.class) {
      return a.equals(new BigDecimal((BigInteger) b));
    }

    if ((bc == Double.class) || (bc == Float.class)) {
      return a.equals(new BigDecimal(b.doubleValue()));
    }

    return a.equals(BigDecimal.valueOf(b.longValue()));
  }
  public void verificar(ActionEvent actionEvent) {
    actualizarValores();
    if (totalDebe.equals(totalHaber)
        && totalDebe.compareTo(BigDecimal.ZERO) > 0
        && totalHaber.compareTo(BigDecimal.ZERO) > 0) {
      List<Transaccion> transacciones = beanAsiento.getTransacciones();
      List<Transaccion> tSalida = new ArrayList<>();

      for (Transaccion t : transacciones) {
        if (t.getIdcodcuenta() != null
            && (t.getDebe() != BigDecimal.ZERO || t.getHaber() != BigDecimal.ZERO)) {
          tSalida.add(t);
        }
      }

      BigDecimal tdebe = BigDecimal.ZERO;
      BigDecimal thaber = BigDecimal.ZERO;

      for (Transaccion tSalida1 : tSalida) {
        tdebe = tdebe.add(tSalida1.getDebe().setScale(2, BigDecimal.ROUND_HALF_UP));
        thaber = thaber.add(tSalida1.getHaber().setScale(2, BigDecimal.ROUND_HALF_UP));
      }
      //
      if (thaber.equals(tdebe)) {
        List<Asiento> asientosAux = asientoFacade.findAll();
        int numAsiento = asientosAux.size() + 1;

        Asiento asientoAux = new Asiento();
        asientoAux.setIdcodasiento(numAsiento);
        asientoAux.setNumasiento(numAsiento);
        asientoAux.setNumdiario(beanAsiento.getNumDiario());
        asientoAux.setPeriodo(beanAsiento.getPeriodo());
        asientoAux.setFecha(beanAsiento.getFecha());
        asientoAux.setDebe(tdebe);
        asientoAux.setHaber(thaber);
        asientoAux.setConcepto(beanAsiento.getConcepto());
        asientoAux.setDocumento(beanAsiento.getDocumento());

        for (Transaccion t : tSalida) {
          t.setIdcodasiento(asientoAux);
          // transaccionFacade.create(t);
        }
        asientoAux.setTransaccionList(tSalida);
        asientoFacade.create(asientoAux);

        asientos = asientoFacade.findAll();
        JsfUtil.addSuccessMessage("Ahora puede Finalizar");
      } else {
        JsfUtil.addErrorMessage("Verifique los valores");
      }
    } else {
      JsfUtil.addErrorMessage("Verifique los valores");
    }
  }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public boolean eIsSet(int featureID) {
   switch (featureID) {
     case ExtensionsPackage.EXTENDED_ADDRESS__LATITUDE:
       return LATITUDE_EDEFAULT == null ? latitude != null : !LATITUDE_EDEFAULT.equals(latitude);
     case ExtensionsPackage.EXTENDED_ADDRESS__LONGITUDE:
       return LONGITUDE_EDEFAULT == null
           ? longitude != null
           : !LONGITUDE_EDEFAULT.equals(longitude);
   }
   return super.eIsSet(featureID);
 }
Пример #9
0
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public boolean eIsSet(int featureID) {
   switch (featureID) {
     case Gml311Package.COORD_TYPE__X:
       return X_EDEFAULT == null ? x != null : !X_EDEFAULT.equals(x);
     case Gml311Package.COORD_TYPE__Y:
       return Y_EDEFAULT == null ? y != null : !Y_EDEFAULT.equals(y);
     case Gml311Package.COORD_TYPE__Z:
       return Z_EDEFAULT == null ? z != null : !Z_EDEFAULT.equals(z);
   }
   return super.eIsSet(featureID);
 }
Пример #10
0
  private boolean filter(Location location) {
    BigDecimal longitude =
        (new BigDecimal(location.getLongitude())).setScale(ACCURACY, BigDecimal.ROUND_HALF_UP);

    BigDecimal latitude =
        (new BigDecimal(location.getLatitude())).setScale(ACCURACY, BigDecimal.ROUND_HALF_UP);

    if (latitude.equals(lastLatitude) && longitude.equals(lastLongitude)) {
      return false;
    }

    lastLatitude = latitude;
    lastLongitude = longitude;
    return true;
  }
Пример #11
0
  long readBigint() {

    boolean minus = false;

    if (token.tokenType == Tokens.MINUS) {
      minus = true;

      read();
    }

    checkIsValue();

    if (minus
        && token.dataType.typeCode == Types.SQL_NUMERIC
        && LONG_MAX_VALUE_INCREMENT.equals(token.tokenValue)) {
      read();

      return Long.MIN_VALUE;
    }

    if (token.dataType.typeCode != Types.SQL_INTEGER
        && token.dataType.typeCode != Types.SQL_BIGINT) {
      throw Error.error(ErrorCode.X_42565);
    }

    long val = ((Number) token.tokenValue).longValue();

    if (minus) {
      val = -val;
    }

    read();

    return val;
  }
Пример #12
0
    /** {@inheritDoc} */
    @SuppressWarnings({"BigDecimalEquals", "EqualsHashCodeCalledOnUrl", "RedundantIfStatement"})
    @Override
    public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;

      TestObject that = (TestObject) o;

      if (id != that.id) return false;
      if (!Arrays.equals(arrVal, that.arrVal)) return false;
      if (bigVal != null ? !bigVal.equals(that.bigVal) : that.bigVal != null) return false;
      if (boolVal != null ? !boolVal.equals(that.boolVal) : that.boolVal != null) return false;
      if (byteVal != null ? !byteVal.equals(that.byteVal) : that.byteVal != null) return false;
      if (dateVal != null ? !dateVal.equals(that.dateVal) : that.dateVal != null) return false;
      if (doubleVal != null ? !doubleVal.equals(that.doubleVal) : that.doubleVal != null)
        return false;
      if (f1 != null ? !f1.equals(that.f1) : that.f1 != null) return false;
      if (f2 != null ? !f2.equals(that.f2) : that.f2 != null) return false;
      if (f3 != null ? !f3.equals(that.f3) : that.f3 != null) return false;
      if (floatVal != null ? !floatVal.equals(that.floatVal) : that.floatVal != null) return false;
      if (intVal != null ? !intVal.equals(that.intVal) : that.intVal != null) return false;
      if (longVal != null ? !longVal.equals(that.longVal) : that.longVal != null) return false;
      if (shortVal != null ? !shortVal.equals(that.shortVal) : that.shortVal != null) return false;
      if (strVal != null ? !strVal.equals(that.strVal) : that.strVal != null) return false;
      if (timeVal != null ? !timeVal.equals(that.timeVal) : that.timeVal != null) return false;
      if (tsVal != null ? !tsVal.equals(that.tsVal) : that.tsVal != null) return false;
      if (urlVal != null ? !urlVal.equals(that.urlVal) : that.urlVal != null) return false;

      return true;
    }
Пример #13
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    CheckInfo that = (CheckInfo) o;

    if (getId() != that.getId()) return false;
    if (chkStatus != null ? !chkStatus.equals(that.chkStatus) : that.chkStatus != null)
      return false;
    if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null)
      return false;
    if (partnerId != null ? !partnerId.equals(that.partnerId) : that.partnerId != null)
      return false;
    if (productCode != null ? !productCode.equals(that.productCode) : that.productCode != null)
      return false;
    if (productName != null ? !productName.equals(that.productName) : that.productName != null)
      return false;
    if (productType != null ? !productType.equals(that.productType) : that.productType != null)
      return false;
    if (tradeAmount != null ? !tradeAmount.equals(that.tradeAmount) : that.tradeAmount != null)
      return false;
    if (tradeDate != null ? !tradeDate.equals(that.tradeDate) : that.tradeDate != null)
      return false;
    if (tradeNo != null ? !tradeNo.equals(that.tradeNo) : that.tradeNo != null) return false;
    if (tradeType != null ? !tradeType.equals(that.tradeType) : that.tradeType != null)
      return false;
    if (updateTime != null ? !updateTime.equals(that.updateTime) : that.updateTime != null)
      return false;

    return true;
  }
  // Gauss-Legendre Algorithm
  public static BigDecimal calculatePi() {
    BigDecimal a = ONE;
    BigDecimal b = ONE.divide(sqrt(TWO, SCALE), SCALE, BigDecimal.ROUND_HALF_UP);
    BigDecimal t = new BigDecimal(0.25);
    BigDecimal x = ONE;
    BigDecimal y;

    while (!a.equals(b)) {
      y = a;

      // a = (a + b)/2
      a = a.add(b).divide(TWO, SCALE, BigDecimal.ROUND_HALF_UP);

      // b = sqrt(b*y)
      b = sqrt(b.multiply(y), SCALE);

      // t -= x*((y - a)^2)
      t = t.subtract(x.multiply(y.subtract(a).multiply(y.subtract(a))));

      // x *= 2
      x = x.multiply(TWO);
    }
    // a + (a+b)/(4)
    return a.add(b).multiply(a.add(b)).divide(t.multiply(FOUR), SCALE, BigDecimal.ROUND_HALF_UP);
  }
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (!(obj instanceof Customer)) return false;
   Customer other = (Customer) obj;
   if (address == null) {
     if (other.address != null) return false;
   } else if (!address.equals(other.address)) return false;
   if (creditRequests == null) {
     if (other.creditRequests != null) return false;
   } else if (!creditRequests.equals(other.creditRequests)) return false;
   if (customerId != other.customerId) return false;
   if (disbursementPreference == null) {
     if (other.disbursementPreference != null) return false;
   } else if (!disbursementPreference.equals(other.disbursementPreference)) return false;
   if (firstName == null) {
     if (other.firstName != null) return false;
   } else if (!firstName.equals(other.firstName)) return false;
   if (lastName == null) {
     if (other.lastName != null) return false;
   } else if (!lastName.equals(other.lastName)) return false;
   if (middleName == null) {
     if (other.middleName != null) return false;
   } else if (!middleName.equals(other.middleName)) return false;
   if (openBalance == null) {
     if (other.openBalance != null) return false;
   } else if (!openBalance.equals(other.openBalance)) return false;
   if (rating == null) {
     if (other.rating != null) return false;
   } else if (!rating.equals(other.rating)) return false;
   return true;
 }
    @Override
    public boolean equals(Object o) {
      if (this == o) {
        return true;
      }
      if (o == null || getClass() != o.getClass()) {
        return false;
      }

      ComplexObject that = (ComplexObject) o;

      if (map != null ? !map.equals(that.map) : that.map != null) {
        return false;
      }
      if (name != null ? !name.equals(that.name) : that.name != null) {
        return false;
      }
      if (number != null ? !number.equals(that.number) : that.number != null) {
        return false;
      }
      if (obj != null ? !obj.equals(that.obj) : that.obj != null) {
        return false;
      }

      return true;
    }
Пример #17
0
  public static void main(String[] args) throws ParseException {
    //        ZoneId america = ZoneId.of("America/New_York");
    //        ZoneId zone0 = ZoneId.of("UTC+00:00");
    //        ZoneId zone8 = ZoneId.of("UTC+08:00");
    //        ZoneOffset offset = ZoneOffset.UTC;
    //        LocalDateTime nowOfHere = LocalDateTime.now();
    //        ZonedDateTime timePoint8 =ZonedDateTime.of(nowOfHere, zone8);
    //        ZonedDateTime timePoint0 = timePoint8.withZoneSameInstant(zone0);
    //
    //        System.out.println(timePoint8);
    //        System.out.println(timePoint0);

    double f1 = 299.0F / 31;
    double f2 = f1 * 31;
    System.out.println(f1);
    System.out.println(f2);
    System.out.println(f2 == 299.0d);
    if (f2 - 299.0 < 0.0001) {
      System.out.println("equals");
    }

    BigDecimal bd1 = new BigDecimal(299);
    BigDecimal bd2 = bd1.divide(new BigDecimal(31), 5, BigDecimal.ROUND_CEILING);
    BigDecimal bd3 = bd2.multiply(new BigDecimal(31));
    System.out.println(bd1);
    System.out.println(bd2);
    System.out.println(bd3);
    System.out.println(bd1.equals(bd3));
  }
  public String lineDiscountString() {
    StringBuffer result = new StringBuffer();
    BigDecimal rate = BigDecimal.ZERO;
    BigDecimal value = BigDecimal.ZERO;
    boolean percentage = true;
    if (getProductType().equals(ProductType.Product)) {
      rate = getDiscount().getRate();
      value = getDiscount().getValue();
      percentage = getDiscount().getPercentage();

    } else if (getProductType().equals(ProductType.Discount)) {
      rate = getDiscount().getRate();
      value = getAmount().getValue();
      percentage = getDiscount().getPercentage();

    } else if (getProductType().equals(ProductType.DocumentDiscount)
        || getProductType().equals(ProductType.ContactDiscount)) {
      rate = getDiscount().getRate();
      value = getDiscount().getValue();
      percentage = getDiscount().getPercentage();
    }
    if (percentage && !rate.equals(BigDecimal.ZERO)) {
      result
          .append(getNumberFormat().format(value))
          .append("(%")
          .append(getNumberFormat().format(rate))
          .append(")");
    } else {
      result.append(getNumberFormat().format(value));
    }
    return result.toString();
  }
Пример #19
0
  public static BigDecimal get(final BigDecimal n) {

    // Make sure n is a positive number

    if (n.compareTo(ZERO) <= 0) {
      throw new IllegalArgumentException();
    }

    final BigDecimal initialGuess = getInitialApproximation(n);
    BigDecimal lastGuess = ZERO;
    BigDecimal guess = new BigDecimal(initialGuess.toString());

    // Iterate

    iterations = 0;
    boolean more = true;
    while (more) {
      lastGuess = guess;
      guess = n.divide(guess, scale, BigDecimal.ROUND_HALF_UP);
      guess = guess.add(lastGuess);
      guess = guess.divide(TWO, scale, BigDecimal.ROUND_HALF_UP);
      error = n.subtract(guess.multiply(guess));
      if (++iterations >= maxIterations) {
        more = false;
      } else if (lastGuess.equals(guess)) {
        more = error.abs().compareTo(ONE) >= 0;
      }
    }
    return guess;
  }
Пример #20
0
 /*
  * (non-Javadoc)
  *
  * @see java.lang.Object#equals(java.lang.Object)
  */
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   ExchangeRate other = (ExchangeRate) obj;
   if (base == null) {
     if (other.base != null) return false;
   } else if (!base.equals(other.base)) return false;
   if (chain[0] != this) {
     if (!Arrays.equals(chain, other.chain)) return false;
   }
   if (exchangeRateType == null) {
     if (other.exchangeRateType != null) return false;
   } else if (!exchangeRateType.equals(other.exchangeRateType)) return false;
   if (factor == null) {
     if (other.factor != null) return false;
   } else if (!factor.equals(other.factor)) return false;
   if (provider == null) {
     if (other.provider != null) return false;
   } else if (!provider.equals(other.provider)) return false;
   if (term == null) {
     if (other.term != null) return false;
   } else if (!term.equals(other.term)) return false;
   if (validFrom == null) {
     if (other.validFrom != null) return false;
   } else if (!validFrom.equals(other.validFrom)) return false;
   if (validUntil == null) {
     if (other.validUntil != null) return false;
   } else if (!validUntil.equals(other.validUntil)) return false;
   return true;
 }
Пример #21
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   RealEstateEntity other = (RealEstateEntity) obj;
   if (address == null) {
     if (other.address != null) return false;
   } else if (!address.equals(other.address)) return false;
   if (create_ == null) {
     if (other.create_ != null) return false;
   } else if (!create_.equals(other.create_)) return false;
   if (description == null) {
     if (other.description != null) return false;
   } else if (!description.equals(other.description)) return false;
   if (id == null) {
     if (other.id != null) return false;
   } else if (!id.equals(other.id)) return false;
   if (owner == null) {
     if (other.owner != null) return false;
   } else if (!owner.equals(other.owner)) return false;
   if (price == null) {
     if (other.price != null) return false;
   } else if (!price.equals(other.price)) return false;
   return true;
 }
  @Override
  protected IndicatorValueEntity calculateIndicatorValueForArea(
      IndicatorEntity indicator,
      FrequencyEntity frequency,
      AreaEntity area,
      Date from,
      Date to,
      String category) {
    BigDecimal numeratorValue = calculateDwQueryValue(indicator.getNumerator(), area, from, to);
    BigDecimal denominatorValue;
    BigDecimal result = null;
    if (indicator.getDenominator() != null) {
      result = calculateDwQueryValue(indicator.getDenominator(), area, from, to);
    }

    if (result == null) {
      denominatorValue = BigDecimal.ONE;
    } else if (result.equals(BigDecimal.ZERO)) {
      numeratorValue = BigDecimal.ZERO;
      denominatorValue = BigDecimal.ONE;
    } else {
      denominatorValue = result;
    }

    return prepareIndicatorValueEntity(numeratorValue, denominatorValue);
  }
 /**
  * determine the change in q if a node were to move to the given community.
  *
  * @param currCommunityId
  * @param testCommunityId
  * @param testSigmaTot
  * @param edgeWeightInCommunity (sum of weight of edges from this ndoe to target community)
  * @param nodeWeight (the node degree)
  * @param internalWeight
  * @return
  */
 private BigDecimal q(
     String currCommunityId,
     String testCommunityId,
     long testSigmaTot,
     long edgeWeightInCommunity,
     long nodeWeight,
     long internalWeight) {
   boolean isCurrentCommunity = (currCommunityId.equals(testCommunityId));
   BigDecimal M = new BigDecimal(Long.toString(getTotalEdgeWeight()));
   long k_i_in_L =
       (isCurrentCommunity) ? edgeWeightInCommunity + internalWeight : edgeWeightInCommunity;
   BigDecimal k_i_in = new BigDecimal(Long.toString(k_i_in_L));
   BigDecimal k_i = new BigDecimal(Long.toString(nodeWeight + internalWeight));
   BigDecimal sigma_tot = new BigDecimal(Long.toString(testSigmaTot));
   if (isCurrentCommunity) {
     sigma_tot = sigma_tot.subtract(k_i);
   }
   // diouble sigma_tot_temp = (isCurrentCommunity) ? testSigmaTot - k_i :
   // testSigmaTot;
   BigDecimal deltaQ = new BigDecimal("0.0");
   if (!(isCurrentCommunity && sigma_tot.equals(deltaQ))) {
     BigDecimal dividend = k_i.multiply(sigma_tot);
     int scale = 20;
     deltaQ = k_i_in.subtract(dividend.divide(M, scale, RoundingMode.HALF_DOWN));
   }
   return deltaQ;
 }
Пример #24
0
  /*----------------------------------
  @Author: Jorge Vidal - Disytel
  @Fecha: 05/09/2006
  @Comentario: Actualiza el total que corresponde a las lineas
  @Parametros:
  -------------------------------------------*/
  public void checkLines() {
    StringBuffer sql =
        new StringBuffer(
            "SELECT SUM(PAYMENT_AMT) FROM M_BOLETADEPOSITOLINE WHERE M_BOLETADEPOSITO_ID=? ");

    PreparedStatement pstmt = null;
    try {
      pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
      pstmt.setInt(1, getM_BoletaDeposito_ID());
      ResultSet rs = pstmt.executeQuery();
      if (rs.next()) {
        BigDecimal total = rs.getBigDecimal(1);
        if (!(total.equals(getGrandTotal()))) {
          setGrandTotal(total);
          save();
        }
      }

      rs.close();
      pstmt.close();
      pstmt = null;
    } catch (Exception e) {
      log.log(Level.SEVERE, "CheckLines - " + sql, e);
    } finally {
      try {
        if (pstmt != null) pstmt.close();
      } catch (Exception e) {
      }
      pstmt = null;
    }
  }
Пример #25
0
  public BigFraction(BigDecimal numerator, BigDecimal denominator) {
    if (denominator.equals(BigDecimal.ZERO)) throw new ArithmeticException("Divide by zero.");

    BigFraction tmp = new BigFraction(numerator).divide(new BigFraction(denominator));
    this.numerator = tmp.numerator;
    this.denominator = tmp.denominator;
  }
Пример #26
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   RangeKeyClass other = (RangeKeyClass) obj;
   if (bigDecimalAttribute == null) {
     if (other.bigDecimalAttribute != null) return false;
   } else if (!bigDecimalAttribute.equals(other.bigDecimalAttribute)) return false;
   if (integerSetAttribute == null) {
     if (other.integerSetAttribute != null) return false;
   } else if (!integerSetAttribute.equals(other.integerSetAttribute)) return false;
   if (key != other.key) return false;
   if (Double.doubleToLongBits(rangeKey) != Double.doubleToLongBits(other.rangeKey)) return false;
   if (stringAttribute == null) {
     if (other.stringAttribute != null) return false;
   } else if (!stringAttribute.equals(other.stringAttribute)) return false;
   if (stringSetAttribute == null) {
     if (other.stringSetAttribute != null) return false;
   } else if (!stringSetAttribute.equals(other.stringSetAttribute)) return false;
   if (version == null) {
     if (other.version != null) return false;
   } else if (!version.equals(other.version)) return false;
   return true;
 }
Пример #27
0
  public static ArrayList<BigDecimal> factors(BigDecimal query) {
    if (query.equals(new BigDecimal("0"))) {
      return null;
    }

    ArrayList<BigDecimal> factors = new ArrayList<BigDecimal>();

    BigDecimal sqrt = sqrt(query);

    if (sqrt.remainder(new BigDecimal("1")).equals(new BigDecimal("0"))) {
      factors.add(sqrt);
    }

    for (float i = 1; i < sqrt.floatValue(); i++) {
      // simplifying assumption
      if (factors.size() > 2) {
        break;
      }

      String m = Float.toString(i);
      BigDecimal otherFactor = query.divide(new BigDecimal(m), MathContext.DECIMAL128);

      if (query
              .divide(new BigDecimal(m), MathContext.DECIMAL128)
              .remainder(new BigDecimal(1))
              .floatValue()
          == 0) {
        factors.add(new BigDecimal(m));
        factors.add(query.divide(new BigDecimal(m)));
      }
    }

    return factors;
  }
Пример #28
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   Weather other = (Weather) obj;
   if (location == null) {
     if (other.location != null) return false;
   } else if (!location.equals(other.location)) return false;
   if (observationTime == null) {
     if (other.observationTime != null) return false;
   } else if (!observationTime.equals(other.observationTime)) return false;
   if (relativeHumidity == null) {
     if (other.relativeHumidity != null) return false;
   } else if (!relativeHumidity.equals(other.relativeHumidity)) return false;
   if (temperature == null) {
     if (other.temperature != null) return false;
   } else if (!temperature.equals(other.temperature)) return false;
   if (weatherDescription == null) {
     if (other.weatherDescription != null) return false;
   } else if (!weatherDescription.equals(other.weatherDescription)) return false;
   if (windDescription == null) {
     if (other.windDescription != null) return false;
   } else if (!windDescription.equals(other.windDescription)) return false;
   if (windDirection == null) {
     if (other.windDirection != null) return false;
   } else if (!windDirection.equals(other.windDirection)) return false;
   return true;
 }
 protected Boolean decodeBoolean(BigDecimal bigDecimal) {
   if (bigDecimal.equals(BigDecimal.ONE)) {
     return Boolean.TRUE;
   } else {
     return Boolean.FALSE;
   }
 }
Пример #30
0
  @Override
  public boolean equals(Object obj) {
    if (this == obj) return true;
    if (obj == null) return false;
    if (getClass() != obj.getClass()) return false;
    final Artikel other = (Artikel) obj;
    //		if (artikelUri == null) {
    //			if (other.artikelUri != null)
    //				return false;
    //		}
    //		else if (!artikelUri.equals(other.artikelUri))
    //			return false;
    if (bezeichnung == null) {
      if (other.bezeichnung != null) return false;
    } else if (!bezeichnung.equals(other.bezeichnung)) return false;

    if (id == null) {
      if (other.id != null) return false;
    } else if (!id.equals(other.id)) return false;

    if (preis == null) {
      if (other.preis != null) return false;
    } else if (!preis.equals(other.preis)) return false;
    return true;
  }