java.lang.Object
com.vaadin.flow.component.template.internal.IdMapper
All Implemented Interfaces:
Serializable

public class IdMapper extends Object implements Serializable
Creates or maps Element instances to fields mapped using @Id.

For internal use only. May be renamed or removed in a future release.

Since:
See Also:
  • Constructor Details

    • IdMapper

      public IdMapper(Component template)
      Creates a mapper for the given template.
      Parameters:
      template - a template instance
  • Method Details

    • mapComponentOrElement

      public void mapComponentOrElement(Field field, String id, String tag, Consumer<Element> beforeInject)
      Maps an element or component to the given field.

      If an element with the given id exists in the template element tree, that element is used.

      If no element exists (the typical case), a virtual element is created and later on, when the template has been rendered in the client, is connected to the rendered element with the given id.

      Parameters:
      field - the field to assign the element/component to
      id - the id of the element to map
      tag - the tag of the injected element or null if not known
      beforeInject - a callback invoked before assigning the element/component to the field
    • getOrCreateShadowRoot

      public ShadowRoot getOrCreateShadowRoot()
      Gets the shadow root for the template.

      Creates a shadow root if the template does not have one.

      Returns:
      the shadow root for the template
    • reset

      public void reset()
      Resets the mapper to its original state, clearing any registered mappings.
    • isMapped

      public boolean isMapped(String id)
      Checks if the given id has been mapped.
      Parameters:
      id - the id to check
      Returns:
      true if the element has been mapped, false otherwise