001package io.ebeaninternal.api; 002 003import java.util.ArrayList; 004import java.util.List; 005 006/** 007 * The results of bean cache hit. 008 */ 009public class BeanCacheResult<T> { 010 011 private final List<Entry<T>> list = new ArrayList<>(); 012 013 /** 014 * Add an entry. 015 */ 016 public void add(T bean, Object key) { 017 list.add(new Entry<>(bean, key)); 018 } 019 020 /** 021 * Return the hits. 022 */ 023 public List<Entry<T>> hits() { 024 return list; 025 } 026 027 /** 028 * Bean and cache key pair. 029 */ 030 static class Entry<T> { 031 032 private final T bean; 033 private final Object key; 034 035 public Entry(T bean, Object key) { 036 this.bean = bean; 037 this.key = key; 038 } 039 040 /** 041 * Return the natural key or id value. 042 */ 043 public Object getKey() { 044 return key; 045 } 046 047 /** 048 * Return the bean. 049 */ 050 public T getBean() { 051 return bean; 052 } 053 } 054}