本文整理匯總了Java中com.sefford.kor.repositories.interfaces.Repository類的典型用法代碼示例。如果您正苦於以下問題:Java Repository類的具體用法?Java Repository怎麽用?Java Repository使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Repository類屬於com.sefford.kor.repositories.interfaces包,在下文中一共展示了Repository類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testThreeTierResolvesGetCorrectly
import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
@Test
public void testThreeTierResolvesGetCorrectly() throws Exception {
final Repository<Integer, TestElement> firstLevel = mock(Repository.class);
final Repository<Integer, TestElement> secondLevel = mock(Repository.class);
final Repository<Integer, TestElement> thirdLevel = mock(Repository.class);
final TwoTierRepository<Integer, TestElement> localLevel = new TwoTierRepository(firstLevel, secondLevel);
final TwoTierRepository<Integer, TestElement> repository = new TwoTierRepository(localLevel, thirdLevel);
when(firstLevel.get(EXPECTED_FIRST_ID)).thenReturn(null);
when(firstLevel.isAvailable()).thenReturn(Boolean.TRUE);
when(secondLevel.isAvailable()).thenReturn(Boolean.FALSE);
when(thirdLevel.isAvailable()).thenReturn(Boolean.TRUE);
when(thirdLevel.get(EXPECTED_FIRST_ID)).thenReturn(mock(TestElement.class));
assertNotNull(repository.get(EXPECTED_FIRST_ID));
}
示例2: testThreeTierResolvesContainsCorrectly
import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
@Test
public void testThreeTierResolvesContainsCorrectly() throws Exception {
final Repository<Integer, TestElement> firstLevel = mock(Repository.class);
final Repository<Integer, TestElement> secondLevel = mock(Repository.class);
final Repository<Integer, TestElement> thirdLevel = mock(Repository.class);
final TwoTierRepository<Integer, TestElement> localLevel = new TwoTierRepository(firstLevel, secondLevel);
final TwoTierRepository<Integer, TestElement> repository = new TwoTierRepository(localLevel, thirdLevel);
when(firstLevel.contains(EXPECTED_FIRST_ID)).thenReturn(Boolean.FALSE);
when(firstLevel.isAvailable()).thenReturn(Boolean.TRUE);
when(secondLevel.contains(EXPECTED_FIRST_ID)).thenReturn(Boolean.FALSE);
when(secondLevel.isAvailable()).thenReturn(Boolean.FALSE);
when(thirdLevel.isAvailable()).thenReturn(Boolean.TRUE);
when(thirdLevel.contains(EXPECTED_FIRST_ID)).thenReturn(Boolean.TRUE);
assertTrue(repository.contains(EXPECTED_FIRST_ID));
}
示例3: testTierOneDoesNotContainElementTierTwoFailsAndTierThreeResolves
import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
@Test
public void testTierOneDoesNotContainElementTierTwoFailsAndTierThreeResolves() {
final Repository<Integer, TestElement> firstLevel = mock(Repository.class);
final Repository<Integer, TestElement> secondLevel = mock(Repository.class);
final Repository<Integer, TestElement> thirdLevel = mock(Repository.class);
final TwoTierRepository<Integer, TestElement> localLevel = new TwoTierRepository(firstLevel, secondLevel);
final TwoTierRepository<Integer, TestElement> repository = new TwoTierRepository(localLevel, thirdLevel);
when(firstLevel.contains(EXPECTED_FIRST_ID)).thenReturn(Boolean.FALSE);
when(firstLevel.isAvailable()).thenReturn(Boolean.TRUE);
when(firstLevel.get(EXPECTED_FIRST_ID)).thenReturn(null);
when(secondLevel.contains(EXPECTED_FIRST_ID)).thenReturn(Boolean.TRUE);
when(secondLevel.isAvailable()).thenReturn(Boolean.FALSE);
when(secondLevel.get(EXPECTED_FIRST_ID)).thenReturn(null);
when(thirdLevel.isAvailable()).thenReturn(Boolean.TRUE);
when(thirdLevel.contains(EXPECTED_FIRST_ID)).thenReturn(Boolean.TRUE);
when(thirdLevel.get(EXPECTED_FIRST_ID)).thenReturn(mockedElement1);
assertThat(repository.get(EXPECTED_FIRST_ID), is(mockedElement1));
}
示例4: GetPhoneContactsDelegate
import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
public GetPhoneContactsDelegate(Context context, Repository<Long, Contact> cache) {
this.context = context;
this.cache = cache;
}
示例5: GetContactDelegate
import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
public GetContactDelegate(Repository<Long, Contact> repository, long id) {
this.repository = repository;
this.id = id;
}
示例6: provideContactCache
import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
@Provides
@Singleton
public Repository<Long, Contact> provideContactCache() {
return new ContactRepository();
}
示例7: UserRepository
import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
public UserRepository(Repository<String, User> currentLevel, Repository<String, User> nextLevel) {
super(currentLevel, nextLevel);
}
示例8: GetContact
import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
/**
* Creates a new instance of the Standalone Interactor.
*
* @param log Logging facilities
* @param executor Execution element
* @param repository
*/
@Inject
public GetContact(Loggable log, ThreadPoolExecutor executor, Repository<Long, Contact> repository) {
super(log, executor);
this.repository = repository;
}
示例9: GetContacts
import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
/**
* Creates a new instance of the Standalone Interactor.
*
* @param log Logging facilities
* @param executor Execution element
* @param cache Contact cache for saving the elements
*/
@Inject
public GetContacts(Loggable log, ThreadPoolExecutor executor, Repository<Long, Contact> cache) {
super(log, executor);
this.cache = cache;
}
示例10: LruRepository
import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
/**
* Wraps a repository which can only hold maxSize elements
*
* @param repository Core repository to add the capability to
* @param maxSize Max elements capable to add to the repository
*/
public LruRepository(Repository<K, V> repository, int maxSize) {
this.repository = repository;
this.lru = new LruCache<>(maxSize);
}
示例11: TwoTierRepository
import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
/**
* Creates a new instance of a TwoTierRepository with next level.
* <p>
* This next level can be optionally initialized to null.
*
* @param currentLevel Current Level of the Repository
* @param nextLevel Next Level of the Repository
*/
public TwoTierRepository(Repository<K, V> currentLevel, Repository<K, V> nextLevel) {
this.currentLevel = currentLevel;
this.nextLevel = nextLevel;
}
示例12: TwoTierFastRepository
import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
/**
* Creates a new instance of a TwoTierRepository with next level.
* <p/>
* This next level can be optionally initialized to null.
*
* @param currentLevel Current Level of the Repository
* @param nextLevel Next Level of the Repository
*/
protected TwoTierFastRepository(FastRepository<K, V> currentLevel, Repository<K, V> nextLevel) {
super((Repository<K, V>) currentLevel, nextLevel);
}
示例13: ExpirationRepository
import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
/**
* Wraps a Repository and enables to apply an Expiration Policy to elements
*
* @param repository Repository to wrap.
* @param policy Expiration policy to apply to the elements
*/
public ExpirationRepository(Repository<K, V> repository, ExpirationPolicy<K> policy) {
this.repository = repository;
this.policy = policy;
}