/** * @since 1.8 */ public ObjectWriter withSchema(FormatSchema schema) { if (_schema == schema) { return this; } return new ObjectWriter(this, _config, _rootType, _prettyPrinter, schema); }
/** * Method that will construct a new instance that uses specific type * as the root type for serialization, instead of runtime dynamic * type of the root object itself. */ public ObjectWriter withType(JavaType rootType) { if (rootType == _rootType) return this; // type is stored here, no need to make a copy of config return new ObjectWriter(this, _config, rootType, _prettyPrinter, _schema); }
/** * Method that will construct a new instance that will use specified pretty * printer (or, if null, will not do any pretty-printing) * * @since 1.6 */ public ObjectWriter withPrettyPrinter(PrettyPrinter pp) { if (pp == _prettyPrinter) { return this; } // since null would mean "don't care", need to use placeholder to indicate "disable" if (pp == null) { pp = NULL_PRETTY_PRINTER; } return new ObjectWriter(this, _config, _rootType, pp, _schema); }
/** * Factory method for constructing {@link ObjectWriter} that will * pass specific schema object to {@link JsonGenerator} used for * writing content. * * @param schema Schema to pass to generator * * @since 1.9 */ public ObjectWriter writer(FormatSchema schema) { return new ObjectWriter(this, copySerializationConfig(), schema); }
/** * Convenience method for constructing {@link ObjectWriter} * with default settings. * * @since 1.6 */ public ObjectWriter writer() { return new ObjectWriter(this, copySerializationConfig()); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified root type, instead of actual * runtime type of value. Type must be a super-type of runtime type. * * @since 1.9 */ public ObjectWriter writerWithType(JavaType rootType) { return new ObjectWriter(this, copySerializationConfig(), rootType, /*PrettyPrinter*/null); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified pretty printer for indentation * (or if null, no pretty printer) * * @since 1.9 */ public ObjectWriter writer(PrettyPrinter pp) { if (pp == null) { // need to use a marker to indicate explicit disabling of pp pp = ObjectWriter.NULL_PRETTY_PRINTER; } return new ObjectWriter(this, copySerializationConfig(), /*root type*/ null, pp); }
/** * Fluent factory method that will construct a new writer instance that will * use specified date format for serializing dates; or if null passed, one * that will serialize dates as numeric timestamps. * * @since 1.9 */ public ObjectWriter withDateFormat(DateFormat df) { SerializationConfig newConfig = _config.withDateFormat(df); if (newConfig == _config) { return this; } return new ObjectWriter(this, newConfig); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified JSON View (filter). * * @since 1.9 */ public ObjectWriter writerWithView(Class<?> serializationView) { return new ObjectWriter(this, copySerializationConfig().withView(serializationView)); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using the default pretty printer for indentation * * @since 1.9 */ public ObjectWriter writerWithDefaultPrettyPrinter() { return new ObjectWriter(this, copySerializationConfig(), /*root type*/ null, _defaultPrettyPrinter()); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified {@link DateFormat}; or, if * null passed, using timestamp (64-bit number. * * @since 1.9 */ public ObjectWriter writer(DateFormat df) { return new ObjectWriter(this, copySerializationConfig().withDateFormat(df)); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified root type, instead of actual * runtime type of value. Type must be a super-type of runtime * type. * * @since 1.9 */ public ObjectWriter writerWithType(Class<?> rootType) { JavaType t = (rootType == null) ? null : _typeFactory.constructType(rootType); return new ObjectWriter(this, copySerializationConfig(), t, /*PrettyPrinter*/null); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified root type, instead of actual * runtime type of value. Type must be a super-type of runtime type. * * @since 1.9 */ public ObjectWriter writerWithType(TypeReference<?> rootType) { JavaType t = (rootType == null) ? null : _typeFactory.constructType(rootType); return new ObjectWriter(this, copySerializationConfig(), t, /*PrettyPrinter*/null); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified filter provider. * * @since 1.9 */ public ObjectWriter writer(FilterProvider filterProvider) { return new ObjectWriter(this, copySerializationConfig().withFilters(filterProvider)); }
/** * Method that will construct a new instance that uses specified * serialization view for serialization (with null basically disables * view processing) */ public ObjectWriter withView(Class<?> view) { if (view == _config.getSerializationView()) return this; return new ObjectWriter(this, _config.withView(view)); }
/** * Method that will construct a new instance that uses specified * provider for resolving filter instances by id. * * @since 1.7 */ public ObjectWriter withFilters(FilterProvider filterProvider) { if (filterProvider == _config.getFilterProvider()) { // no change? return this; } return new ObjectWriter(this, _config.withFilters(filterProvider)); }
/** * Convenience method for constructing {@link ObjectWriter} * with default settings. * * @since 1.6 */ public ObjectWriter writer() { return new ObjectWriter(this, copySerializationConfig()); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified root type, instead of actual * runtime type of value. Type must be a super-type of runtime type. * * @since 1.9 */ public ObjectWriter writerWithType(JavaType rootType) { return new ObjectWriter(this, copySerializationConfig(), rootType, /*PrettyPrinter*/null); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified JSON View (filter). * * @since 1.9 */ public ObjectWriter writerWithView(Class<?> serializationView) { return new ObjectWriter(this, copySerializationConfig().withView(serializationView)); }
/** * Method that will construct a new instance that uses specified * provider for resolving filter instances by id. * * @since 1.7 */ public ObjectWriter withFilters(FilterProvider filterProvider) { if (filterProvider == _config.getFilterProvider()) { // no change? return this; } return new ObjectWriter(this, _config.withFilters(filterProvider)); }