本文整理汇总了Java中java.util.AbstractMap.SimpleEntry类的典型用法代码示例。如果您正苦于以下问题:Java SimpleEntry类的具体用法?Java SimpleEntry怎么用?Java SimpleEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleEntry类属于java.util.AbstractMap包,在下文中一共展示了SimpleEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.util.AbstractMap.SimpleEntry; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
List<Entry> actualEntries = findEntries();
List<Entry> expectedEntries = List.of(
new SimpleEntry<>(29, 0),
new SimpleEntry<>(30, 4),
new SimpleEntry<>(32, 9),
new SimpleEntry<>(33, 16),
new SimpleEntry<>(34, 32),
new SimpleEntry<>(35, 46),
new SimpleEntry<>(36, 52)
);
if (!Objects.equals(actualEntries, expectedEntries)) {
error(String.format("Unexpected LineNumberTable: %s", actualEntries.toString()));
}
try {
new Test();
} catch (NullPointerException npe) {
if (Arrays.stream(npe.getStackTrace())
.noneMatch(se -> se.getFileName().contains("NullCheckLineNumberTest") &&
se.getLineNumber() == 34)) {
throw new AssertionError("Should go through line 34!");
}
}
}
示例2: exportParameters
import java.util.AbstractMap.SimpleEntry; //导入依赖的package包/类
/**
* Extracts and exports normal parameters
*
* @param writer Writer object
* @param ob Object
* @throws XMLStreamException
*/
static void exportParameters(XMLStreamWriter writer,
Object ob) throws XMLStreamException {
Method[] mets = ob.getClass().getMethods();
for(Method m : mets) {
//lookup if the Method is marked as ExchangeParameter and NOT a setter
ExchangeParameter ep = m.getAnnotation(ExchangeParameter.class);
if(ep != null && m.getName().contains("get")) {
writer.writeEmptyElement("Parameter");
String paramName = m.getName().substring(3);
SimpleEntry<String, String> se = exportParamType(ob, m.getName());
writer.writeAttribute("name", paramName);
writer.writeAttribute("type", se.getKey());
writer.writeAttribute("value", se.getValue());
}
}
}
示例3: exportConstructParameters
import java.util.AbstractMap.SimpleEntry; //导入依赖的package包/类
/**
* Extracts and write out the AdditionalConstructionParameters to the writer
*
* @param writer Given Writer
* @param ob Object with annotations from AdditionalConstructParameter.class
* @throws XMLStreamException
*/
static void exportConstructParameters(XMLStreamWriter writer,
Object ob) throws XMLStreamException {
//Get the Construction Parameters
AdditionalConstructParameter acp = ob.getClass().getAnnotation(AdditionalConstructParameter.class);
if(acp != null) {
for(int i = 0; i < acp.parameterGetters().length; i++) {
writer.writeEmptyElement("ConstructParameter");
writer.writeAttribute("name", acp.parameterNames()[i]);
SimpleEntry<String, String> se = exportParamType(ob, acp.parameterGetters()[i]);
writer.writeAttribute("type", se.getKey());
writer.writeAttribute("value", se.getValue());
}
}
}
示例4: getSortedService
import java.util.AbstractMap.SimpleEntry; //导入依赖的package包/类
public static <T> List<T> getSortedService(Class<T> serviceType) {
List<Entry<Integer, T>> serviceEntries = new ArrayList<>();
ServiceLoader<T> serviceLoader = ServiceLoader.load(serviceType);
serviceLoader.forEach(service -> {
int serviceOrder = 0;
Method getOrder = ReflectionUtils.findMethod(service.getClass(), "getOrder");
if (getOrder != null) {
serviceOrder = (int) ReflectionUtils.invokeMethod(getOrder, service);
}
Entry<Integer, T> entry = new SimpleEntry<>(serviceOrder, service);
serviceEntries.add(entry);
});
return serviceEntries.stream()
.sorted(Comparator.comparingInt(Entry::getKey))
.map(Entry::getValue)
.collect(Collectors.toList());
}
示例5: firstEntry
import java.util.AbstractMap.SimpleEntry; //导入依赖的package包/类
public static <K, V> Entry<K, V> firstEntry(NavigableMap<K, ? extends Iterable<V>> map) {
Entry<K, V> result = null;
Iterator<? extends Entry<K, ? extends Iterable<V>>> itE = map.entrySet().iterator();
// For robustness, remove entry valueX sets
while(itE.hasNext()) {
Entry<K, ? extends Iterable<V>> e = itE.next();
K k = e.getKey();
Iterable<V> vs = e.getValue();
Iterator<V> itV = vs.iterator();
if(itV.hasNext()) {
V v = itV.next();
result = new SimpleEntry<>(k, v);
break;
} else {
continue;
}
}
return result;
}
开发者ID:SmartDataAnalytics,项目名称:SubgraphIsomorphismIndex,代码行数:26,代码来源:ProblemContainerNeighbourhoodAware.java
示例6: testExtraLinks
import java.util.AbstractMap.SimpleEntry; //导入依赖的package包/类
@Test
public void testExtraLinks() {
final String inbox = "http://ldn.example.com/inbox";
final String annService = "http://annotation.example.com/resource";
when(mockResource.getExtraLinkRelations()).thenAnswer(inv -> Stream.of(
new SimpleEntry<>(annService, OA.annotationService.getIRIString()),
new SimpleEntry<>(SKOS.Concept.getIRIString(), "type"),
new SimpleEntry<>(inbox, "inbox")));
when(mockHeaders.getAcceptableMediaTypes()).thenReturn(singletonList(TEXT_TURTLE_TYPE));
final GetHandler getHandler = new GetHandler(mockLdpRequest, mockResourceService,
mockIoService, mockBinaryService, baseUrl);
final Response res = getHandler.getRepresentation(mockResource).build();
assertEquals(OK, res.getStatusInfo());
assertTrue(res.getLinks().stream().anyMatch(hasType(SKOS.Concept)));
assertTrue(res.getLinks().stream().anyMatch(hasLink(rdf.createIRI(inbox), "inbox")));
assertTrue(res.getLinks().stream().anyMatch(hasLink(rdf.createIRI(annService),
OA.annotationService.getIRIString())));
}
示例7: iterator
import java.util.AbstractMap.SimpleEntry; //导入依赖的package包/类
public final Iterator<Map.Entry<K,V>> iterator() {
return new MapIterator<Map.Entry<K,V>>() {
@Override
public Map.Entry<K,V> next() {
if (mapEntry == null) {
throw new NoSuchElementException();
}
SimpleEntry<K, V> result = new SimpleEntry<K, V>(mapEntry.getKey(), readValue(mapEntry.getValue()));
mapEntry = null;
return result;
}
@Override
public void remove() {
if (mapEntry == null) {
throw new IllegalStateException();
}
map.remove(mapEntry.getKey(), mapEntry.getValue());
mapEntry = null;
}
};
}
示例8: findEntries
import java.util.AbstractMap.SimpleEntry; //导入依赖的package包/类
static List<Entry> findEntries() throws IOException, ConstantPoolException {
ClassFile self = ClassFile.read(NullCheckLineNumberTest.Test.class.getResourceAsStream("NullCheckLineNumberTest$Test.class"));
for (Method m : self.methods) {
if ("<init>".equals(m.getName(self.constant_pool))) {
Code_attribute code_attribute = (Code_attribute)m.attributes.get(Attribute.Code);
for (Attribute at : code_attribute.attributes) {
if (Attribute.LineNumberTable.equals(at.getName(self.constant_pool))) {
return Arrays.stream(((LineNumberTable_attribute)at).line_number_table)
.map(e -> new SimpleEntry<> (e.line_number, e.start_pc))
.collect(Collectors.toList());
}
}
}
}
return null;
}
示例9: sendMessageToManagerForConfiguredShards
import java.util.AbstractMap.SimpleEntry; //导入依赖的package包/类
private <T> void sendMessageToManagerForConfiguredShards(DataStoreType dataStoreType,
List<Entry<ListenableFuture<T>, ShardResultBuilder>> shardResultData,
Function<String, Object> messageSupplier) {
ActorContext actorContext = dataStoreType == DataStoreType.Config ? configDataStore.getActorContext()
: operDataStore.getActorContext();
Set<String> allShardNames = actorContext.getConfiguration().getAllShardNames();
LOG.debug("Sending message to all shards {} for data store {}", allShardNames, actorContext.getDataStoreName());
for (String shardName: allShardNames) {
ListenableFuture<T> future = this.ask(actorContext.getShardManager(), messageSupplier.apply(shardName),
SHARD_MGR_TIMEOUT);
shardResultData.add(new SimpleEntry<>(future,
new ShardResultBuilder().setShardName(shardName).setDataStoreType(dataStoreType)));
}
}
示例10: possiblyAddConfigModuleIdentifier
import java.util.AbstractMap.SimpleEntry; //导入依赖的package包/类
private void possiblyAddConfigModuleIdentifier(final ServiceReference<?> reference,
final List<Entry<String, ModuleIdentifier>> configModules) {
Object moduleNamespace = reference.getProperty(CONFIG_MODULE_NAMESPACE_PROP);
if (moduleNamespace == null) {
return;
}
String moduleName = getRequiredConfigModuleProperty(CONFIG_MODULE_NAME_PROP, moduleNamespace,
reference);
String instanceName = getRequiredConfigModuleProperty(CONFIG_INSTANCE_NAME_PROP, moduleNamespace,
reference);
if (moduleName == null || instanceName == null) {
return;
}
LOG.debug("Found service with config module: namespace {}, module name {}, instance {}",
moduleNamespace, moduleName, instanceName);
configModules.add(new SimpleEntry<>(moduleNamespace.toString(),
new ModuleIdentifier(moduleName, instanceName)));
}
示例11: returnFNameLineGroup
import java.util.AbstractMap.SimpleEntry; //导入依赖的package包/类
/**
* Searches for a group of Keys and print each occurrence and its file name.
* @param keys
*/
private ArrayList<SimpleEntry> returnFNameLineGroup(String[] keys, boolean printName){
ArrayList<SimpleEntry> eA = new ArrayList<>();
ArrayList<SimpleEntry> keyRes = new ArrayList<>();
for (String s: keys){
keyRes = this.sU.searchForKeyInJava(s,this.codeRoot);
if (printName && (!keyRes.isEmpty()))
OutBut.printH3(s);
eA.addAll(this.sU.searchForKeyInJava(s,this.codeRoot));
}
return eA;
}
示例12: createDatastoreClient
import java.util.AbstractMap.SimpleEntry; //导入依赖的package包/类
@SuppressWarnings("checkstyle:IllegalCatch")
private Entry<DataStoreClient, ActorRef> createDatastoreClient(
final String shardName, final ActorContext actorContext)
throws DOMDataTreeShardCreationFailedException {
LOG.debug("{}: Creating distributed datastore client for shard {}", memberName, shardName);
final Props distributedDataStoreClientProps =
SimpleDataStoreClientActor.props(memberName, "Shard-" + shardName, actorContext, shardName);
final ActorRef clientActor = actorSystem.actorOf(distributedDataStoreClientProps);
try {
return new SimpleEntry<>(SimpleDataStoreClientActor
.getDistributedDataStoreClient(clientActor, 30, TimeUnit.SECONDS), clientActor);
} catch (final Exception e) {
LOG.error("{}: Failed to get actor for {}", distributedDataStoreClientProps, memberName, e);
clientActor.tell(PoisonPill.getInstance(), noSender());
throw new DOMDataTreeShardCreationFailedException(
"Unable to create datastore client for shard{" + shardName + "}", e);
}
}
示例13: getContentURIsFromSmali
import java.util.AbstractMap.SimpleEntry; //导入依赖的package包/类
public void getContentURIsFromSmali(String smaliPath){
this.contentURIs = new ArrayList<String>();
ArrayList<String> contents = new ArrayList<String>();
ArrayList<SimpleEntry> contentsReturn =new ArrayList<SimpleEntry>();
SearchUtil searcher = new SearchUtil();
String contentUri;
contents = searcher.search4KeyInDir(smaliPath, "content://");
for (String c:contents){
if (!"".equals(contentUri = this.correctContentUri(c)))
this.contentURIs.add(contentUri);
}
this.contentURIs = this.removeDuplicates(this.contentURIs);
}
示例14: parseRaw
import java.util.AbstractMap.SimpleEntry; //导入依赖的package包/类
private SimpleEntry<String, Integer> parseRaw(byte[] input, int index) {
StringBuilder result = new StringBuilder();
int advance = 0;
ArrayList<Byte> raw = new ArrayList<>();
while (!isKnownByte(input[index + advance])) {
raw.add(input[index + advance]);
advance++;
if (index + advance >= input.length)
break;
if (conditionalLengths.size() > 0 && conditionalIndexes.size() > 0) {
if (index + advance >= conditionalLengths.peek() + conditionalIndexes.peek())
break;
}
}
advance--;
result.append("raw(");
for (int x = 0; x < raw.size(); x++) {
result.append(Integer.toHexString(raw.get(x) & 0xFF));
if (x < raw.size() - 1)
result.append(",");
else
result.append(")");
}
return new SimpleEntry<>(result.toString(), advance);
}
示例15: parseReturn
import java.util.AbstractMap.SimpleEntry; //导入依赖的package包/类
private SimpleEntry<String, Integer> parseReturn(byte[] input, int index) {
String result;
int advance = 2;
int returnPoint = (ScriptUtils.shortFromByteArray(input, index + 1) + 3) * -1; // Return markers will always use a negative value.
if (savedPoints.containsKey(index - returnPoint)) {
int point = savedPoints.get(index - returnPoint);
int line = point + lineNumber;
//Special case fix for A002_OP1 bev file.
if (input[index - returnPoint] != 0x47 && (decompiled.get(point).startsWith("ev::") || decompiled.get(point).startsWith("bev::"))) {
return this.parseRaw(input, index, 3);
}
result = "goto(" + line + ")";
return new SimpleEntry<>(result, advance);
} else {
return this.parseRaw(input, index, 3);
}
}