Java tutorial
package tv.arte.resteventapi.core.presentation.serialization; /* * #%L * RestEventAPI * %% * Copyright (C) 2014 ARTE G.E.I.E * %% * This program is free software: you can redistribute it and/or modify * it under the terms of The MIT License (MIT) as published by the Open Source * Initiative. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See The * MIT License (MIT) for more details. * * You should have received a copy of The MIT License (MIT) * along with this program. If not, see <http://opensource.org/licenses/MIT> * #L% */ import java.io.IOException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdKeySerializers; import com.fasterxml.jackson.databind.type.TypeFactory; /** * Serializer that will skip all {@link TransientString} * * @see TransientString * * @author Simeon Petev * @since 0.1 */ public class TransientStringSerializer extends JsonSerializer<Object> { @Override public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { //Serialize everything else but TransientString if (!(value instanceof TransientString)) { StdKeySerializers .getStdKeySerializer(TypeFactory.defaultInstance() .constructFromCanonical(value.getClass().getCanonicalName())) .serialize(value, jgen, provider); } } }