All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.djutils.data.serialization.SpecificTextSerializer Maven / Gradle / Ivy

The newest version!
package org.djutils.data.serialization;

/**
 * StrictTextSerializer adds one method to the textSerializer class where it it is not necessary to specify the type for the
 * deserialize method, since it is a specific class.
 * 

* 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 * @param the value type */ public interface SpecificTextSerializer extends TextSerializer { /** * Serialize a value to text in such a way that it can be deserialized with the corresponding deserializer. Note that * {@code null} values for value are allowed. A {@code null} values stands for an empty column value in a CVS-file, a * missing tag in an XML-file, etc. This version of the serialize method ignores the unit. * @param value T; the value to serialize, may be {@code null} * @return String; a string representation of the value that can later be deserialized, or {@code null}to denote a missing * value */ default String serialize(final T value) { return serialize(value, null); } /** * Deserialize a value from text that has been created with the corresponding serializer, where the value does not have a * unit, and the class is known and fixed (and not checked). Note that {@code null} values for text are allowed. A * {@code null} values stands for an empty column value in a CVS-file, a missing tag in an XML-file, etc. In this way, we * can explicitly show values that were not specified in the file. * @param text String; the string to deserialize, may be {@code null} * @return T; an instance of the object created with the corresponding serializer, may be {@code null} when a value was not * specified in the source from which the deserializer was called */ default T deserialize(final String text) { return deserialize(null, text, null); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy