當前位置: 首頁>>代碼示例>>Java>>正文


Java Repository類代碼示例

本文整理匯總了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));
}
 
開發者ID:Sefford,項目名稱:kor,代碼行數:18,代碼來源:TwoTierRepositoryTest.java

示例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));
}
 
開發者ID:Sefford,項目名稱:kor,代碼行數:19,代碼來源:TwoTierRepositoryTest.java

示例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));
}
 
開發者ID:Sefford,項目名稱:kor,代碼行數:22,代碼來源:TwoTierRepositoryTest.java

示例4: GetPhoneContactsDelegate

import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
public GetPhoneContactsDelegate(Context context, Repository<Long, Contact> cache) {
    this.context = context;
    this.cache = cache;
}
 
開發者ID:Sefford,項目名稱:material-in-30-minutes,代碼行數:5,代碼來源:GetPhoneContactsDelegate.java

示例5: GetContactDelegate

import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
public GetContactDelegate(Repository<Long, Contact> repository, long id) {
    this.repository = repository;
    this.id = id;
}
 
開發者ID:Sefford,項目名稱:material-in-30-minutes,代碼行數:5,代碼來源:GetContactDelegate.java

示例6: provideContactCache

import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
@Provides
@Singleton
public Repository<Long, Contact> provideContactCache() {
    return new ContactRepository();
}
 
開發者ID:Sefford,項目名稱:material-in-30-minutes,代碼行數:6,代碼來源:CoreModule.java

示例7: UserRepository

import com.sefford.kor.repositories.interfaces.Repository; //導入依賴的package包/類
public UserRepository(Repository<String, User> currentLevel, Repository<String, User> nextLevel) {
    super(currentLevel, nextLevel);
}
 
開發者ID:Sefford,項目名稱:Kor-Sample,代碼行數:4,代碼來源:UserRepository.java

示例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;
}
 
開發者ID:Sefford,項目名稱:material-in-30-minutes,代碼行數:13,代碼來源:GetContact.java

示例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;
}
 
開發者ID:Sefford,項目名稱:material-in-30-minutes,代碼行數:13,代碼來源:GetContacts.java

示例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);
}
 
開發者ID:Sefford,項目名稱:kor,代碼行數:11,代碼來源:LruRepository.java

示例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;
}
 
開發者ID:Sefford,項目名稱:kor,代碼行數:13,代碼來源:TwoTierRepository.java

示例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);
}
 
開發者ID:Sefford,項目名稱:kor,代碼行數:12,代碼來源:TwoTierFastRepository.java

示例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;
}
 
開發者ID:Sefford,項目名稱:kor,代碼行數:11,代碼來源:ExpirationRepository.java


注:本文中的com.sefford.kor.repositories.interfaces.Repository類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。