Package com.cedarsoftware.util.io
Class WriteOptionsBuilder.DefaultWriteOptions
java.lang.Object
com.cedarsoftware.util.io.WriteOptionsBuilder.DefaultWriteOptions
- All Implemented Interfaces:
WriteOptions
- Enclosing class:
- WriteOptionsBuilder
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.cedarsoftware.util.io.WriteOptions
WriteOptions.ShowType
-
Method Summary
Modifier and TypeMethodDescriptionvoid
findCustomWriter
(Class<?> c) getAccessorsForClass
(Class<?> c) getCustomWriter
(Class<?> c) Fetch the custom writer for the passed in Class.getDeepDeclaredFields
(Class<?> c) Gets the declared fields for the full class hierarchy of a given classgetTypeNameAlias
(String typeName) Alias Type Names, e.g.boolean
boolean
isCustomWrittenClass
(Class<?> clazz) boolean
boolean
boolean
boolean
isNonReferenceableClass
(Class<?> clazz) boolean
isNotCustomWrittenClass
(Class<?> clazz) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.cedarsoftware.util.io.WriteOptions
getClassLoader, isAllowNanAndInfinity, isCloseStream, isEnumPublicFieldsOnly, isForceMapOutputAsTwoArrays, isPrettyPrint, isShortMetaKeys, isSkipNullFields, isWriteLongsAsStrings
-
Method Details
-
getTypeNameAlias
Alias Type Names, e.g. "ArrayList" instead of "java.util.ArrayList".- Specified by:
getTypeNameAlias
in interfaceWriteOptions
- 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 interfaceWriteOptions
- Returns:
- boolean true if set to always show type (@type)
-
isNeverShowingType
public boolean isNeverShowingType()- Specified by:
isNeverShowingType
in interfaceWriteOptions
- Returns:
- boolean true if set to never show type (no @type)
-
isMinimalShowingType
public boolean isMinimalShowingType()- Specified by:
isMinimalShowingType
in interfaceWriteOptions
- Returns:
- boolean true if set to show minimal type (@type)
-
isCustomWrittenClass
- Specified by:
isCustomWrittenClass
in interfaceWriteOptions
- 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
- Specified by:
isNotCustomWrittenClass
in interfaceWriteOptions
- 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
- Specified by:
getAccessorsForClass
in interfaceWriteOptions
-
isLongDateFormat
public boolean isLongDateFormat()- Specified by:
isLongDateFormat
in interfaceWriteOptions
- Returns:
- boolean true if java.util.Date and java.sql.Date's are being written in long (numeric) format.
-
isNonReferenceableClass
- Specified by:
isNonReferenceableClass
in interfaceWriteOptions
- 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
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 interfaceWriteOptions
- Parameters:
c
- Class of object for which fetch a custom writer- Returns:
- JsonClassWriter for the custom class (if one exists), null otherwise.
-
findCustomWriter
-
clearCaches
public void clearCaches()- Specified by:
clearCaches
in interfaceWriteOptions
-
getDeepDeclaredFields
Gets the declared fields for the full class hierarchy of a given class- Specified by:
getDeepDeclaredFields
in interfaceWriteOptions
- 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.
-