
de.taimos.dvalin.notification.push.PushMessage Maven / Gradle / Ivy
/*
* Copyright (c) 2016. Taimos GmbH
*
*/
package de.taimos.dvalin.notification.push;
/*-
* #%L
* Dvalin notification service
* %%
* Copyright (C) 2016 - 2017 Taimos GmbH
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.io.IOException;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
public abstract class PushMessage {
private static ObjectMapper MAPPER;
static {
MAPPER = new ObjectMapper();
MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL);
MAPPER.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
MAPPER.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
MAPPER.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
MAPPER.enable(MapperFeature.AUTO_DETECT_GETTERS);
}
public abstract Platform getType();
protected abstract Map getPayload();
public String getPushMessage() throws IOException {
return PushMessage.MAPPER.writeValueAsString(this.getPayload());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy