Skip to main content

Deprecations

DataElement Deprecations

Delete by id

delete(Long) has been deprecated in favour of the delete(DataRef) (or deleteByDataRef(ParameterContext) on the bean).

Reason: Bad Encapsulation

By passing the database id instead of a DataRef, the method signature is strongly tied to the underlying implementation. This does not correctly implement AVT.

Get X by id

getDetails(Long), getInfo(Long), getDataRef(Long), getName(Long) and getId(String) have been deprecated. To replace these methods, instead use the getProjection() method. getId(String) can be replaced with resolveDataRef(DataRef), which maps a DataRef with only name or a functional key to a valid DataRef referencing the corresponding instance.

Reason: Bad Encapsulation

Reason: Similar to the delete by id, these methods expose the underlying implementation.

Find all X

findAllDataRefs() and findAllInfos() have been deprecated. These methods were convenience methods to retrieve all instances of a DataElement. Instead, developers should use the find(SearchDetails) method.

Reason: Leads to Bad Practice

Reason: If used carelessly, it can drain all records of a table. In some cases, getting all records can be correct. However, when calling a find method, developers should be conscious of the performance impact.

Get Details by DataRef

getDetails(DataRef) (or getDetailsFromDataRef(ParameterContext) on the bean) has been deprecated. Instead, the getProjection(ProjectionRef) should be used.

Reason: Fluff method around getProjection

getDetails(DataRef) does not add anything significant. It only delegates to getProjection(ProjectionRef).

Nsx-runtime Deprecations

Type converter interfaces

Several specific Converter interfaces have been deprecated (ILongConverter, IDateConverter...). The effect should be limited to expanded artifacts.

Reason: Unnecessary

The methods exposed by the interfaces were only ever used in locations where the converter class was known. Removing these interfaces made the code simpler.

IFieldValidator interface

IFieldValidator has been deprecated. The effect should be limited to expanded artifacts.

Reason: Unnecessary

Validator classes are only used in locations where the actual class is known.

ValidationHelper

Reason: Uses Reflection

The ValidationHelper was used in the Struts Validator classes to get the value of a field. It uses reflection to get there.

Base64, ByteArrayConverter, SimpleUriFormat, DirUtil, IExecutor, ListUtil, Options

Replace with the following:

  • Base64 -> java.util.Base64
  • ByteArrayConverter -> java.nio.file.Files#readAllBytes(Path)
  • SimpleUriFormat -> java.nio.file.Path#toUri()
  • DirUtil -> java.nio.file.Files
  • IExecutor -> java.util.function.Consumer
  • ListUtil -> Stream Api
  • Options -> java.util.Optional
Reason: Already provided by JDK

The same functionality is provided by the standard Java library and has better support.