下面列出了怎么用com.google.common.collect.testing.TestStringSetGenerator的API类实例代码及写法,或者点击链接到github查看源代码。
private static TestStringSetGenerator onHeapIndexedCollectionGenerator() {
return new TestStringSetGenerator() {
@Override protected Set<String> create(String[] elements) {
IndexedCollection<String> indexedCollection = new ConcurrentIndexedCollection<String>(OnHeapPersistence.onPrimaryKey(QueryFactory.selfAttribute(String.class)));
indexedCollection.addAll(asList(elements));
return indexedCollection;
}
};
}
private static TestStringSetGenerator offHeapIndexedCollectionGenerator() {
return new TestStringSetGenerator() {
@Override protected Set<String> create(String[] elements) {
IndexedCollection<String> indexedCollection = new ConcurrentIndexedCollection<String>(OffHeapPersistence.onPrimaryKey(QueryFactory.selfAttribute(String.class)));
indexedCollection.addAll(asList(elements));
return indexedCollection;
}
};
}
private static TestStringSetGenerator onHeapIndexedCollectionGenerator() {
return new TestStringSetGenerator() {
@Override protected Set<String> create(String[] elements) {
IndexedCollection<String> indexedCollection = new TransactionalIndexedCollection<String>(String.class, OnHeapPersistence.onPrimaryKey(QueryFactory.selfAttribute(String.class)));
indexedCollection.addAll(Arrays.asList(elements));
return indexedCollection;
}
};
}
private static TestStringSetGenerator offHeapIndexedCollectionGenerator() {
return new TestStringSetGenerator() {
@Override protected Set<String> create(String[] elements) {
IndexedCollection<String> indexedCollection = new TransactionalIndexedCollection<String>(String.class, OffHeapPersistence.onPrimaryKey(QueryFactory.selfAttribute(String.class)));
indexedCollection.addAll(Arrays.asList(elements));
return indexedCollection;
}
};
}
private static TestStringSetGenerator onHeapIndexedCollectionGenerator() {
return new TestStringSetGenerator() {
@Override protected Set<String> create(String[] elements) {
IndexedCollection<String> indexedCollection = new ObjectLockingIndexedCollection<String>(OnHeapPersistence.onPrimaryKey(QueryFactory.selfAttribute(String.class)));
indexedCollection.addAll(Arrays.asList(elements));
return indexedCollection;
}
};
}
private static TestStringSetGenerator offHeapIndexedCollectionGenerator() {
return new TestStringSetGenerator() {
@Override protected Set<String> create(String[] elements) {
IndexedCollection<String> indexedCollection = new ObjectLockingIndexedCollection<String>(OffHeapPersistence.onPrimaryKey(QueryFactory.selfAttribute(String.class)));
indexedCollection.addAll(Arrays.asList(elements));
return indexedCollection;
}
};
}
public static Test suite() throws Exception {
return SetTestSuiteBuilder.using(new TestStringSetGenerator() {
@Override
protected Set<String> create(String[] elements) {
Set<String> set = new SingleWriterHashSet<>(elements.length);
Collections.addAll(set, elements);
return set;
}
}).withFeatures(
SetFeature.GENERAL_PURPOSE,
CollectionSize.ANY,
CollectionFeature.NON_STANDARD_TOSTRING)
.named(SingleWriterHashSet.class.getSimpleName())
.createTestSuite();
}