com.github.nmorel.gwtjackson.client.ser.EnumJsonSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gwt-jackson Show documentation
Show all versions of gwt-jackson Show documentation
gwt-jackson is a GWT JSON serializer/deserializer mechanism based on Jackson annotations
package com.github.nmorel.gwtjackson.client.ser;
import javax.annotation.Nonnull;
import java.io.IOException;
import com.github.nmorel.gwtjackson.client.JsonSerializationContext;
import com.github.nmorel.gwtjackson.client.JsonSerializer;
import com.github.nmorel.gwtjackson.client.stream.JsonWriter;
/**
* Default {@link JsonSerializer} implementation for {@link Enum}.
*
* @author Nicolas Morel
*/
public class EnumJsonSerializer> extends JsonSerializer {
private static final EnumJsonSerializer> INSTANCE = new EnumJsonSerializer();
/**
* @return an instance of {@link EnumJsonSerializer}
*/
@SuppressWarnings( "unchecked" )
public static > EnumJsonSerializer getInstance() {
return (EnumJsonSerializer) INSTANCE;
}
private EnumJsonSerializer() { }
@Override
public void doSerialize( JsonWriter writer, @Nonnull E value, JsonSerializationContext ctx ) throws IOException {
writer.value( value.name() );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy