public enum UpgradeConversionPolicy extends Enum<UpgradeConversionPolicy>
Permazen fields are identified by their storage ID's, which is typically derived automatically from the field's name. With one restriction*, the type of a field may change arbitrarily between schema versions.
When changing an object's schema version, Permazen supports optional automatic conversion of simple field
values from the old type to the new type. For example, an
int field value
1234 can be automatically
String field value
FieldType.convert(io.permazen.core.FieldType<S>, S) for details about conversions between simple field types. In addition,
Counter fields can be converted to/from any numeric Java primitive (or primitive wrapper) type.
This class is used to specify whether such automatic conversion should occur when a simple field's type changes, and if so, whether the conversion must always succeed.
*A simple field may not have different types across schema versions and be indexed in both versions.
References and Enums
Automatic conversion of reference fields also works as long as the referenced object's type is assignable to the field's new Java type (otherwise, the field is set to null).
Note that arbitrary conversion logic is always possible using
|Enum Constant and Description|
Attempt automatic conversion of field values to the new type, and if automatic conversion fails, set the value to the new type's default value as would
Attempt automatic conversion of field values to the new type, and iIf automatic conversion fails, throw a
Do not attempt to automatically convert values to the new type.
|Modifier and Type||Method and Description|
Determine whether this policy should attempt to convert field values from the old type to the new type.
Determine whether failed attempts to convert a field's value from the old type to the new type should be fatal.
Returns the enum constant of this type with the specified name.
Returns an array containing the constants of this enum type, in the order they are declared.
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
public static final UpgradeConversionPolicy RESET
Instead, during a schema version change, the field will be reset to the default value of the field's new type.
public static final UpgradeConversionPolicy ATTEMPT
public static UpgradeConversionPolicy values()
for (UpgradeConversionPolicy c : UpgradeConversionPolicy.values()) System.out.println(c);
public static UpgradeConversionPolicy valueOf(String name)
public boolean isConvertsValues()
If this is false, the field's value will be set to the new type's default value.
If this is true, the field's old value will be converted to the field's new type if possible;
if the conversion fails, the behavior depends on
public boolean isRequireConversion()
If this is true, a failed conversion attempt results in a
UpgradeConversionException being thrown.
If this is false, a failed conversion attempt results in the field being set to the new type's default value.
Copyright © 2020. All rights reserved.