Package jodd.typeconverter.impl

Source Code of jodd.typeconverter.impl.MutableLongConverter

// Copyright (c) 2003-2014, Jodd Team (jodd.org). All Rights Reserved.

package jodd.typeconverter.impl;

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

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

  protected final TypeConverter<Long> typeConverter;

  @SuppressWarnings("unchecked")
  public MutableLongConverter(TypeConverterManagerBean typeConverterManagerBean) {
    typeConverter = typeConverterManagerBean.lookup(Long.class);
  }

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

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

    return new MutableLong(typeConverter.convert(value));
  }
}
TOP

Related Classes of jodd.typeconverter.impl.MutableLongConverter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.