001package arez;
002
003import grim.annotations.OmitType;
004import javax.annotation.Nonnull;
005import javax.annotation.Nullable;
006
007/**
008 * The interface used to look up components by type and id.
009 * This is primarily used by components that represent entities that relate to other entities.
010 */
011@OmitType( unless = "arez.enable_references" )
012public interface Locator
013{
014  /**
015   * Lookup the entity with the specified type and the specified id, returning null if not present.
016   *
017   * @param <T>  the entity type.
018   * @param type the type of the entity.
019   * @param id   the id of the entity.
020   * @return the entity or null if no such entity.
021   */
022  @Nullable
023  <T> T findById( @Nonnull Class<T> type, @Nonnull Object id );
024}