Example usage for java.lang Float isNaN

List of usage examples for java.lang Float isNaN

Introduction

In this page you can find the example usage for java.lang Float isNaN.

Prototype

public boolean isNaN() 

Source Link

Document

Returns true if this Float value is a Not-a-Number (NaN), false otherwise.

Usage

From source file:net.toxbank.client.resource.InvestigationClient.java

/**
 * Gets the list of investigation urls that match the given gene identifiers
 * @param rootUrl the root url of the investigation service
 * @param geneIdentifiers the list of gene identifiers to search by
 * @param value optional minimum value of the given type
 * @param valueType the type of value to search by
 * @param comparator the comparator to use
 * @return the list of investigation entries
 *///from  w w w .j a  v  a  2s .c o  m
public List<TimestampedUrl> findByGeneIdentifiers(URL rootUrl, List<String> geneIdentifiers, Float value,
        ValueType valueType, ComparatorType comparator) throws Exception {
    StringBuilder sb = new StringBuilder();
    for (String gene : geneIdentifiers) {
        String geneValue = URLEncoder.encode(gene, "UTF-8");
        if (sb.length() > 0) {
            sb.append(",");
        }
        sb.append(geneValue);
    }

    String valueTypeName;
    switch (valueType) {
    case foldChange:
        valueTypeName = "FC";
        break;
    case qValue:
        valueTypeName = "qvalue";
        break;
    case pValue:
        valueTypeName = "pvalue";
        break;
    default:
        throw new RuntimeException("Unsupported value type: " + valueType);
    }

    String url;
    if (value != null && !value.isNaN()) {
        String valueString = valueTypeName + ":" + String.valueOf(value);
        valueString = URLEncoder.encode(valueString, "UTF-8");
        url = rootUrl + "/sparql/investigation_by_gene_and_value?geneIdentifiers=" + sb.toString() + "&value="
                + valueString + "&relOperator=" + comparator;
    } else {
        url = rootUrl + "/sparql/investigation_by_genes?geneIdentifiers=" + sb.toString();
    }

    JSONArray bindings = requestToJsonBindings(new URL(url), null);
    List<TimestampedUrl> results = new ArrayList<TimestampedUrl>();
    for (int i = 0; i < bindings.length(); i++) {
        JSONObject binding = bindings.getJSONObject(i);
        JSONObject invObj = binding.optJSONObject("investigation");
        if (invObj != null) {
            String invUrl = invObj.optString("value", null);
            if (invUrl != null) {
                results.add(new TimestampedUrl(new URL(invUrl), 0l));
            }
        }
    }
    return results;
}

From source file:com.inkubator.hrm.service.impl.TempAttendanceRealizationServiceImpl.java

private Float calculateAndCheckTotalOverTime(List<ImplementationOfOverTime> listImplementationOfOverTime,
        WtPeriode wtPeriode, Long empDataId, String religionCode) throws Exception {
    Float totalOvertime = 0f;

    //Get List Holiday Schedule
    List<TempJadwalKaryawan> listJadwalLibur = tempJadwalKaryawanDao.getAllDataByEmpIdAndPeriodDateAndOffDay(
            empDataId, wtPeriode.getFromPeriode(), wtPeriode.getUntilPeriode());
    List<Date> listDateLibur = Lambda.extract(listJadwalLibur,
            Lambda.on(TempJadwalKaryawan.class).getTanggalWaktuKerja());
    Collections.sort(listDateLibur);

    //Get List Public Non Religion Holiday Schedule
    List<WtHoliday> listPublicNonReligionHoliday = wtHolidayDao.getListPublicNonReligionHolidayBetweenDate(
            wtPeriode.getFromPeriode(), wtPeriode.getUntilPeriode());
    List<Date> listPublicNonReligionHolidayDate = Lambda.extract(listPublicNonReligionHoliday,
            Lambda.on(WtHoliday.class).getHolidayDate());
    Collections.sort(listPublicNonReligionHolidayDate);

    //Get List Public Religion Holiday Schedule
    List<WtHoliday> listPublicReligionHoliday = wtHolidayDao
            .getListPublicReligionHolidayByReligionCodeAndBetweenDate(wtPeriode.getFromPeriode(),
                    wtPeriode.getUntilPeriode(), religionCode);
    List<Date> listPublicReligionHolidayDate = Lambda.extract(listPublicReligionHoliday,
            Lambda.on(WtHoliday.class).getHolidayDate());
    Collections.sort(listPublicReligionHolidayDate);

    //Looping List Overtime Implementation
    for (ImplementationOfOverTime otImpl : listImplementationOfOverTime) {

        //if overtime with null wtHitungLembur found, throw BussinessException
        if (ObjectUtils.equals(otImpl.getWtOverTime().getWtHitungLembur(), null)) {
            throw new BussinessException(
                    "workingTime.attendance_realization_calc_error_overtime_with_null_wt_hitung_lembur_found");
        }//from ww w .ja  va  2 s  .  co  m

        List<WtHitungLemburJam> listWtHitungLemburJam = wtHitungLemburJamDao
                .getListByWtHitungLemburId(otImpl.getWtOverTime().getWtHitungLembur().getId());

        Boolean isImplementedOnScheduleHoliday = Collections.binarySearch(listDateLibur,
                otImpl.getImplementationDate(), new MyDateComparator()) >= 0;
        Boolean isImplementedOnPublicNonReligionHoliday = Collections.binarySearch(
                listPublicNonReligionHolidayDate, otImpl.getImplementationDate(), new MyDateComparator()) >= 0;
        Boolean isImplementedOnPublicReligionHoliday = Collections.binarySearch(listPublicReligionHolidayDate,
                otImpl.getImplementationDate(), new MyDateComparator()) >= 0;

        //get total Overtime in hours
        Float totalHoursOvertime = DateTimeUtil
                .getTotalHoursDifference(otImpl.getStartTime(), otImpl.getEndTime()).floatValue();

        //Initialize real total hours overtime
        Float realTotalOverTime = 0f;

        //Check implementOn and calculate real total hours based on implementOn
        if (isImplementedOnScheduleHoliday || isImplementedOnPublicNonReligionHoliday) {
            realTotalOverTime = countRealOverTime(totalHoursOvertime, listWtHitungLemburJam,
                    "schduleOrPublicNonReligionHoliday");
        } else if (isImplementedOnPublicReligionHoliday) {
            realTotalOverTime = countRealOverTime(totalHoursOvertime, listWtHitungLemburJam,
                    "publicReligionHoliday");
        } else {
            realTotalOverTime = countRealOverTime(totalHoursOvertime, listWtHitungLemburJam, "workingDay");
        }

        //increment totalOvertime with each realTotalOvertime record
        totalOvertime += realTotalOverTime;

    }

    //if totalOvertime Is Not A Number than reinitialize to 0
    if (totalOvertime.isNaN()) {
        totalOvertime = 0f;
    }

    //return totalOvertime of employee during period active
    return totalOvertime;
}