com.vaadin.flow.component.template.internal.
Class IdMapper
- java.lang.Object
-
- com.vaadin.flow.component.template.internal.IdMapper
-
All Implemented Interfaces:
Direct Known Subclasses:
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:
-
-
Method Summary
All Methods Modifier and Type Method Description ShadowRoot
getOrCreateShadowRoot()
Gets the shadow root for the template.
boolean
isMapped(String id)
Checks if the given id has been mapped.
void
mapComponentOrElement(Field field, String id, String tag, Consumer<Element> beforeInject)
Maps an element or component to the given field.
void
reset()
Resets the mapper to its original state, clearing any registered mappings.
-
-
-
Constructor Detail
-
IdMapper
public IdMapper(Component template)
Creates a mapper for the given template.
Parameters:
template
- a template instance
-
-
Method Detail
-
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 toid
- the id of the element to maptag
- the tag of the injected element ornull
if not knownbeforeInject
- 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 checkReturns:
true
if the element has been mapped,false
otherwise
-
-