本文整理匯總了Java中com.google.common.collect.ImmutableSortedMap.of方法的典型用法代碼示例。如果您正苦於以下問題:Java ImmutableSortedMap.of方法的具體用法?Java ImmutableSortedMap.of怎麽用?Java ImmutableSortedMap.of使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.ImmutableSortedMap
的用法示例。
在下文中一共展示了ImmutableSortedMap.of方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testViewSerialization
import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
@GwtIncompatible // SerializableTester
public void testViewSerialization() {
Map<String, Integer> map =
ImmutableSortedMap.of("one", 1, "two", 2, "three", 3);
SerializableTester.reserializeAndAssert(map.entrySet());
SerializableTester.reserializeAndAssert(map.keySet());
assertEquals(Lists.newArrayList(map.values()),
Lists.newArrayList(SerializableTester.reserialize(map.values())));
}
示例2: run
import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
@Override
public void run()
{
logger.info("Blast Server Running");
Stopwatch timer = Stopwatch.createStarted();
while (m_keepRunning)
{
long now = System.currentTimeMillis();
DataPoint dataPoint = m_longDataPointFactory.createDataPoint(now, 42);
int row = RandomUtils.nextInt(0, m_numberOfRows);
ImmutableSortedMap<String, String> tags = ImmutableSortedMap.of("row",
String.valueOf(row), "host", "blast_server");
try
{
m_datastore.putDataPoint(m_metricName, tags, dataPoint, m_ttl);
}
catch (DatastoreException e)
{
e.printStackTrace();
}
m_counter ++;
if ((m_counter % 100000 == 0) && (timer.elapsed(TimeUnit.SECONDS) > m_durration))
m_keepRunning = false;
}
}
示例3: IntervalSet
import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
/**
* Construct new set containing the interval with the given start and end position.
*/
public IntervalSet(T start, T end)
{
this(ImmutableSortedMap.of(start, end));
}
示例4: setUp
import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
@Before
public void setUp() {
metaInfo = ImmutableSortedMap.of();
idVegetable = ImmutableTermId.constructWithPrefix("VO:0000001");
idRootVegetable = ImmutableTermId.constructWithPrefix("VO:0000002");
idLeafVegetable = ImmutableTermId.constructWithPrefix("VO:0000003");
idCarrot = ImmutableTermId.constructWithPrefix("VO:0000004");
idBeet = ImmutableTermId.constructWithPrefix("VO:0000005");
idPumpkin = ImmutableTermId.constructWithPrefix("VO:0000006");
idBlueCarrot = ImmutableTermId.constructWithPrefix("VO:0000007");
vertices = ImmutableList.of(idVegetable, idRootVegetable, idLeafVegetable, idCarrot, idBeet,
idPumpkin, idBlueCarrot);
edges = ImmutableList.of(ImmutableEdge.construct(idRootVegetable, idVegetable, 1),
ImmutableEdge.construct(idLeafVegetable, idVegetable, 2),
ImmutableEdge.construct(idCarrot, idRootVegetable, 3),
ImmutableEdge.construct(idBeet, idRootVegetable, 4),
ImmutableEdge.construct(idBeet, idLeafVegetable, 5),
ImmutableEdge.construct(idPumpkin, idRootVegetable, 6),
ImmutableEdge.construct(idBlueCarrot, idCarrot, 7));
graph = ImmutableDirectedGraph.construct(edges);
rootTermId = idVegetable;
ImmutableMap.Builder<TermId, VegetableTerm> termMapBuilder = ImmutableMap.builder();
termMapBuilder.put(idVegetable,
new VegetableTerm(idVegetable, new ArrayList<>(), "vegetable",
"part of a plant that is consumed", null, new ArrayList<>(), new ArrayList<>(), false,
null, null, new ArrayList<>()));
termMapBuilder.put(idRootVegetable,
new VegetableTerm(idRootVegetable, new ArrayList<>(), "root vegetable",
"consumed root part of plant", null, new ArrayList<>(), new ArrayList<>(), false, null,
null, new ArrayList<>()));
termMapBuilder.put(idLeafVegetable,
new VegetableTerm(idLeafVegetable, new ArrayList<>(), "leaf vegetable",
"consumed leaf part of plant", null, new ArrayList<>(), new ArrayList<>(), false, null,
null, new ArrayList<>()));
termMapBuilder.put(idCarrot,
new VegetableTerm(idCarrot, new ArrayList<>(), "carrot",
"carrots are very tasty root vegetables", null, new ArrayList<>(), new ArrayList<>(),
false, null, null, new ArrayList<>()));
termMapBuilder.put(idBlueCarrot,
new VegetableTerm(idBlueCarrot, new ArrayList<>(), "blue carrot",
"blue ones are even better", null, new ArrayList<>(), new ArrayList<>(), false, null,
null, new ArrayList<>()));
termMapBuilder.put(idBeet,
new VegetableTerm(idBeet, new ArrayList<>(), "beet root",
"beets are tasty and can be used for coloring", null, new ArrayList<>(),
new ArrayList<>(), false, null, null, new ArrayList<>()));
termMapBuilder.put(idPumpkin,
new VegetableTerm(idPumpkin, new ArrayList<>(), "pumpkin",
"pumpkins are great for soup and pickling", null, new ArrayList<>(), new ArrayList<>(),
false, null, null, new ArrayList<>()));
termMap = termMapBuilder.build();
ImmutableMap.Builder<Integer, VegetableTermRelation> relationMapBuilder =
ImmutableMap.builder();
relationMapBuilder.put(1, new VegetableTermRelation(idRootVegetable, idVegetable, 1));
relationMapBuilder.put(2, new VegetableTermRelation(idLeafVegetable, idVegetable, 2));
relationMapBuilder.put(3, new VegetableTermRelation(idCarrot, idRootVegetable, 3));
relationMapBuilder.put(4, new VegetableTermRelation(idBeet, idRootVegetable, 4));
relationMapBuilder.put(5, new VegetableTermRelation(idBeet, idLeafVegetable, 5));
relationMapBuilder.put(6, new VegetableTermRelation(idPumpkin, idRootVegetable, 6));
relationMapBuilder.put(7, new VegetableTermRelation(idBlueCarrot, idCarrot, 7));
relationMap = relationMapBuilder.build();
ontology = new ImmutableOntology<VegetableTerm, VegetableTermRelation>(metaInfo, graph,
rootTermId, termMap.keySet(), ImmutableSet.of(), termMap, relationMap);
recipeAnnotations = Lists.newArrayList(new VegetableRecipeAnnotation(idCarrot, "pumpkin soup"),
new VegetableRecipeAnnotation(idPumpkin, "pumpkin soup"),
new VegetableRecipeAnnotation(idPumpkin, "pickled pumpkin"),
new VegetableRecipeAnnotation(idBeet, "pumpkin soup"),
new VegetableRecipeAnnotation(idBlueCarrot, "beet surpreme"),
new VegetableRecipeAnnotation(idBeet, "beet surpreme"));
}
示例5: setUp
import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
@Before
public void setUp() {
metaInfo = ImmutableSortedMap.of();
id1 = ImmutableTermId.constructWithPrefix("HP:0000001");
id2 = ImmutableTermId.constructWithPrefix("HP:0000002");
id3 = ImmutableTermId.constructWithPrefix("HP:0000003");
id4 = ImmutableTermId.constructWithPrefix("HP:0000004");
id5 = ImmutableTermId.constructWithPrefix("HP:0000005");
vertices = ImmutableList.of(id1, id2, id3, id4, id5);
edges =
ImmutableList.of(ImmutableEdge.construct(id1, id2, 1), ImmutableEdge.construct(id1, id3, 2),
ImmutableEdge.construct(id1, id4, 3), ImmutableEdge.construct(id2, id5, 4),
ImmutableEdge.construct(id3, id5, 5), ImmutableEdge.construct(id4, id5, 6));
graph = ImmutableDirectedGraph.construct(edges);
rootTermId = id5;
ImmutableMap.Builder<TermId, TestTerm> termMapBuilder = ImmutableMap.builder();
termMapBuilder.put(id1, new TestTerm(id1, new ArrayList<>(), "term1", "some definition 1", null,
new ArrayList<>(), new ArrayList<>(), false, null, null, new ArrayList<>()));
termMapBuilder.put(id2, new TestTerm(id2, new ArrayList<>(), "term2", "some definition 2", null,
new ArrayList<>(), new ArrayList<>(), false, null, null, new ArrayList<>()));
termMapBuilder.put(id3, new TestTerm(id3, new ArrayList<>(), "term3", "some definition 3", null,
new ArrayList<>(), new ArrayList<>(), false, null, null, new ArrayList<>()));
termMapBuilder.put(id4, new TestTerm(id4, new ArrayList<>(), "term4", "some definition 4", null,
new ArrayList<>(), new ArrayList<>(), false, null, null, new ArrayList<>()));
termMapBuilder.put(id5, new TestTerm(id5, new ArrayList<>(), "term5", "some definition 5", null,
new ArrayList<>(), new ArrayList<>(), false, null, null, new ArrayList<>()));
termMap = termMapBuilder.build();
obsoleteTermMap = ImmutableMap.of();
ImmutableMap.Builder<Integer, TestTermRelation> relationMapBuilder = ImmutableMap.builder();
relationMapBuilder.put(1, new TestTermRelation(id1, id2, 1));
relationMapBuilder.put(2, new TestTermRelation(id1, id3, 2));
relationMapBuilder.put(3, new TestTermRelation(id1, id4, 3));
relationMapBuilder.put(4, new TestTermRelation(id2, id5, 4));
relationMapBuilder.put(5, new TestTermRelation(id3, id5, 5));
relationMapBuilder.put(6, new TestTermRelation(id4, id5, 6));
relationMap = relationMapBuilder.build();
ontology = new ImmutableOntology<TestTerm, TestTermRelation>(metaInfo, graph, rootTermId,
termMap.keySet(), obsoleteTermMap.keySet(), termMap, relationMap);
}
示例6: setUp
import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
@Before
public void setUp() {
objDist =
new ObjectScoreDistribution(1, 2, 10, ImmutableSortedMap.of(0.1, 0.1, 0.5, 0.5, 0.9, 0.9));
}
示例7: generateImmutableSortedMap
import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
@Generates private static <K extends Comparable<? super K>, V> ImmutableSortedMap<K, V>
generateImmutableSortedMap(K key, V value) {
return ImmutableSortedMap.of(key, value);
}
示例8: testReport
import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
@Test
public void testReport() {
final Sender sender = mock(Sender.class);
final DropwizardTransformer transformer = mock(DropwizardTransformer.class);
final InfluxDbMeasurementReporter reporter = new InfluxDbMeasurementReporter(
sender,
new MetricRegistry(),
MetricFilter.ALL,
TimeUnit.SECONDS,
TimeUnit.MILLISECONDS,
clock,
transformer
);
final long timestamp = clock.instant().toEpochMilli();
final SortedMap<String, Gauge> gauges = ImmutableSortedMap.of("some", () -> 5);
final SortedMap<String, Counter> counters = ImmutableSortedMap.of("more", new Counter());
final SortedMap<String, Histogram> histograms = ImmutableSortedMap.of("metrics", new Histogram(new ExponentiallyDecayingReservoir()));
final SortedMap<String, Meter> meters = ImmutableSortedMap.of("for", new Meter());
final SortedMap<String, Timer> timers = ImmutableSortedMap.of("for", new Timer());
final List<InfluxDbMeasurement> expectedMeasurements =
Stream
.of("gauge", "counter", "histogram", "meter", "timer")
.map(name ->
InfluxDbMeasurement.create(
"some",
ImmutableMap.of(),
ImmutableMap.of(name, "stuff"),
timestamp
)
).collect(toList());
when(transformer.fromGauges(gauges, timestamp))
.thenReturn(ImmutableList.of(expectedMeasurements.get(0)));
when(transformer.fromCounters(counters, timestamp))
.thenReturn(ImmutableList.of(expectedMeasurements.get(1)));
when(transformer.fromHistograms(histograms, timestamp))
.thenReturn(ImmutableList.of(expectedMeasurements.get(2)));
when(transformer.fromMeters(meters, timestamp))
.thenReturn(ImmutableList.of(expectedMeasurements.get(3)));
when(transformer.fromTimers(timers, timestamp))
.thenReturn(ImmutableList.of(expectedMeasurements.get(4)));
reporter.report(gauges, counters, histograms, meters, timers);
verify(sender).send(expectedMeasurements);
}
開發者ID:kickstarter,項目名稱:dropwizard-influxdb-reporter,代碼行數:53,代碼來源:InfluxDbMeasurementReporterTest.java
示例9: setUp
import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
@Before
public void setUp() {
metaInfo = ImmutableSortedMap.of();
idVegetable = ImmutableTermId.constructWithPrefix("VO:0000001");
idRootVegetable = ImmutableTermId.constructWithPrefix("VO:0000002");
idLeafVegetable = ImmutableTermId.constructWithPrefix("VO:0000003");
idCarrot = ImmutableTermId.constructWithPrefix("VO:0000004");
idBeet = ImmutableTermId.constructWithPrefix("VO:0000005");
idPumpkin = ImmutableTermId.constructWithPrefix("VO:0000006");
idBlueCarrot = ImmutableTermId.constructWithPrefix("VO:0000007");
vertices = ImmutableList.of(idVegetable, idRootVegetable, idLeafVegetable, idCarrot, idBeet,
idPumpkin, idBlueCarrot);
edges = ImmutableList.of(ImmutableEdge.construct(idRootVegetable, idVegetable, 1),
ImmutableEdge.construct(idLeafVegetable, idVegetable, 2),
ImmutableEdge.construct(idCarrot, idRootVegetable, 3),
ImmutableEdge.construct(idBeet, idRootVegetable, 4),
ImmutableEdge.construct(idBeet, idLeafVegetable, 5),
ImmutableEdge.construct(idPumpkin, idRootVegetable, 6),
ImmutableEdge.construct(idBlueCarrot, idCarrot, 7));
graph = ImmutableDirectedGraph.construct(edges);
rootTermId = idVegetable;
ImmutableMap.Builder<TermId, VegetableTerm> termMapBuilder = ImmutableMap.builder();
termMapBuilder.put(idVegetable,
new VegetableTerm(idVegetable, new ArrayList<>(), "vegetable",
"part of a plant that is consumed", null, new ArrayList<>(), new ArrayList<>(), false,
null, null));
termMapBuilder.put(idRootVegetable,
new VegetableTerm(idRootVegetable, new ArrayList<>(), "root vegetable",
"consumed root part of plant", null, new ArrayList<>(), new ArrayList<>(), false, null,
null));
termMapBuilder.put(idLeafVegetable,
new VegetableTerm(idLeafVegetable, new ArrayList<>(), "leaf vegetable",
"consumed leaf part of plant", null, new ArrayList<>(), new ArrayList<>(), false, null,
null));
termMapBuilder.put(idCarrot,
new VegetableTerm(idCarrot, new ArrayList<>(), "carrot",
"carrots are very tasty root vegetables", null, new ArrayList<>(), new ArrayList<>(),
false, null, null));
termMapBuilder.put(idBlueCarrot,
new VegetableTerm(idBlueCarrot, new ArrayList<>(), "blue carrot",
"blue ones are even better", null, new ArrayList<>(), new ArrayList<>(), false, null,
null));
termMapBuilder.put(idBeet,
new VegetableTerm(idBeet, new ArrayList<>(), "beet root",
"beets are tasty and can be used for coloring", null, new ArrayList<>(),
new ArrayList<>(), false, null, null));
termMapBuilder.put(idPumpkin,
new VegetableTerm(idPumpkin, new ArrayList<>(), "pumpkin",
"pumpkins are great for soup and pickling", null, new ArrayList<>(), new ArrayList<>(),
false, null, null));
termMap = termMapBuilder.build();
ImmutableMap.Builder<Integer, VegetableTermRelation> relationMapBuilder =
ImmutableMap.builder();
relationMapBuilder.put(1, new VegetableTermRelation(idRootVegetable, idVegetable, 1));
relationMapBuilder.put(2, new VegetableTermRelation(idLeafVegetable, idVegetable, 2));
relationMapBuilder.put(3, new VegetableTermRelation(idCarrot, idRootVegetable, 3));
relationMapBuilder.put(4, new VegetableTermRelation(idBeet, idRootVegetable, 4));
relationMapBuilder.put(5, new VegetableTermRelation(idBeet, idLeafVegetable, 5));
relationMapBuilder.put(6, new VegetableTermRelation(idPumpkin, idRootVegetable, 6));
relationMapBuilder.put(7, new VegetableTermRelation(idBlueCarrot, idCarrot, 7));
relationMap = relationMapBuilder.build();
ontology = new ImmutableOntology<VegetableTerm, VegetableTermRelation>(metaInfo, graph,
rootTermId, termMap.keySet(), ImmutableSet.of(), termMap, relationMap);
recipeAnnotations = Lists.newArrayList(new VegetableRecipeAnnotation(idCarrot, "pumpkin soup"),
new VegetableRecipeAnnotation(idPumpkin, "pumpkin soup"),
new VegetableRecipeAnnotation(idPumpkin, "pickled pumpkin"),
new VegetableRecipeAnnotation(idBeet, "pumpkin soup"),
new VegetableRecipeAnnotation(idBlueCarrot, "beet surpreme"),
new VegetableRecipeAnnotation(idBeet, "beet surpreme"));
}
示例10: setUp
import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
@Before
public void setUp() {
metaInfo = ImmutableSortedMap.of();
id1 = ImmutableTermId.constructWithPrefix("HP:0000001");
id2 = ImmutableTermId.constructWithPrefix("HP:0000002");
id3 = ImmutableTermId.constructWithPrefix("HP:0000003");
id4 = ImmutableTermId.constructWithPrefix("HP:0000004");
id5 = ImmutableTermId.constructWithPrefix("HP:0000005");
vertices = ImmutableList.of(id1, id2, id3, id4, id5);
edges =
ImmutableList.of(ImmutableEdge.construct(id1, id2, 1), ImmutableEdge.construct(id1, id3, 2),
ImmutableEdge.construct(id1, id4, 3), ImmutableEdge.construct(id2, id5, 4),
ImmutableEdge.construct(id3, id5, 5), ImmutableEdge.construct(id4, id5, 6));
graph = ImmutableDirectedGraph.construct(edges);
rootTermId = id5;
ImmutableMap.Builder<TermId, TestTerm> termMapBuilder = ImmutableMap.builder();
termMapBuilder.put(id1, new TestTerm(id1, new ArrayList<>(), "term1", "some definition 1", null,
new ArrayList<>(), new ArrayList<>(), false, null, null));
termMapBuilder.put(id2, new TestTerm(id2, new ArrayList<>(), "term2", "some definition 2", null,
new ArrayList<>(), new ArrayList<>(), false, null, null));
termMapBuilder.put(id3, new TestTerm(id3, new ArrayList<>(), "term3", "some definition 3", null,
new ArrayList<>(), new ArrayList<>(), false, null, null));
termMapBuilder.put(id4, new TestTerm(id4, new ArrayList<>(), "term4", "some definition 4", null,
new ArrayList<>(), new ArrayList<>(), false, null, null));
termMapBuilder.put(id5, new TestTerm(id5, new ArrayList<>(), "term5", "some definition 5", null,
new ArrayList<>(), new ArrayList<>(), false, null, null));
termMap = termMapBuilder.build();
obsoleteTermMap = ImmutableMap.of();
ImmutableMap.Builder<Integer, TestTermRelation> relationMapBuilder = ImmutableMap.builder();
relationMapBuilder.put(1, new TestTermRelation(id1, id2, 1));
relationMapBuilder.put(2, new TestTermRelation(id1, id3, 2));
relationMapBuilder.put(3, new TestTermRelation(id1, id4, 3));
relationMapBuilder.put(4, new TestTermRelation(id2, id5, 4));
relationMapBuilder.put(5, new TestTermRelation(id3, id5, 5));
relationMapBuilder.put(6, new TestTermRelation(id4, id5, 6));
relationMap = relationMapBuilder.build();
ontology = new ImmutableOntology<TestTerm, TestTermRelation>(metaInfo, graph, rootTermId,
termMap.keySet(), obsoleteTermMap.keySet(), termMap, relationMap);
}