Skip to content

Replace Literals with Stateless Functions #98

@omervk

Description

@omervk

Literals are currently only used for two purposes:

  1. Type-safe casts
  2. Type-safe comparators

They are not usually needed together and whenever one is needed, a new Literal is instantiated. In a tight loop, this isn't optimal.

These could be replaced by a couple of functions (mock code):

static <From, To> Function<From, To> convert(from: Class<From>, to: Class<To>)
static <T> Comparator<T> convert(clazz: Class<T>)

These functions could be cached and lookup could be via a hashtable at O(1).

This would also have another benefit of removing a type from the domain model, simplifying UnboundPredicate and BoundPredicate's signatures.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions