Package au.net.causal.projo.prefs.transform

Source Code of au.net.causal.projo.prefs.transform.UuidToStringTransformer

package au.net.causal.projo.prefs.transform;

import java.util.UUID;

import au.net.causal.projo.prefs.PreferencesException;

/**
* Converter that can store UUIDs as strings.
*
* @author prunge
*/
public class UuidToStringTransformer extends GenericToStringTransformer<UUID>
{
  public UuidToStringTransformer()
  {
    super(UUID.class);
  }
 
  @Override
  protected UUID stringToValue(String s) throws PreferencesException
  {
    try
    {
      return(UUID.fromString(s));
    }
    catch (IllegalArgumentException e)
    {
      throw new PreferencesException("Failed to convert value '" + s + "' to an integer.", e);
    }
  }
 
  @Override
  protected String valueToString(UUID value) throws PreferencesException
  {
    return(value.toString());
  }
}
TOP

Related Classes of au.net.causal.projo.prefs.transform.UuidToStringTransformer

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.