Java Code Examples for javax.annotation.Nonnull
The following examples show how to use
javax.annotation.Nonnull.
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: Folivora Author: Cricin File: FolivoraDomExtender.java License: Apache License 2.0 | 6 votes |
@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) {} }
Example #2
Source Project: openboard Author: dslul File: DictionaryFacilitatorImpl.java License: GNU General Public License v3.0 | 6 votes |
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)); } }
Example #3
Source Project: netcdf-java Author: Unidata File: RecordDatasetHelper.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
@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; }
Example #4
Source Project: appcenter-plugin Author: jenkinsci File: UploadAppToResourceTask.java License: MIT License | 6 votes |
@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; }
Example #5
Source Project: flink Author: flink-tpc-ds File: DirectExecutorService.java License: Apache License 2.0 | 6 votes |
@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); }
Example #6
Source Project: openboard Author: dslul File: Keyboard.java License: GNU General Public License v3.0 | 6 votes |
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; }
Example #7
Source Project: Flink-CEPplus Author: ljygz File: TtlReducingStateVerifier.java License: Apache License 2.0 | 6 votes |
@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; }
Example #8
Source Project: mzmine3 Author: mzmine File: MZmineCore.java License: GNU General Public License v2.0 | 6 votes |
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); }
Example #9
Source Project: react-native-stripe-terminal Author: theopolisme File: RNStripeTerminalModule.java License: MIT License | 6 votes |
@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); } }); } }
Example #10
Source Project: flink Author: flink-tpc-ds File: AggregatingTaskManagersMetricsHandler.java License: Apache License 2.0 | 6 votes |
@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; } }
Example #11
Source Project: Flink-CEPplus Author: ljygz File: HeapKeyedStateBackend.java License: Apache License 2.0 | 6 votes |
@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; }
Example #12
Source Project: openboard Author: dslul File: KeyboardLayout.java License: GNU General Public License v3.0 | 6 votes |
/** * 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); }
Example #13
Source Project: mzmine3 Author: mzmine File: ProcessingComponent.java License: GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #14
Source Project: flink Author: flink-tpc-ds File: FlinkKafkaConsumerBaseTest.java License: Apache License 2.0 | 5 votes |
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(); }
Example #15
Source Project: hadoop-ozone Author: apache File: GrpcOutputStream.java License: Apache License 2.0 | 5 votes |
@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); } }
Example #16
Source Project: flink Author: flink-tpc-ds File: SlotPoolImplTest.java License: Apache License 2.0 | 5 votes |
@Nonnull private TestingSlotPoolImpl createSlotPoolImpl(ManualClock clock) { return new TestingSlotPoolImpl( jobId, clock, TestingUtils.infiniteTime(), timeout, TestingUtils.infiniteTime()); }
Example #17
Source Project: fastjgame Author: hl845740757 File: RedisEventLoop.java License: Apache License 2.0 | 5 votes |
public RedisEventLoop(@Nullable RedisEventLoopGroup parent, @Nonnull ThreadFactory threadFactory, @Nonnull RejectedExecutionHandler rejectedExecutionHandler, @Nonnull JedisPoolAbstract jedisPool) { super(parent, threadFactory, rejectedExecutionHandler, TASK_BATCH_SIZE); this.jedisPool = jedisPool; }
Example #18
Source Project: flink Author: flink-tpc-ds File: LeaderRetrievalHandler.java License: Apache License 2.0 | 5 votes |
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); }
Example #19
Source Project: Flink-CEPplus Author: ljygz File: BlobServerTest.java License: Apache License 2.0 | 5 votes |
@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; }
Example #20
Source Project: jetlinks-community Author: jetlinks File: DefaultEmailNotifier.java License: Apache License 2.0 | 5 votes |
@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())); }
Example #21
Source Project: fastjgame Author: hl845740757 File: AbstractSessionHandlerContext.java License: Apache License 2.0 | 5 votes |
/** * 寻找下一个入站处理器 (头部到尾部) - tail必须实现inboundHandler; * 此外:由于异常只有inboundHandler有,因此head也必须事件inboundHandler * * @return ctx */ @Nonnull private AbstractSessionHandlerContext findNextInboundContext() { AbstractSessionHandlerContext ctx = this; do { ctx = ctx.next; } while (!ctx.isInbound); return ctx; }
Example #22
Source Project: Flink-CEPplus Author: ljygz File: RestClusterClientSavepointTriggerTest.java License: Apache License 2.0 | 5 votes |
@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))); }
Example #23
Source Project: flink Author: flink-tpc-ds File: RocksDBKeyedStateBackend.java License: Apache License 2.0 | 5 votes |
@Nonnull @Override public <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> KeyGroupedInternalPriorityQueue<T> create( @Nonnull String stateName, @Nonnull TypeSerializer<T> byteOrderedElementSerializer) { return priorityQueueFactory.create(stateName, byteOrderedElementSerializer); }
Example #24
Source Project: flink Author: flink-tpc-ds File: SlotPoolImpl.java License: Apache License 2.0 | 5 votes |
/** * 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(); }
Example #25
Source Project: openAGV Author: tcrct File: RxtxClientChannelManager.java License: Apache License 2.0 | 5 votes |
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()); } }
Example #26
Source Project: Flink-CEPplus Author: ljygz File: SlotManager.java License: Apache License 2.0 | 5 votes |
@Nonnull private TaskManagerSlot createAndRegisterTaskManagerSlot(SlotID slotId, ResourceProfile resourceProfile, TaskExecutorConnection taskManagerConnection) { final TaskManagerSlot slot = new TaskManagerSlot( slotId, resourceProfile, taskManagerConnection); slots.put(slotId, slot); return slot; }
Example #27
Source Project: mzmine3 Author: mzmine File: ADAP3AlignerModule.java License: GNU General Public License v2.0 | 5 votes |
@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; }
Example #28
Source Project: openAGV Author: tcrct File: TCSOrderSet.java License: Apache License 2.0 | 5 votes |
/** * 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); } }
Example #29
Source Project: mzmine3 Author: mzmine File: ModularFeatureList.java License: GNU General Public License v2.0 | 5 votes |
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()); }); } } }
Example #30
Source Project: flink Author: flink-tpc-ds File: LocalRecoveryDirectoryProviderImpl.java License: Apache License 2.0 | 5 votes |
public LocalRecoveryDirectoryProviderImpl( File allocationBaseDir, @Nonnull JobID jobID, @Nonnull JobVertexID jobVertexID, @Nonnegative int subtaskIndex) { this(new File[]{allocationBaseDir}, jobID, jobVertexID, subtaskIndex); }