工作杂记

1. Class UniqueKeyUtil.

public static String getUniqueKey() {
        String threadId = Long.toHexString(Thread.currentThread().getId() % 100);
        int randomLength = LENGTH_LIMIT - threadId.length();
        String randomString = RandomStringUtils.randomAlphanumeric(randomLength);
        return threadId + randomString;
    }

2.

ToStringBuilder.reflectionToString(response, ToStringStyle.MULTI_LINE_STYLE)

3.Enum

public enum InvestmentHistoryRequestTypeCode implements StringValueEnum {

    /** The NONE. */
    NONE("NONE"),

    /** The PAST. */
    PAST("PAST"),

    /** The CURR. */
    CURR("CURR");

    /** The Constant STRING_TO_ENUM. */
    private static final Map<String, InvestmentHistoryRequestTypeCode> STRING_TO_ENUM = new HashMap<String, InvestmentHistoryRequestTypeCode>();

    /** The value. */
    private String value;

    /**
     * Instantiates a new investment history request type code.
     *
     * @param value
     *            the value
     */
    private InvestmentHistoryRequestTypeCode(final String value) {
        this.value = value;
    }

    /*
     * (non-Javadoc)
     *
     * @see com.hsbc.scwd.common.datatype.StringValueEnum#getValue()
     */
    @Override
    public String getValue() {
        return this.value;
    }

    static {
        for (InvestmentHistoryRequestTypeCode e : values()) {
            STRING_TO_ENUM.put(e.getValue(), e);
        }
    }

    /**
     * From string.
     *
     * @param symbol
     *            the symbol
     *
     * @return the investment history request type code
     */
    public static InvestmentHistoryRequestTypeCode fromString(final String symbol) {
        return STRING_TO_ENUM.get(symbol);
    }

}

 

4 equals hashcode:

    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        Account rhs = (Account) obj;
       
        return new EqualsBuilder() //
        .append(this.accountProductTypeCode, rhs.accountProductTypeCode)//
        .append(this.accountNumber, rhs.accountNumber)//
        .append(this.accountType, rhs.accountType)//
        .append(this.countryInvestmentAccountCode, rhs.countryInvestmentAccountCode)//
        .append(this.groupMemberInvestmentAccountCode, rhs.groupMemberInvestmentAccountCode)//
        .append(this.accountControlNumber, rhs.accountControlNumber)//
        .append(this.currencyAccountCode, rhs.currencyAccountCode)//
        // .append(this.accountGroupIdentifier, rhs.accountGroupIdentifier)//
        // .append(this.accountNickName, rhs.accountNickName)//
        // .append(this.accountStatusCode, rhs.accountStatusCode)//
        // .append(this.accountSegmentText, rhs.accountSegmentText)//
        .isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder()//
        .append(this.accountProductTypeCode)//
        .append(this.accountNumber)//
        .append(this.accountType)//
        .append(this.countryInvestmentAccountCode)//
        .append(this.groupMemberInvestmentAccountCode)//
        .append(this.accountControlNumber)//
        .append(this.currencyAccountCode)//
        // .append(this.accountGroupIdentifier)//
        // .append(this.accountNickName)//
        // .append(this.accountStatusCode)//
        // .append(this.accountSegmentText)//
        .toHashCode();
    }

 

你可能感兴趣的:(工作)