id
stringlengths
7
14
text
stringlengths
1
37.2k
98490554_6
public RetryerBuilder<V> retryIfExceptionOfType(Class<? extends Throwable> exceptionClass) { Preconditions.checkNotNull(exceptionClass, "exceptionClass may not be null"); rejectionPredicate = Predicates.or(rejectionPredicate, new ExceptionClassPredicate<V>(exceptionClass)); return this; }
98605274_28
public void publishDisconnectedEvent(String clientId, ApplicationEventPublisher applicationEventPublisher, Object source) { if (applicationEventPublisher != null) { applicationEventPublisher .publishEvent(new MqttClientDisconnectedEvent(clientId, source)); } }
98639195_9
static Object fix(Object orig) { if (orig instanceof List) { final List<?> list = MappingContext.cast(orig); final List<Object> copy = new ArrayList<>(list.size()); for (Object obj : list) { copy.add(fix(obj)); } return copy; } else if (orig instanceof Map) { final Map<?, ?> map = Mapp...
98709134_1
public static String nowAsHttpDateString() { return timeAsHttpDateString(ZonedDateTime.now(ZoneId.of("GMT"))); }
98797746_0
@Override public User getUserByApi(String token) { String s = HttpClientUtils.doGet(api_getUserByToken + token); QuarkResult quarkResult = JsonUtils.jsonToQuarkResult(s, User.class); User data= (User) quarkResult.getData(); return data; }
98801926_32
int getStrength(long previousDuration, long currentDuration, int strength) { if (isPreviousDurationCloserToGoal(previousDuration, currentDuration)) { return strength - 1; } else { return strength; } }
98805906_15
private boolean isEnabled(org.slf4j.Logger logger, LogLevel level) { Objects.requireNonNull(level, "LogLevel must not be null."); switch (level) { case TRACE: return logger.isTraceEnabled(); case DEBUG: return logger.isDebugEnabled(); case INFO: return...
98876601_2
@Deprecated public static long[] toLongArray(List<Long> ls) { long[] output = new long[ls.size()]; int i = 0; for (Long l : ls) { output[i] = l; i++; } return output; }
98885701_0
@Override public <R, C extends Command<R>> R execute(C command) { CommandHandler<R, C> commandHandler = (CommandHandler<R, C>) registry.get(command.getClass()); return commandHandler.handle(command); }
98887914_2
@Bindable public String getTitle() { return mSound.getName(); }
99030958_0
@Override public Iterator<Schema> iterator() { return this; }
99034741_34
protected static ChaincodeMessage newDeleteStateEventMessage(final String channelId, final String txId, final String collection, final String key) { return newEventMessage(DEL_STATE, channelId, txId, DelState.newBuilder().setCollection(collection).setKey(key).build().toByteString()); }
99161825_30
public void onTooManyRedirects(WebView view, Message cancelMsg, Message continueMsg) { if (loggingEnabled) { logger.logError(String.format(LOCALE, "%s onTooManyRedirects()", SPACE)); } }
99203413_1
@Override public boolean equals(Object obj) { if (obj instanceof OpenSDSInfo) { OpenSDSInfo openSDSInfo = (OpenSDSInfo) obj; if (openSDSInfo.getId().equals(getId())) { return true; } } return false; }
99244131_2
@Override protected boolean internalCancel(String appName, String id, boolean isReplication) { handleCancelation(appName, id, isReplication); return super.internalCancel(appName, id, isReplication); }
99287959_3
public static String parseIpFromUrl(String url) throws MalformedURLException, UnknownHostException { Asserts.notBlank(url, "url can't be null"); InetAddress address = InetAddress.getByName(new URL(url).getHost()); return address.getHostAddress(); }
99313507_1
public static SortedMap<String, List<MigrateTask>> balanceExpand(List<List<NodeIndexRange>> integerListMap, List<String> oldDataNodes, List<String> newDataNodes, int slotsTotalNum) { int newNodeSize = oldDataNodes.size() + newDataNodes.size(); int newSlotPerNode = slotsTotalNum / newNodeSize; TreeMap<String...
99413042_0
void sendEmail(String to, String from, String title, String content) { SimpleMailMessage mail = new SimpleMailMessage(); mail.setTo(to); mail.setFrom(from); mail.setSubject(title); mail.setText(content); javaMailSender.send(mail); }
99449332_6
public Uri getRedirectUri() { return mRedirectUri; }
99486588_8
@Override public void centreOn(Point2D pointOnTarget) { // move to centre point and apply scale Point2D delta = pointOnTarget.subtract(targetPointAtViewportCentre()); translateBy(new Dimension2D(delta.getX(), delta.getY())); }
99613808_20
public String getValue() { return value; }
99666045_26
public void callDomMethod(JSONObject task) { if (task == null) { return; } String method = (String) task.get(WXBridgeManager.METHOD); JSONArray args = (JSONArray) task.get(WXBridgeManager.ARGS); callDomMethod(method,args); }
99676748_0
public static AnnotationSpans extractAnnotationSpans(JCas jCas) { BidiMap sentenceBeginIndexToCharacterIndex = new TreeBidiMap(); BidiMap sentenceEndIndexToCharacterIndex = new TreeBidiMap(); List<Sentence> sentences = new ArrayList<>(JCasUtil.select(jCas, Sentence.class)); for (int i = 0; i < sentence...
99686575_3
@PUT @Path("/{id : \\d+}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Update a Book", response = Book.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "The book is updated"), @ApiResponse(code = 400, message = "Invalid input") }) public Response update(@PathP...
99694869_1
public AlbumDto getAlbumById(String id) { if (id == null || id.isEmpty()) { throw new IllegalArgumentException("Album's identifier can not be empty"); } Album album = albumDao.getById(id); if (album == null) { throw new ResourceNotFoundException("Album with id '" + id + "' not found");...
99695762_5
public SecKillRecoveryCheckResult<T> check(PromotionEntity promotion) { List<EventEntity> entities = this.repository.findByPromotionId(promotion.getPromotionId()); if (!entities.isEmpty()) { long count = entities.stream() .filter(event -> SecKillEventType.CouponGrabbedEvent.equals(event.getType())) ...
99700466_2
@Override public void inject(SpanContext ctx, HttpHeaders headers) { HttpHeadersInjectAdapter injectAdapter = new HttpHeadersInjectAdapter(headers); tracer.inject(ctx, Format.Builtin.HTTP_HEADERS, injectAdapter); }
99742967_18
public List<Dimension> getDimensions(final Metric metric, final MetricRecorder.RecorderContext context) { //Flattening the context hierarchy here allows this dimension mapper to work with multiple cloudwatch //recorders. If a recorder wants to precompute the flattened hierarchy it can do so in its implementatio...
99851447_1
protected void highlightSingleFieldValue(String field, String s, Set<HighlightingQuery> highlightingQueries, Analyzer analyzer, AtomicBoolean anythingHighlighted, ...
100021742_27
public AbstractMessageListenerContainer getListenerContainer(String topic, String subscriptionName) { DefaultMessageListenerContainer listenerContainer = new DefaultMessageListenerContainer(); listenerContainer.setConnectionFactory(connectionFactory); listenerContainer.setPubSubDomain(true); listenerCon...
100035986_2
public static Map<String, Integer> readLabelsFromFile(File file) throws IOException { FileInputStream inputStream = new FileInputStream(file); List<String> lines = IOUtils.readLines(inputStream, UTF8); IOUtils.closeQuietly(inputStream); Map<String, Integer> result = new TreeMap<>(); for (i...
100077276_0
public String fetchDOI(String input) { //From grobid Pattern DOIPattern = Pattern.compile("(10\\.\\d{4,5}\\/[\\S]+[^;,.\\s])"); Matcher doiMatcher = DOIPattern.matcher(input); while (doiMatcher.find()) { if (doiMatcher.groupCount() == 1) { return doiMatcher.group(1); } ...
100086904_0
public List<SupplyLocation> uploadFitleredLocations(List<SupplyLocation> locations) { return this.service.saveSupplyLocationsZipContains504(locations); }
100135378_9
@Override public List<Property> getProperties(Type type) { return getJacksonProperties(type).stream() .filter(JacksonPropertyScanner::isReadable) .map(this::convertProp) .collect(toList()); }
100218123_2
@GetMapping("/mongo/findLikes") public List<Book> findByLikes(@RequestParam String search) { return mongoDbService.findByLikes(search); }
100262257_3
public <T> int sort(T[] array, Comparator<T> comparator, boolean optimized) { if (array == null) { return 0; } int counter = 0; //make sure we enter into first loop of the "while" boolean swapped = true; int lastSwap = array.length-1; while (swapped) { /* if ...
100280380_0
@Override public TrackingEventStream openStream(TrackingToken trackingToken) { return storageEngine().openStream(trackingToken); }
100295611_13
@SafeVarargs @Nullable public static <T> List<T> toList(@Nullable T... arguments) { if (arguments != null) { if (arguments.length == 1) { return Collections.singletonList(arguments[0]); } if (arguments.length > 1) { return Arrays.asList(arguments); } } return null; }
100360236_11
public TextRow append(String text) { return append(text, null); }
100361171_9
@NonNull protected Intent getServiceIntent(String clientId) { Intent intent = super.getServiceIntent(clientId); intent.putExtra(KEY_CHANNEL_TYPE, CHANNEL_WEBSOCKET); return intent; }
100388774_0
public String getDisplayName(){ List<String> names = Arrays.asList(getPrefix(), getGivenName(), getFamilyName(), getSuffix()); return names.stream().filter(Objects::nonNull).collect(Collectors.joining(" ")); }
100394036_2
@NonNull public FirebaseAuthLiveData getFirebaseAuthLiveData() { return firebaseAuthLiveData; }
100402355_74
@Override public Collection<MetricAnomaly<BrokerEntity>> metricAnomalies(Map<BrokerEntity, ValuesAndExtrapolations> metricsHistoryByBroker, Map<BrokerEntity, ValuesAndExtrapolations> currentMetricsByBroker) { LOG.info("Slow broker detection started."); ...
100407794_0
public RichTextElement convert(RichTextElement orig) { if (orig.getValue() == null) { return orig; } orig.setValue(resolveLinks(orig)); orig.setValue(resolveLinkedItems(orig)); if (richTextElementResolver != null) { orig.setValue(richTextElementResolver.resolve(orig.getValue())); ...
100417935_19
public WatchDog(Car car) throws Exception { super(Characters.FLASH); this.car = car; Environment env = Config.getEnvironment(); HEARTBEAT_INTERVAL_MS=env.getInteger(Config.WATCHDOG_HEARTBEAT_INTERVAL_MS); MAX_MISSED_BEATS=env.getInteger(Config.WATCHDOG_MAX_MISSED_BEATS); }
100418846_46
@Override public void deserialize(Binder data, BiDeserializer deserializer) { super.deserialize(data, deserializer); initFromParams(); }
100470026_0
public String returnMessage() { return message; }
100470837_4
@Override public Result search(Query query, Execution execution) { QueryTree tree = query.getModel().getQueryTree(); if (isMetalQuery(tree)) { OrItem orItem = new OrItem(); orItem.addItem(tree.getRoot()); orItem.addItem(new WordItem("metal", "album")); tree.setRoot(orItem); ...
100522769_15
@SuppressWarnings("PMD.ShortMethodName") public static String of(Element element) { return of(element.getClass()); }
100544309_2
public void decrement() { setCount(getCount() - 1); }
100566396_36
public String getMacthResult(String regex, String source, int index) { return getMacthResult(regex,source,index,null); }
100677440_5
private CountByLane countByLane(int lanesNumber, double[] speedLimit, double speed){ for(int i = 1; i <= lanesNumber; i++){ if(speed <= speedLimit[i - 1]){ return new CountByLane(1, i); } } return new CountByLane(1, lanesNumber); }
100683024_676
public static List<LdifEntry> reverseRename( Entry entry, Rdn newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
100716846_10
@Override public Optional<OutputEvent> tryInvoke(InvocationContext ctx, InputEvent evt) { SpringCloudMethod method = loader.getFunction(); Object[] userFunctionParams = coerceParameters(ctx, method, evt); Object result = tryInvoke(method, userFunctionParams); return coerceReturnValue(ctx, method, resul...
100758796_3
void sendColorMsg(MeshId targetMeshId, Colour msgColor) { try { if (targetMeshId != null) { String payload = targetMeshId.toString() + ":" + msgColor.toString(); rmConnector.sendDataReliable(targetMeshId, payload); } } catch (RightMeshException.RightMeshServiceDisconnecte...
100808500_35
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; PutInvariantSpanOp other = (PutInvariantSpanOp) obj; if (ripIndex != other.ripIndex) return false; if (invariantStart != other.invariantStart) ...
100928537_1
public void nextMicrophoneState() { switch (getMicrophoneState()) { case BLOCKED: microphoneState = MicrophoneState.NO_SOUND; jsonParser.setMicrophoneState("softEmptyNoise"); break; case NO_SOUND: microphoneState = MicrophoneState.NEUTRAL_SOUND; ...
100955538_0
public static Cookie parse(String setCookie) { return parse(System.currentTimeMillis(), setCookie); }
101047757_15
@Override public void callPreProcessing(SimulationState simulationState) { Integer graphId = this.properties.getIntegerProperty(graphIdName); Double precisionSeed = this.properties.getDoubleProperty(precisionSeedName); Boolean insideAreaSeed = this.properties.getBooleanProperty(insideAreaSeedName); GraphScenari...
101086314_17
static List<StyleError> validate(OptionManager optionManager, CommandLine commandLine) { OpenAPIParser openApiParser = new OpenAPIParser(); ParseOptions parseOptions = new ParseOptions(); parseOptions.setResolve(true); SwaggerParseResult parserResult = openApiParser.readLocation(optionManager.getSource...
101179084_0
public Single<List<FileContainer>> asList() { this.subject.subscribe(this.itemsObserver); this.size = this.files.size(); this.remains = this.size; Observable<FileContainer> observable = Observable .fromIterable(this.files) .observeOn(AndroidSchedulers.mainThread()) .s...
101184471_9
public Command getCommand(String commandLine) throws InvalidCommandException, InvalidCommandParams { commandLine = commandLine.trim().replaceAll(" {2}", " "); String[] split = commandLine.split(" "); String mainCommand = split[0].toUpperCase(); String[] params = Arrays.copyOfRange(split, 1,...
101231823_11
@Override public int compareTo(final IEXPrice iexPrice) { return compare(this.getNumber(), iexPrice.getNumber()); }
101264180_0
@Override @Transactional public Book saveBook(@NotNull @Valid final Book book) { LOGGER.debug("Creating {}", book); Book existing = repository.findOne(book.getId()); if (existing != null) { throw new BookAlreadyExistsException( String.format("There already exists a book with id=%s", ...
101380382_1
@Override public Call newCall(Request request) { if (shouldMockRequest(request)) { return mockedClient.newCall(request); } else { return realClient.newCall(request); } }
101401522_1
public void priceLevelUpdate(final IEXPriceLevelUpdateMessage iexPriceLevelUpdateMessage) { switch (iexPriceLevelUpdateMessage.getIexMessageType()) { case PRICE_LEVEL_UPDATE_SELL: askSide.priceLevelUpdate(iexPriceLevelUpdateMessage); break; case PRICE_LEVEL_UPDATE_BUY: ...
101408117_12
@Override public int read(byte[] buffer, int offset, int length) throws IOException { int read = 0; try { read = memory.getBytesAt(address, buffer,offset,length); } catch (MemoryFault f) { if (f.getAddress() == address) { /* Couldn't read anything - EOF */ return -1; } else { read = (int)(f.getAddre...
101422199_3
public String escapeForStdIn(String text) { if (text == null) { return null; } int firstEscapableChar = findFirstEscapableChar(text); if (firstEscapableChar == -1) { return text; } StringBuilder sb = new StringBuilder(text.substring(0, firstEscapableChar)); int textLength ...
101436299_2
public static URI getParent(final URI uri) { if (isRoot(uri)) { return null; } else { //get the parent path (with a slash on the end) final URI parent = uri.getPath().endsWith("/") ? uri.resolve("..") : uri.resolve("."); final String parentStr = parent.toString(); //if th...
101466853_6
public static void checkCpuIntensiveInvocation() { if (guiThreadChecker == null){ System.out.println("!!!!!!!!!!!!!! --VCellThreadChecker.setGUIThreadChecker() not set"); Thread.dumpStack(); }else if (guiThreadChecker.isEventDispatchThread() && cpuSuppressed.get() == 0) { System.out.println("!!!!!!!!!!!!!! --ca...
101477481_4
private static Optional<Node> parseNode(String nodeString) { try { return Optional.of(NodeFactoryExtra.parseNode(nodeString)); } catch (RiotException e) { log.error("Parsing of value '{}' failed: {}", nodeString, e.getMessage()); return Optional.empty(); } }
101495687_0
static Set<Dependency> convert(Set<IFeaturePlugin> featurePlugins) { return featurePlugins.stream().map(FeaturePluginToMavenDependencyConverter::convert).collect(Collectors.toSet()); }
101559429_7
@Override public String toString() { return "ActivityResult { ResultCode = " + resultCode + ", Data = " + data + " }"; }
101634406_18
void sync(@NonNull PolicyConfiguration config) { if (!config.getChannels().isPresent()) { LOG.info("No alerts channels for policy {} - skipping...", config.getPolicyName()); return; } LOG.info("Synchronizing alerts channels for policy {}...", config.getPolicyName()); AlertsPolicy policy...
101637037_0
public static EmbeddedJMSBrokerHolder create(final String name, boolean marshal, boolean persistent) { final File tempDir = Files.createTempDir(); LOGGER.debug("Created temporary directory: \"{}\"", tempDir.getAbsolutePath()); return new EmbeddedJMSBrokerHolder(createAndConfigureBrokerService(new BrokerSett...
101650961_1
@SuppressWarnings("unchecked") public <T> T resolve(final String value) { final String resolvedValue = resolve.apply(value); if (!(resolvedValue.startsWith("#{") && value.endsWith("}"))) { return (T) resolvedValue; } return (T) this.resolver.evaluate(resolvedValue, this.expressionContext); }
101732174_16
public static long availableTimeout(long expectedTimeoutMillis) { return availableTimeout(expectedTimeoutMillis, 0); }
101735230_1
@Override public void transmitData(String data, Direction direction) { for (DataReceiver dataReceiver : this.subscribers.get(direction)) { dataReceiver.dataReceived(data); } }
101884957_6
@Override public void onItemClicked(int i) { ArrayList<OsmObject> intentList = new ArrayList<>(); intentList.add(0, this.alternateList.get(i)); PoiList.getInstance().setPoiList(intentList); view.startActivity(); }
101970978_0
protected static void init() { keywordSet.add("-" + HOST_ARGS); keywordSet.add("-" + HELP_ARGS); keywordSet.add("-" + PORT_ARGS); keywordSet.add("-" + PASSWORD_ARGS); keywordSet.add("-" + USERNAME_ARGS); keywordSet.add("-" + ISO8601_ARGS); keywordSet.add("-" + MAX_PRINT_ROW_COUNT_ARGS); }
101989943_11
public static BufferedImage fillBackground(BufferedImage img, Color color) { BufferedImage nImg = new BufferedImage(img.getWidth(), img.getHeight(), img.getType()); Graphics2D g = nImg.createGraphics(); g.setColor(color); g.fillRect(0, 0, nImg.getWidth(), nImg.getHeight()); g.drawImage(img, 0, 0, null); g.dispose...
102014366_2
public void write(int n, long v) { if (n < 1 || n > 64) { throw new IllegalArgumentException( String.format("Unable to write %s bits to value %d", n, v)); } reserve(n); long v1 = v << 64 - n >>> shift; data[index] = data[index] | v1; shift += n; if (shift >= 64) { shift -= 64; index++...
102026692_2
public Long getLeaseId() { initLease(); return leaseId; }
102047648_0
private void getBalance(APDU apdu, byte[] buffer) { Util.setShort(buffer, (byte) 0, balance); apdu.setOutgoingAndSend((byte) 0, (byte) 2); }
102083574_26
static URL findLocalizedResourceURL(String resource, Locale l, IOException[] mal, Class<?> relativeTo) { URL url = null; if (l != null) { url = findResourceURL(resource, "_" + l.getLanguage() + "_" + l.getCountry(), mal, relativeTo); if (url != null) { return url; } u...
102093756_64
Result convertResult(nl.tudelft.serg.evosql.Result evoSqlResult) { return new Result( evoSqlResult.getInputQuery(), evoSqlResult.getPathResults().stream() .filter(pr -> pr.getFixture() != null) .filter(pr -> pr.isSuccess()) .map(thi...
102096357_1
public static float scalarMultiply(float[] lhs, float[] rhs) { return lhs[x]*rhs[x] + lhs[y]*rhs[y] + lhs[z]*rhs[z]; }
102143456_2
@KafkaListener(topics = "${eventing.topic_name}") public void listen(final ConsumerRecord<String, String> consumerRecord, final Acknowledgment ack) { super.handleConsumerRecord(consumerRecord, ack); }
102170678_7
private void getProduct(RoutingContext rc) { String itemId = rc.request().getParam("itemid"); catalogService.getProduct(itemId, ar -> { if (ar.succeeded()) { Product product = ar.result(); if (product != null) { rc.response() .putHeader("Co...
102229956_2
;
102268868_0
public String toString() { return mMajor + "." + mMinor + "." + mBuild; }
102274375_9
public String annotationPropertiesMapping() { return JsonbBuilder.create().toJson(magazine); }
102328857_0
public BaseActionImpl() { }
102341886_2
public static void read(Swagger swagger, Set<Class<?>> classes) { final Reader reader = new Reader(swagger); for (Class<?> cls : classes) { final ReaderContext context = new ReaderContext(swagger, cls, cls, "", null, false, new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), new Array...
102415104_0
@Override public void fetchUsers() { if (this.getView() != null) { this.getView().onLoading(true); this.addDisposable(mRepository.fetchUsers(this.getView().getPage()). subscribeOn(this.getScheduler().io()) .observeOn(this.getScheduler().ui()) .subscri...
102444259_0
public static void sendMessage(WebSocket webSocket, String msg, boolean streaming) { if (streaming && msg.length() > STREAM_BUFFER_SIZE) { int p = 0; while (p < msg.length()) { if (msg.length() - p < STREAM_BUFFER_SIZE) { webSocket.sendContinuationFrame(msg.substring(p), true, 0); p = ms...
102452115_247
public boolean isReleasable(Direction direction, Marble marble) { if (tile == null) { throw new IllegalStateException(TILEABLE_UNPLACED); } Tile neighbour = tile.get(direction); return neighbour != null && neighbour.getTileable().accepts(direction.inverse(), marble); }
102471968_31
@Override @SuppressWarnings("ConstantConditions") public CreditDraft apply(@NonNull final CreditDraftRaw raw) throws Exception { assertEssentialParams(raw); return CreditDraft.builder() .id(raw.id()) .purpose(raw.purposeName()) .amount(raw.amoun...
102596286_136
public static Map<String, String> generatePsbAppServiceIdsByAppSvcName( final String appInstanceName, final Set<String> appServiceNames, int psbMaxAppIdLength) { Map<String, String> psbAppServiceIds = new HashMap<>(appServiceNames.size()); String timeSuffix = String.valueOf(...
102608940_2
@Override public void buy(int amount, JsonObject quote, Handler<AsyncResult<Portfolio>> resultHandler) { if (amount <= 0) { resultHandler.handle(Future.failedFuture("Cannot buy " + quote.getString("name") + " - the amount must be " + "greater than 0")); return; } if (quote.getIn...