org.djutils.data.serialization.StringSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of djutils-data Show documentation
Show all versions of djutils-data Show documentation
DJUTILS sampling and output data storage utilities
The newest version!
package org.djutils.data.serialization;
/**
* StringSerializer (de)serializes String objects.
*
* Copyright (c) 2020-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See DJUTILS License.
*
* @author Alexander Verbraeck
* @author Peter Knoppers
* @author Wouter Schakel
*/
public class StringSerializer implements SpecificTextSerializer
{
/** {@inheritDoc} */
@Override
public String serialize(final String value, final String unit)
{
return value == null ? null : value.toString();
}
/** {@inheritDoc} */
@Override
public String deserialize(final Class type, final String text, final String unit)
{
return (text == null || text.isEmpty()) ? null : text;
}
}