Skip to content

Consolidate entity serialization into one implicit class #1950

Closed
@felixmulder

Description

@felixmulder

The templating engine only works on java.util.Map[String, AnyRef] (buuh). This means that for each entity, we must convert it to this format. This is done in: dottydoc.model.JavaConverters.

This file is unnecessarily large, since it contains an implicit class for each subtype of Entity. But! It could be made to just contain one implicit class for all subtypes of Entity. Namely:

implicit class JavaEntity(val ent: Entity) extends AnyVal {
  def asJava: JMap[String, _] = ...
}

The asJava function would return a map with all possible fields of subtypes of Entity with null for value if the field does not exist in the current subtype.

Yes, we hate null in Scala land - but here we are on the border between Java and Scala and as such we have to make some concessions to please the great Java Templating engine gods.

Added bonus points for: getting rid of the _root_ imports, no longer needed

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions