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

org.apache.juneau.msgpack.MsgPackSerializer Maven / Gradle / Ivy

There is a newer version: 9.0.1
Show newest version
// ***************************************************************************************************************************
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
// * to you 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.                                              *
// ***************************************************************************************************************************
package org.apache.juneau.msgpack;

import org.apache.juneau.*;
import org.apache.juneau.serializer.*;

/**
 * Serializes POJO models to MessagePack.
 *
 * 
Media types:
* * Handles Accept types: octal/msgpack * *

* Produces Content-Type types: octal/msgpack */ public class MsgPackSerializer extends OutputStreamSerializer { //------------------------------------------------------------------------------------------------------------------- // Configurable properties //------------------------------------------------------------------------------------------------------------------- private static final String PREFIX = "MsgPackSerializer."; /** * Configuration property: Add "_type" properties when needed. * *

    *
  • Name: "MsgPackSerializer.addBeanTypeProperties" *
  • Data type: Boolean *
  • Default: false *
  • Session-overridable: true *
* *

* If true, then "_type" properties will be added to beans if their type cannot be inferred * through reflection. * This is used to recreate the correct objects during parsing if the object types cannot be inferred. * For example, when serializing a {@code Map} field, where the bean class cannot be determined from * the value type. * *

* When present, this value overrides the {@link #SERIALIZER_addBeanTypeProperties} setting and is * provided to customize the behavior of specific serializers in a {@link SerializerGroup}. */ public static final String MSGPACK_addBeanTypeProperties = PREFIX + "addBeanTypeProperties"; //------------------------------------------------------------------------------------------------------------------- // Predefined instances //------------------------------------------------------------------------------------------------------------------- /** Default serializer, all default settings.*/ public static final MsgPackSerializer DEFAULT = new MsgPackSerializer(PropertyStore.create()); //------------------------------------------------------------------------------------------------------------------- // Instance //------------------------------------------------------------------------------------------------------------------- private final MsgPackSerializerContext ctx; /** * Constructor. * * @param propertyStore The property store containing all the settings for this object. */ public MsgPackSerializer(PropertyStore propertyStore) { super(propertyStore, "octal/msgpack"); this.ctx = createContext(MsgPackSerializerContext.class); } @Override /* CoreObject */ public MsgPackSerializerBuilder builder() { return new MsgPackSerializerBuilder(propertyStore); } @Override /* Serializer */ public OutputStreamSerializerSession createSession(SerializerSessionArgs args) { return new MsgPackSerializerSession(ctx, args); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy