001package arez.component; 002 003import arez.Arez; 004import java.util.Objects; 005import javax.annotation.Nonnull; 006 007/** 008 * Exception thrown by repository when the query for a specific entity failed. 009 */ 010@SuppressWarnings( "GwtInconsistentSerializableClass" ) 011public class NoSuchEntityException 012 extends NoResultException 013{ 014 @Nonnull 015 private final Object _id; 016 017 /** 018 * Create the exception 019 * 020 * @param id the id of the entity that was queried. 021 */ 022 public NoSuchEntityException( @Nonnull final Object id ) 023 { 024 _id = Objects.requireNonNull( id ); 025 } 026 027 /** 028 * Return the id of the entity that was not found. 029 * 030 * @return the id of the entity that was not found. 031 */ 032 @Nonnull 033 public Object getId() 034 { 035 return _id; 036 } 037 038 @Override 039 public String toString() 040 { 041 if ( Arez.areNamesEnabled() ) 042 { 043 return "NoSuchEntityException[id=" + _id + ']'; 044 } 045 else 046 { 047 return super.toString(); 048 } 049 } 050}