Class Writers.PrimitiveTypeWriter

java.lang.Object
com.cedarsoftware.io.Writers.PrimitiveTypeWriter
All Implemented Interfaces:
JsonClassWriter
Direct Known Subclasses:
AtomicIntegerArrayWriter, AtomicLongArrayWriter, BitSetWriter, LongWriter, Writers.BigDecimalWriter, Writers.BigIntegerWriter, Writers.CharacterWriter, Writers.CurrencyWriter, Writers.DurationWriter, Writers.FloatingPointWriter, Writers.InstantWriter, Writers.LocalDateAsLong, Writers.LocalDateTimeWriter, Writers.LocalDateWriter, Writers.LocaleWriter, Writers.LocalTimeWriter, Writers.MonthDayWriter, Writers.OffsetDateTimeWriter, Writers.OffsetTimeWriter, Writers.PatternWriter, Writers.PeriodWriter, Writers.PrimitiveUtf8StringWriter, Writers.PrimitiveValueWriter, Writers.TimestampWriter, Writers.UUIDWriter, Writers.YearMonthWriter, Writers.YearWriter, Writers.ZonedDateTimeWriter, Writers.ZoneOffsetWriter
Enclosing class:
Writers

public static class Writers.PrimitiveTypeWriter extends Object implements JsonClassWriter
Used as a template to write out types that will have a primitive form. Uses the default key of "value" unless overridden
  • Constructor Details

    • PrimitiveTypeWriter

      public PrimitiveTypeWriter()
  • Method Details

    • getKey

      protected String getKey()
    • write

      public void write(Object obj, boolean showType, Writer output, WriterContext context) throws IOException
      Description copied from interface: JsonClassWriter
      Write the object in JSON format to the output Writer.
      Specified by:
      write in interface JsonClassWriter
      Parameters:
      obj - Object to be written in JSON format
      showType - boolean indicating whether to include @type in the output
      output - Writer destination where the JSON is written
      context - WriterContext providing access to WriteOptions and other write utilities
      Throws:
      IOException - if an I/O error occurs during writing
    • hasPrimitiveForm

      public boolean hasPrimitiveForm(WriterContext writerContext)
      Description copied from interface: JsonClassWriter
      Indicates whether this class has a primitive (non-object) JSON form. Most custom writers will not have a primitive form, so the default is false.
      Specified by:
      hasPrimitiveForm in interface JsonClassWriter
      Parameters:
      writerContext - WriterContext providing access to WriteOptions
      Returns:
      true if this class can be written as a JSON primitive value