下面列出了javax.swing.event.TreeSelectionListener#javax.annotation.Nonnull 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void registerExtensions(@Nonnull AndroidDomElement element,
@Nonnull final DomExtensionsRegistrar registrar) {
final AndroidFacet facet = AndroidFacet.getInstance(element);
if (facet == null) {
return;
}
AttributeProcessingUtil.AttributeProcessor callback = (xmlName, attrDef, parentStyleableName)
-> {
Set<?> formats = attrDef.getFormats();
Class valueClass = formats.size() == 1 ? getValueClass(formats.iterator().next()) : String
.class;
registrar.registerAttributeChildExtension(xmlName, GenericAttributeValue.class);
return registrar.registerGenericAttributeValueChildExtension(xmlName, valueClass);
};
try {
FolivoraAttrProcessing.registerFolivoraAttributes(facet, element, callback);
} catch (Exception ignore) {}
}
public void addToUserHistory(final String suggestion, final boolean wasAutoCapitalized,
@Nonnull final NgramContext ngramContext, final long timeStampInSeconds,
final boolean blockPotentiallyOffensive) {
// Update the spelling cache before learning. Words that are not yet added to user history
// and appear in no other language model are not considered valid.
putWordIntoValidSpellingWordCache("addToUserHistory", suggestion);
final String[] words = suggestion.split(Constants.WORD_SEPARATOR);
NgramContext ngramContextForCurrentWord = ngramContext;
for (int i = 0; i < words.length; i++) {
final String currentWord = words[i];
final boolean wasCurrentWordAutoCapitalized = (i == 0) && wasAutoCapitalized;
addWordToUserHistory(mDictionaryGroup, ngramContextForCurrentWord, currentWord,
wasCurrentWordAutoCapitalized, (int) timeStampInSeconds,
blockPotentiallyOffensive);
ngramContextForCurrentWord =
ngramContextForCurrentWord.getNextNgramContext(new WordInfo(currentWord));
}
}
@Nonnull
public StructureData getFeatureData() throws IOException {
if (null == sdata) {
try {
// deal with files that are updating // LOOK kludge?
if (recno > getRecordCount()) {
int n = getRecordCount();
ncfile.syncExtend();
log.info("RecordPointObs.getData recno=" + recno + " > " + n + "; after sync= " + getRecordCount());
}
sdata = recordVar.readStructure(recno);
} catch (ucar.ma2.InvalidRangeException e) {
e.printStackTrace();
throw new IOException(e.getMessage());
}
}
return sdata;
}
@Nonnull
private CompletableFuture<UploadRequest> uploadSymbols(@Nonnull UploadRequest request) {
final String pathToDebugSymbols = request.pathToDebugSymbols;
final String symbolUploadUrl = requireNonNull(request.symbolUploadUrl, "symbolUploadUrl cannot be null");
log("Uploading symbols to resource.");
final CompletableFuture<UploadRequest> future = new CompletableFuture<>();
final File file = new File(filePath.child(pathToDebugSymbols).getRemote());
final RequestBody requestFile = RequestBody.create(null, file);
factory.createUploadService(symbolUploadUrl)
.uploadSymbols(symbolUploadUrl, requestFile)
.whenComplete((responseBody, throwable) -> {
if (throwable != null) {
final AppCenterException exception = logFailure("Upload symbols to resource unsuccessful: ", throwable);
future.completeExceptionally(exception);
} else {
log("Upload symbols to resource successful.");
future.complete(request);
}
});
return future;
}
@Override
@Nonnull
public <T> T invokeAny(@Nonnull Collection<? extends Callable<T>> tasks) throws ExecutionException {
Exception exception = null;
for (Callable<T> task : tasks) {
try {
return task.call();
} catch (Exception e) {
// try next task
exception = e;
}
}
throw new ExecutionException("No tasks finished successfully.", exception);
}
protected Keyboard(@Nonnull final Keyboard keyboard) {
mId = keyboard.mId;
mThemeId = keyboard.mThemeId;
mOccupiedHeight = keyboard.mOccupiedHeight;
mOccupiedWidth = keyboard.mOccupiedWidth;
mBaseHeight = keyboard.mBaseHeight;
mBaseWidth = keyboard.mBaseWidth;
mMostCommonKeyHeight = keyboard.mMostCommonKeyHeight;
mMostCommonKeyWidth = keyboard.mMostCommonKeyWidth;
mMoreKeysTemplate = keyboard.mMoreKeysTemplate;
mMaxMoreKeysKeyboardColumn = keyboard.mMaxMoreKeysKeyboardColumn;
mKeyVisualAttributes = keyboard.mKeyVisualAttributes;
mTopPadding = keyboard.mTopPadding;
mVerticalGap = keyboard.mVerticalGap;
mSortedKeys = keyboard.mSortedKeys;
mShiftKeys = keyboard.mShiftKeys;
mAltCodeKeysWhileTyping = keyboard.mAltCodeKeysWhileTyping;
mIconsSet = keyboard.mIconsSet;
mProximityInfo = keyboard.mProximityInfo;
mProximityCharsCorrectionEnabled = keyboard.mProximityCharsCorrectionEnabled;
mKeyboardLayout = keyboard.mKeyboardLayout;
}
@Override
Integer expected(@Nonnull List<ValueWithTs<Integer>> updates, long currentTimestamp) {
if (updates.isEmpty()) {
return null;
}
int acc = 0;
long lastTs = updates.get(0).getTimestamp();
for (ValueWithTs<Integer> update : updates) {
if (expired(lastTs, update.getTimestamp())) {
acc = 0;
}
acc += update.getValue();
lastTs = update.getTimestamp();
}
return expired(lastTs, currentTimestamp) ? null : acc;
}
public static void runMZmineModule(@Nonnull Class<? extends MZmineRunnableModule> moduleClass,
@Nonnull ParameterSet parameters) {
MZmineRunnableModule module = getModuleInstance(moduleClass);
// Usage Tracker
GoogleAnalyticsTracker GAT =
new GoogleAnalyticsTracker(module.getName(), "/JAVA/" + module.getName());
Thread gatThread = new Thread(GAT);
gatThread.setPriority(Thread.MIN_PRIORITY);
gatThread.start();
// Run the module
final List<Task> newTasks = new ArrayList<>();
final MZmineProject currentProject = projectManager.getCurrentProject();
module.runModule(currentProject, parameters, newTasks);
taskController.addTasks(newTasks.toArray(new Task[0]));
// Log module run in audit log
// AuditLogEntry auditLogEntry = new AuditLogEntry(module, parameters,
// newTasks);
// currentProject.logProcessingStep(auditLogEntry);
}
@ReactMethod
public void disconnectReader(){
if(Terminal.getInstance().getConnectedReader()==null){
sendEventWithName(EVENT_READER_DISCONNECTION_COMPLETION,Arguments.createMap());
}else{
Terminal.getInstance().disconnectReader(new Callback() {
@Override
public void onSuccess() {
sendEventWithName(EVENT_READER_DISCONNECTION_COMPLETION,Arguments.createMap());
}
@Override
public void onFailure(@Nonnull TerminalException e) {
WritableMap errorMap = Arguments.createMap();
errorMap.putString(ERROR,e.getErrorMessage());
sendEventWithName(EVENT_READER_DISCONNECTION_COMPLETION,errorMap);
}
});
}
}
@Nonnull
@Override
Collection<? extends MetricStore.ComponentMetricStore> getStores(MetricStore store, HandlerRequest<EmptyRequestBody, AggregateTaskManagerMetricsParameters> request) {
List<ResourceID> taskmanagers = request.getQueryParameter(TaskManagersFilterQueryParameter.class);
if (taskmanagers.isEmpty()) {
return store.getTaskManagers().values();
} else {
Collection<MetricStore.TaskManagerMetricStore> taskmanagerStores = new ArrayList<>(taskmanagers.size());
for (ResourceID taskmanager : taskmanagers) {
MetricStore.TaskManagerMetricStore taskManagerMetricStore = store.getTaskManagerMetricStore(taskmanager.getResourceIdString());
if (taskManagerMetricStore != null) {
taskmanagerStores.add(taskManagerMetricStore);
}
}
return taskmanagerStores;
}
}
@Nonnull
private <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> KeyGroupedInternalPriorityQueue<T> createInternal(
RegisteredPriorityQueueStateBackendMetaInfo<T> metaInfo) {
final String stateName = metaInfo.getName();
final HeapPriorityQueueSet<T> priorityQueue = priorityQueueSetFactory.create(
stateName,
metaInfo.getElementSerializer());
HeapPriorityQueueSnapshotRestoreWrapper<T> wrapper =
new HeapPriorityQueueSnapshotRestoreWrapper<>(
priorityQueue,
metaInfo,
KeyExtractorFunction.forKeyedObjects(),
keyGroupRange,
numberOfKeyGroups);
registeredPQStates.put(stateName, wrapper);
return priorityQueue;
}
/**
* Factory method to create {@link KeyboardLayout} objects.
*/
public static KeyboardLayout newKeyboardLayout(@Nonnull final List<Key> sortedKeys,
int mostCommonKeyWidth, int mostCommonKeyHeight,
int occupiedWidth, int occupiedHeight) {
final ArrayList<Key> layoutKeys = new ArrayList<Key>();
for (final Key key : sortedKeys) {
if (!ProximityInfo.needsProximityInfo(key)) {
continue;
}
if (key.getCode() != ',') {
layoutKeys.add(key);
}
}
return new KeyboardLayout(layoutKeys, mostCommonKeyWidth,
mostCommonKeyHeight, occupiedWidth, occupiedHeight);
}
/**
* Creates a collection of DPPModuleTreeItem from a queue. Can be used after loading a queue from
* a file.
*
* @param queue The queue.
* @return Collection<DPPModuleTreeItem>.
*/
private @Nonnull Collection<DPPModuleTreeNode> createTreeItemsFromQueue(
@Nullable DataPointProcessingQueue queue) {
Collection<DPPModuleTreeNode> items = new ArrayList<DPPModuleTreeNode>();
if (queue == null)
return items;
for (MZmineProcessingStep<DataPointProcessingModule> step : queue) {
items.add(new DPPModuleTreeNode(step.getModule(), step.getParameterSet()));
}
return items;
}
private void testFailingConsumerLifecycle(FlinkKafkaConsumerBase<String> testKafkaConsumer, @Nonnull Exception expectedException) throws Exception {
try {
setupConsumer(testKafkaConsumer);
testKafkaConsumer.run(new TestSourceContext<>());
fail("Exception should have been thrown from open / run method of FlinkKafkaConsumerBase.");
} catch (Exception e) {
assertThat(ExceptionUtils.findThrowable(e, throwable -> throwable.equals(expectedException)).isPresent(), is(true));
}
testKafkaConsumer.close();
}
@Override
public void write(@Nonnull byte[] data, int offset, int length) {
if ((offset < 0) || (offset > data.length) || (length < 0) ||
((offset + length) > data.length) || ((offset + length) < 0)) {
throw new IndexOutOfBoundsException();
} else if (length == 0) {
return;
}
try {
if (buffer.size() >= bufferSize) {
flushBuffer(false);
}
int remaining = length;
int off = offset;
int len = Math.min(remaining, bufferSize - buffer.size());
while (remaining > 0) {
buffer.write(data, off, len);
if (buffer.size() >= bufferSize) {
flushBuffer(false);
}
off += len;
remaining -= len;
len = Math.min(bufferSize, remaining);
}
} catch (Exception ex) {
responseObserver.onError(ex);
}
}
@Nonnull
private TestingSlotPoolImpl createSlotPoolImpl(ManualClock clock) {
return new TestingSlotPoolImpl(
jobId,
clock,
TestingUtils.infiniteTime(),
timeout,
TestingUtils.infiniteTime());
}
public RedisEventLoop(@Nullable RedisEventLoopGroup parent,
@Nonnull ThreadFactory threadFactory,
@Nonnull RejectedExecutionHandler rejectedExecutionHandler,
@Nonnull JedisPoolAbstract jedisPool) {
super(parent, threadFactory, rejectedExecutionHandler, TASK_BATCH_SIZE);
this.jedisPool = jedisPool;
}
protected LeaderRetrievalHandler(
@Nonnull GatewayRetriever<? extends T> leaderRetriever,
@Nonnull Time timeout,
@Nonnull Map<String, String> responseHeaders) {
this.leaderRetriever = Preconditions.checkNotNull(leaderRetriever);
this.timeout = Preconditions.checkNotNull(timeout);
this.responseHeaders = Preconditions.checkNotNull(responseHeaders);
}
@Nonnull
private File createNonWritableDirectory() throws IOException {
assumeFalse(OperatingSystem.isWindows()); //setWritable doesn't work on Windows.
final File blobStorageDirectory = temporaryFolder.newFolder();
assertTrue(blobStorageDirectory.setExecutable(true, false));
assertTrue(blobStorageDirectory.setReadable(true, false));
assertTrue(blobStorageDirectory.setWritable(false, false));
return blobStorageDirectory;
}
@Nonnull
@Override
public Mono<Void> send(@Nonnull EmailTemplate template, @Nonnull Values context) {
return Mono.just(template)
.map(temp -> convert(temp, context.getAllValues()))
.flatMap(temp -> doSend(temp, template.getSendTo()));
}
/**
* 寻找下一个入站处理器 (头部到尾部) - tail必须实现inboundHandler;
* 此外:由于异常只有inboundHandler有,因此head也必须事件inboundHandler
*
* @return ctx
*/
@Nonnull
private AbstractSessionHandlerContext findNextInboundContext() {
AbstractSessionHandlerContext ctx = this;
do {
ctx = ctx.next;
} while (!ctx.isInbound);
return ctx;
}
@Override
protected CompletableFuture<AsynchronousOperationResult<SavepointInfo>> handleRequest(
@Nonnull HandlerRequest<EmptyRequestBody, SavepointStatusMessageParameters> request,
@Nonnull DispatcherGateway gateway) throws RestHandlerException {
final TriggerId triggerId = request.getPathParameter(TriggerIdPathParameter.class);
return CompletableFuture.completedFuture(AsynchronousOperationResult.completed(savepointHandlerLogic.apply(triggerId)));
}
@Nonnull
@Override
public <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> KeyGroupedInternalPriorityQueue<T>
create(
@Nonnull String stateName,
@Nonnull TypeSerializer<T> byteOrderedElementSerializer) {
return priorityQueueFactory.create(stateName, byteOrderedElementSerializer);
}
/**
* Requests a new slot from the ResourceManager. If there is currently not ResourceManager
* connected, then the request is stashed and send once a new ResourceManager is connected.
*
* @param pendingRequest pending slot request
* @return An {@link AllocatedSlot} future which is completed once the slot is offered to the {@link SlotPool}
*/
@Nonnull
private CompletableFuture<AllocatedSlot> requestNewAllocatedSlotInternal(PendingRequest pendingRequest) {
if (resourceManagerGateway == null) {
stashRequestWaitingForResourceManager(pendingRequest);
} else {
requestSlotFromResourceManager(resourceManagerGateway, pendingRequest);
}
return pendingRequest.getAllocatedSlotFuture();
}
public void connect(@Nonnull String host, int port) {
requireNonNull(host, "host");
checkState(isInitialized(), "Not initialized");
if (isConnected()) {
LOG.debug("Already connected, doing nothing.");
return;
}
try {
bootstrap.option(RxtxChannelOption.BAUD_RATE, port);
channelFuture = bootstrap.connect(new RxtxDeviceAddress(host)).sync();
channelFuture.addListener((ChannelFuture future) -> {
if (future.isSuccess()) {
this.initialized = true;
LOG.info("串口连接并监听成功,名称[{}],波特率[{}]", host, port);
connectionEventListener.onConnect();
} else {
connectionEventListener.onFailedConnectionAttempt();
LOG.info("打开串口时失败,名称[" + host + "], 波特率[" + port + "], 串口可能已被占用!");
}
});
connectFuture = null;
} catch (Exception e) {
e.printStackTrace();
workerGroup.shutdownGracefully();
throw new RuntimeException("RxtxClientChannelManager initialized is " + isInitialized() + ", exception message: " + e.getMessage());
}
}
@Nonnull
private TaskManagerSlot createAndRegisterTaskManagerSlot(SlotID slotId, ResourceProfile resourceProfile, TaskExecutorConnection taskManagerConnection) {
final TaskManagerSlot slot = new TaskManagerSlot(
slotId,
resourceProfile,
taskManagerConnection);
slots.put(slotId, slot);
return slot;
}
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters,
@Nonnull Collection<Task> tasks) {
Task newTask = new ADAP3AlignerTask(project, parameters);
tasks.add(newTask);
return ExitCode.OK;
}
/**
* Marshals this instance to its XML representation.
*
* @param writer The writer to write this instance's XML representation to.
* @throws IOException If there was a problem marshalling this instance.
*/
public void toXml(@Nonnull Writer writer)
throws IOException {
requireNonNull(writer, "writer");
try {
createMarshaller().marshal(this, writer);
}
catch (JAXBException | SAXException exc) {
throw new IOException("Exception marshalling data", exc);
}
}
public void addFeatureType(@Nonnull List<DataType<?>> types) {
for (DataType<?> type : types) {
if (!getFeatureTypes().containsKey(type.getClass())) {
getFeatureTypes().put(type.getClass(), type);
// add to maps
streamFeatures().forEach(f -> {
f.setProperty(type, type.createProperty());
});
}
}
}
public LocalRecoveryDirectoryProviderImpl(
File allocationBaseDir,
@Nonnull JobID jobID,
@Nonnull JobVertexID jobVertexID,
@Nonnegative int subtaskIndex) {
this(new File[]{allocationBaseDir}, jobID, jobVertexID, subtaskIndex);
}