-
Notifications
You must be signed in to change notification settings - Fork 16
Migrating from 1.x to 2.x
ljacqu edited this page Oct 16, 2024
·
3 revisions
❗ | ConfigMe 2.0 is still in development, so this document is just an ongoing draft! |
---|
-
PrimitivePropertyType
has been split toBooleanType
,NumberType
andStringType
- Note: Strings are now converted to booleans/numbers if the representation matches, e.g. if String(
"4"
) is read from a property resource for an int property, its value will be determined to be the integer4
. ConfigMe 1.x discarded String values for all boolean and number types. - Note: if a conversion fails for an element inside an array, list or similar, ConfigMe will consider the resource not to be "fully valid" in more cases than before. This means that the configuration file will be resaved in more scenarios than previously if you are using a migration service. This change makes the behavior more consistent and should not affect you; however, please don't hesitate to open an issue if you need clarifications.
-
Utils
is renamed toFileUtils
. Feel free to use the method(s) inFileUtils
—it is part of the public API. - Constructor arguments in
Property
classes always start with theString path
, then a type (if applicable), and the default value at the end. Some constructors have been changed to follow this order (e.g.TypeBasedProperty
).
General changes in Mapper
(underlying converter of BeanProperty
):
- Getters and setters on bean classes are no longer relevant. The class's fields are taken as properties.
- Consequently,
@ExportName
can only be set on fields. - To make ConfigMe ignore a field, add the
transient
modifier or add the new annotation@IgnoreInMapping
- The
@Transient
annotation is no longer supported. Use ConfigMe's@IgnoreInMapping
.
- Consequently,
- Note that, as with regular properties, more conversions are now possible, e.g. a string
"3"
will be converted to the integer3
for an int field. - Java records can be used a bean property types. (This is not recommended.)
If you don't override any Mapper
behavior, you can skip this section.
-
LeafValueHandler
has been split intoLeafValueHandler
andMapperLeafType
. To support custom types in the bean mapper, you've had to implement your ownLeafValueHandler
. This is now being handled by aMapperLeafType
.LeafValueHandler
combines multipleMapperLeafType
implementations. Previously,LeafValueHandler
was doing both things via the same interface. - All default
LeafValueHandler
implementations that handled a specific type have changed and are mostly merged with thePropertyType
implementations.- For example: BooleanLeafValueHandler (old) -> BooleanType (new); NumberLeafValueHandler (old) -> NumberType (new).
TODO old/new code samples
If you don't override any Mapper
behavior, you can skip this section.
- Moved
MappingContext
to packageconfigme.beanmapper.context
-
TypeInformation
is no longer provided by ConfigMe, but it now usesTypeInfo
from the librarych.jalu.typeresolver
The property builder implementations have been split and the methods for setting the default value have been changed as to be consistent:
- A method
defaultValue
will always set the entire default value (e.g. whole default list of a list property) and may only be used once. UseaddToDefaultValue
to successively add default entries to a list/set/map/array property. - The property builder classes have changed. This should not greatly affect you if you are using the builder methods from PropertyInitializer.
PropertyBuilder
has been split into classes in thech.jalu.configme.properties.builder
package.- Old
PropertyBuilder.ListPropertyBuilder
is nowCollectionPropertyBuilder#listBuilder
- Old
PropertyBuilder.SetPropertyBuilder
is nowCollectionPropertyBuilder#setBuilder
- Old
PropertyBuilder.ArrayPropertyBuilder
is nowArrayPropertyBuilder#arrayBuilder
- Old
PropertyBuilder.InlineArrayPropertyBuilder
is nowArrayPropertyBuilder#inlineArrayBuilder
- Old
PropertyBuilder.MapPropertyBuilder
is nowMapPropertyBuilder
- Old
PropertyBuilder.TypeBasedPropertyBuilder
has been removed (along with PropertyInitializer#typeBasedProperty). Do you need this? Please open a new GitHub issue if so.
- Old
TODO add old/new examples
-
InlineArrayConverter
andStandardInlineArrayConverters
have been merged and renamed toInlineArrayPropertyType
. The class no longer is a separate type, but rather it implementsPropertyType
. - TODO specify string behavior (#382)
TODO add old/new examples
Guide
- Introduction
- Getting started
- Migration service
- Bean properties
- Custom property types
- Technical documentation
Updating
Development (internal)