Open Source Repository

Home /jodd/jodd-3.3.2 | Repository Home



jodd/typeconverter/impl/MutableLongConverter.java
// Copyright (c) 2003-2012, Jodd Team (jodd.org). All Rights Reserved.

package jodd.typeconverter.impl;

import jodd.mutable.MutableLong;
import jodd.typeconverter.ConvertBean;
import jodd.typeconverter.TypeConverter;

/**
 * Converts given object to a {@link MutableLong}.
 */
public class MutableLongConverter implements TypeConverter<MutableLong> {

  protected final ConvertBean convertBean;

  public MutableLongConverter(ConvertBean convertBean) {
    this.convertBean = convertBean;
  }

  public MutableLong convert(Object value) {
    if (value == null) {
      return null;
    }

    if (value.getClass() == MutableLong.class) {
      return (MutableLongvalue;
    }

    return new MutableLong(convertBean.toLongValue(value));
  }
}