Example usage for org.apache.commons.lang StringUtils equals

List of usage examples for org.apache.commons.lang StringUtils equals

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils equals.

Prototype

public static boolean equals(String str1, String str2) 

Source Link

Document

Compares two Strings, returning true if they are equal.

Usage

From source file:cn.cuizuoli.appranking.enumeration.DeviceType.java

/**
 * getObject/*from ww w  . j av a  2s .  co  m*/
 * @param code
 */
public static DeviceType getObject(String code) {
    for (DeviceType deviceType : DeviceType.values()) {
        if (StringUtils.equals(deviceType.getCode(), code)) {
            return deviceType;
        }
    }
    return null;
}

From source file:cn.cuizuoli.appranking.util.DateRangeUtil.java

/**
 * getHourListOfDay/*  w  w w  .j  av  a2  s .  c  o  m*/
 * @param date
 * @return
 */
public static List<String> getHourListOfDay(String date) {
    List<String> dateHourList = new ArrayList<String>();
    DateTime datetime = DateUtil.fromDay(date).withHourOfDay(0);
    while (StringUtils.equals(DateUtil.toDay(datetime), date)) {
        dateHourList.add(DateUtil.toHour(datetime));
        datetime = datetime.plusHours(1);
    }
    return dateHourList;
}

From source file:com.zb.app.biz.cons.ColumnHotEnum.java

public static ColumnHotEnum getAction(String name) {
    if (StringUtils.isEmpty(name)) {
        return null;
    }/*from ww  w  .j  a v a2s.c  o  m*/
    for (ColumnHotEnum type : values()) {
        if (StringUtils.equals(name, type.name))
            return type;
    }
    return null;
}

From source file:com.l1j5.web.common.utils.ImageUtils.java

public static void createThumbnail(BufferedInputStream stream_file, String save, String type, int w, int h) {
    try {//from www  .  ja  v a  2 s. c  o  m

        if (StringUtils.equals(StringUtils.lowerCase(type), "gif")) {
            getGifImageThumbnail(stream_file, save, type, w, h);
        } else {
            getImageThumbnail(stream_file, save, type, w, h);
        }

    } catch (Exception e) {
        log.error(e);
    }

}

From source file:com.mmj.app.biz.cons.PhotoTypeEnum.java

public static PhotoTypeEnum getAction(String name) {
    for (PhotoTypeEnum type : values()) {
        if (StringUtils.equals(name, type.name))
            return type;
    }/*from ww w.j  a va2  s  . co  m*/
    return null;
}

From source file:com.mmj.app.common.core.lang.BeanUtils.java

public static Map<String, Object> beanToMap(Object entity) {
    Map<String, Object> parameter = new HashMap<String, Object>();
    Field[] fields = entity.getClass().getDeclaredFields();
    for (int i = 0; i < fields.length; i++) {
        String fieldName = fields[i].getName();
        if (StringUtils.equals("serialVersionUID", fieldName)) {
            continue;
        }/*from www  . j  a v  a  2s .c o m*/
        Object o = null;
        String firstLetter = fieldName.substring(0, 1).toUpperCase();
        String getMethodName = "get" + firstLetter + fieldName.substring(1);
        Method getMethod;
        try {
            getMethod = entity.getClass().getMethod(getMethodName, new Class[] {});
            o = getMethod.invoke(entity, new Object[] {});
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (o != null) {
            parameter.put(fieldName, o);
        }
    }
    return parameter;
}

From source file:com.sfs.whichdoctor.formatter.ExpenseClaimFormatter.java

private static String getQuantity(final ExpenseClaimBean expenseClaim) {

    final StringBuffer value = new StringBuffer();

    if (StringUtils.equals(expenseClaim.getExpenseClass(), "Travel")
            && StringUtils.equals(expenseClaim.getExpenseType(), "Petrol (Lump sum)")) {
        if (StringUtils.isNotBlank(expenseClaim.getCurrencyAbbreviation())
                && !StringUtils.equals(expenseClaim.getCurrencyAbbreviation(), DEFAULT_CURRENCY_ABBR)) {
            value.append(expenseClaim.getCurrencyAbbreviation());
        }/*ww  w  .  ja v  a  2 s .  co m*/
        value.append(Formatter.toCurrency(expenseClaim.getRate()));
    }
    if (StringUtils.equals(expenseClaim.getExpenseClass(), "Travel")
            && StringUtils.equals(expenseClaim.getExpenseType(), "Mileage Reimbursement")) {
        value.append(expenseClaim.getQuantity() + " kilometers @ ");
        value.append(Formatter.toCurrency(expenseClaim.getRate()));
        if (StringUtils.isNotBlank(expenseClaim.getCurrencyAbbreviation())
                && !StringUtils.equals(expenseClaim.getCurrencyAbbreviation(), DEFAULT_CURRENCY_ABBR)) {
            value.append(expenseClaim.getCurrencyAbbreviation());
        }
        value.append(" per kilometer");
    }
    if (value.length() == 0) {
        value.append(expenseClaim.getQuantity() + " @ ");
        if (StringUtils.isNotBlank(expenseClaim.getCurrencyAbbreviation())
                && !StringUtils.equals(expenseClaim.getCurrencyAbbreviation(), DEFAULT_CURRENCY_ABBR)) {
            value.append(expenseClaim.getCurrencyAbbreviation());
        }
        value.append(Formatter.toCurrency(expenseClaim.getRate()));
    }
    if (StringUtils.isNotBlank(expenseClaim.getDescription())) {
        if (value.length() > 0) {
            value.append(" - ");
        }
        value.append(expenseClaim.getDescription());
    }
    if (StringUtils.isNotBlank(expenseClaim.getCurrencyAbbreviation())
            && !StringUtils.equals(expenseClaim.getCurrencyAbbreviation(), DEFAULT_CURRENCY_ABBR)) {
        if (value.length() > MAX_QUANTITY) {
            value.append("<br/>");
        }
        value.append(" (Rate: " + expenseClaim.getCurrencyAbbreviation() + "$1 = " + DEFAULT_CURRENCY_ABBR + "$"
                + expenseClaim.getExchangeRate() + ")");
    }
    return value.toString();
}

From source file:com.zb.app.biz.cons.GuestAgeTypeEnum.java

public static GuestAgeTypeEnum getAction(String name) {
    if (StringUtils.isEmpty(name)) {
        return null;
    }// w ww.ja  v a  2  s.  c o m
    for (GuestAgeTypeEnum type : values()) {
        if (StringUtils.equals(name, type.name))
            return type;
    }
    return null;
}

From source file:com.prowidesoftware.swift.model.MessageIOType.java

public static boolean isValid(String ioType) {
    Validate.notNull(ioType, "ioType can not be null");
    for (MessageIOType t : values()) {
        if (StringUtils.equals(ioType.trim(), t.name()))
            return true;
    }//www. j  av a 2  s . c o  m
    return false;
}

From source file:com.eryansky.core.excelTools.ExcelUtils.java

/**
 * JavaBeanMap//from  w ww.j  a v a 2 s.  c o  m
 * @param obj
 * @return
 */
public static Map<String, Object> beanToMap(Object obj) {
    Map<String, Object> params = new HashMap<String, Object>(0);
    try {
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        PropertyDescriptor[] descriptors = propertyUtilsBean.getPropertyDescriptors(obj);
        for (int i = 0; i < descriptors.length; i++) {
            String name = descriptors[i].getName();
            if (!StringUtils.equals(name, "class")) {
                params.put(name, propertyUtilsBean.getNestedProperty(obj, name));
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return params;
}