1. Java / Говнокод #3866

    +74

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    public static int count(String s) {
        int res = 0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == '1') res++;
        }
        return res;
    }
    
    public List<VDictLiability> get(String currency_id, String usedTrailer, Date actualDate, String contract_class_id, String product_id, String risk_object_type_id) {
        for(int i = 0;i<5;i++){
            int j = 0;
            while(j < 32) {
                if(count(Integer.toBinaryString(j)) == i) {
                    String s = Integer.toBinaryString(j);
                    while (s.length() != 5) {
                        s = "0" + s;
                    }
                    List<VDictLiability> result = get(currency_id, usedTrailer, actualDate, contract_class_id, product_id, risk_object_type_id, s);
                    if(result.size() > 0) return result;
                }
                j++;
            }
        }
        return Collections.EMPTY_LIST;
    }
    
    public List<VDictLiability> get(String currency_id, String usedTrailer, Date actualDate, String contract_class_id, String product_id, String risk_object_type_id, String mask) {
        String territoryCode = App.config.getCurrentBrunchCode().substring(1, 3);
        
    ...
        
        HashMap<Double, VDictLiability> map = new HashMap<Double, VDictLiability>();
        for (VDictLiability liabilityRow : get()) {
            if(!territoryType.equals(liabilityRow.getterritory_type_id()) && !(mask.charAt(4) == '1' && liabilityRow.getterritory_type_id() == null)){
                continue;
            }
            if(actualDate != null && !CompareUtil.isInside(liabilityRow.getstart_date(), liabilityRow.getend_date(), actualDate)){
                continue;
            }
            if(((risk_object_type_id != null && !CompareUtil.isEquals(liabilityRow.getrisk_object_type_id(), risk_object_type_id)) && !(mask.charAt(0) == '1' && liabilityRow.getrisk_object_type_id() == null))){
                continue;
            }
            if(((product_id != null && !CompareUtil.isEquals(liabilityRow.getproduct_id(), product_id)) && !(mask.charAt(1) == '1' && liabilityRow.getproduct_id() == null))){
                continue;
            }
            if(((contract_class_id != null && !CompareUtil.isEquals(liabilityRow.getcontract_class_id(), contract_class_id)) && !(mask.charAt(2) == '1' && liabilityRow.getcontract_class_id() == null))){
                continue;
            }
            if((liabilityRow.getcurrency_id() != null & !CompareUtil.isEquals(liabilityRow.getcurrency_id(), currency_id)) && !(mask.charAt(3) == '1' && liabilityRow.getcurrency_id() == null)){
                continue;
            }
            if(liabilityRow.getis_used_trailer() != SQLUtils.NULL_INTEGER_VALUE & !CompareUtil.isEquals(""+liabilityRow.getis_used_trailer(), usedTrailer)){
                continue;
            }
            map.put(liabilityRow.getvalue(), liabilityRow);
        }
        
        ArrayList<VDictLiability> result = new ArrayList<VDictLiability>();
        result.addAll(map.values());
    ...
        return result;
    }
    
    public List<VDictLiability> get(String currency_id, boolean usedTrailer, Date actualDate, String contract_class_id, String product_id, String risk_object_type_id) {
        return get(currency_id, usedTrailer?"1":"0", actualDate, contract_class_id, product_id, risk_object_type_id);
    }

    Это ад

    Запостил: borka, 03 Августа 2010

    Комментарии (1) RSS

    Добавить комментарий