类javax.annotation.Nonnull源码实例Demo

下面列出了怎么用javax.annotation.Nonnull的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Folivora   文件: FolivoraDomExtender.java
@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) {}
}
 
源代码2 项目: openboard   文件: DictionaryFacilitatorImpl.java
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));
    }
}
 
源代码3 项目: netcdf-java   文件: RecordDatasetHelper.java
@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;
}
 
源代码5 项目: flink   文件: DirectExecutorService.java
@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);
}
 
源代码6 项目: openboard   文件: Keyboard.java
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;
}
 
源代码7 项目: Flink-CEPplus   文件: TtlReducingStateVerifier.java
@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;
}
 
源代码8 项目: mzmine3   文件: MZmineCore.java
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;
	}
}
 
源代码11 项目: Flink-CEPplus   文件: HeapKeyedStateBackend.java
@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;
}
 
源代码12 项目: openboard   文件: KeyboardLayout.java
/**
 * 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);
}
 
源代码13 项目: mzmine3   文件: ProcessingComponent.java
/**
 * 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;
}
 
源代码14 项目: flink   文件: FlinkKafkaConsumerBaseTest.java
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();
}
 
源代码15 项目: hadoop-ozone   文件: GrpcOutputStream.java
@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);
  }
}
 
源代码16 项目: flink   文件: SlotPoolImplTest.java
@Nonnull
private TestingSlotPoolImpl createSlotPoolImpl(ManualClock clock) {
	return new TestingSlotPoolImpl(
		jobId,
		clock,
		TestingUtils.infiniteTime(),
		timeout,
		TestingUtils.infiniteTime());
}
 
源代码17 项目: fastjgame   文件: RedisEventLoop.java
public RedisEventLoop(@Nullable RedisEventLoopGroup parent,
                      @Nonnull ThreadFactory threadFactory,
                      @Nonnull RejectedExecutionHandler rejectedExecutionHandler,
                      @Nonnull JedisPoolAbstract jedisPool) {
    super(parent, threadFactory, rejectedExecutionHandler, TASK_BATCH_SIZE);
    this.jedisPool = jedisPool;
}
 
源代码18 项目: flink   文件: LeaderRetrievalHandler.java
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);
}
 
源代码19 项目: Flink-CEPplus   文件: BlobServerTest.java
@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;
}
 
源代码20 项目: jetlinks-community   文件: DefaultEmailNotifier.java
@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()));
}
 
源代码21 项目: fastjgame   文件: AbstractSessionHandlerContext.java
/**
 * 寻找下一个入站处理器 (头部到尾部) - 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)));
}
 
源代码23 项目: flink   文件: RocksDBKeyedStateBackend.java
@Nonnull
@Override
public <T extends HeapPriorityQueueElement & PriorityComparable & Keyed> KeyGroupedInternalPriorityQueue<T>
create(
	@Nonnull String stateName,
	@Nonnull TypeSerializer<T> byteOrderedElementSerializer) {
	return priorityQueueFactory.create(stateName, byteOrderedElementSerializer);
}
 
源代码24 项目: flink   文件: SlotPoolImpl.java
/**
 * 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();
}
 
源代码25 项目: openAGV   文件: RxtxClientChannelManager.java
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());
    }
}
 
源代码26 项目: Flink-CEPplus   文件: SlotManager.java
@Nonnull
private TaskManagerSlot createAndRegisterTaskManagerSlot(SlotID slotId, ResourceProfile resourceProfile, TaskExecutorConnection taskManagerConnection) {
	final TaskManagerSlot slot = new TaskManagerSlot(
		slotId,
		resourceProfile,
		taskManagerConnection);
	slots.put(slotId, slot);
	return slot;
}
 
源代码27 项目: mzmine3   文件: ADAP3AlignerModule.java
@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;
}
 
源代码28 项目: openAGV   文件: TCSOrderSet.java
/**
 * 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);
  }
}
 
源代码29 项目: mzmine3   文件: ModularFeatureList.java
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());
      });
    }
  }
}
 
源代码30 项目: flink   文件: LocalRecoveryDirectoryProviderImpl.java
public LocalRecoveryDirectoryProviderImpl(
	File allocationBaseDir,
	@Nonnull JobID jobID,
	@Nonnull JobVertexID jobVertexID,
	@Nonnegative int subtaskIndex) {
	this(new File[]{allocationBaseDir}, jobID, jobVertexID, subtaskIndex);
}
 
 类所在包
 同包方法