Class WriteOptionsBuilder.DefaultWriteOptions

java.lang.Object
com.cedarsoftware.util.io.WriteOptionsBuilder.DefaultWriteOptions
All Implemented Interfaces:
WriteOptions
Enclosing class:
WriteOptionsBuilder

public static class WriteOptionsBuilder.DefaultWriteOptions extends Object implements WriteOptions
  • Method Details

    • getTypeNameAlias

      public String getTypeNameAlias(String typeName)
      Alias Type Names, e.g. "ArrayList" instead of "java.util.ArrayList".
      Specified by:
      getTypeNameAlias in interface WriteOptions
      Parameters:
      typeName - String name of type to fetch alias for. There are no default aliases.
      Returns:
      String alias name or null if type name is not aliased.
    • isAlwaysShowingType

      public boolean isAlwaysShowingType()
      Specified by:
      isAlwaysShowingType in interface WriteOptions
      Returns:
      boolean true if set to always show type (@type)
    • isNeverShowingType

      public boolean isNeverShowingType()
      Specified by:
      isNeverShowingType in interface WriteOptions
      Returns:
      boolean true if set to never show type (no @type)
    • isMinimalShowingType

      public boolean isMinimalShowingType()
      Specified by:
      isMinimalShowingType in interface WriteOptions
      Returns:
      boolean true if set to show minimal type (@type)
    • isCustomWrittenClass

      public boolean isCustomWrittenClass(Class<?> clazz)
      Specified by:
      isCustomWrittenClass in interface WriteOptions
      Parameters:
      clazz - Class to check to see if there is a custom writer associated to it.
      Returns:
      boolean true if there is an associated custom writer class associated to the passed in class, false otherwise.
    • isNotCustomWrittenClass

      public boolean isNotCustomWrittenClass(Class<?> clazz)
      Specified by:
      isNotCustomWrittenClass in interface WriteOptions
      Parameters:
      clazz - Class to see if it is on the not-customized list. Classes are added to this list when a class is being picked up through inheritance, and you don't want it to have a custom writer associated to it.
      Returns:
      boolean true if the passed in class is on the not-customized list, false otherwise.
    • getAccessorsForClass

      public List<Accessor> getAccessorsForClass(Class<?> c)
      Specified by:
      getAccessorsForClass in interface WriteOptions
    • isLongDateFormat

      public boolean isLongDateFormat()
      Specified by:
      isLongDateFormat in interface WriteOptions
      Returns:
      boolean true if java.util.Date and java.sql.Date's are being written in long (numeric) format.
    • isNonReferenceableClass

      public boolean isNonReferenceableClass(Class<?> clazz)
      Specified by:
      isNonReferenceableClass in interface WriteOptions
      Parameters:
      clazz - Class to check to see if it is non-referenceable. Non-referenceable classes will always create a new instance when read in and never use @id/@ref. This uses more memory when the JSON is read in, as there will be a separate instance in memory for each occurrence. There are certain classes that json-io automatically treats as non-referenceable, like Strings, Enums, Class, and any Number instance (BigDecimal, AtomicLong, etc.) You can add to this list. Often, non-referenceable classes are useful for classes that can be defined in one line as a JSON, like a LocalDateTime, for example.
      Returns:
      boolean true if the passed in class is considered a non-referenceable class.
    • getCustomWriter

      public JsonWriter.JsonClassWriter getCustomWriter(Class<?> c)
      Fetch the custom writer for the passed in Class. If it is cached (already associated to the passed in Class), return the same instance, otherwise, make a call to get the custom writer and store that result.
      Specified by:
      getCustomWriter in interface WriteOptions
      Parameters:
      c - Class of object for which fetch a custom writer
      Returns:
      JsonClassWriter for the custom class (if one exists), null otherwise.
    • findCustomWriter

      public JsonWriter.JsonClassWriter findCustomWriter(Class<?> c)
    • clearCaches

      public void clearCaches()
      Specified by:
      clearCaches in interface WriteOptions
    • getDeepDeclaredFields

      public Map<String,Field> getDeepDeclaredFields(Class<?> c)
      Gets the declared fields for the full class hierarchy of a given class
      Specified by:
      getDeepDeclaredFields in interface WriteOptions
      Parameters:
      c - - given class.
      Returns:
      Map - map of string fieldName to Field Object. This will have the deep list of fields for a given class.