id
stringlengths
7
14
text
stringlengths
1
37.2k
75718771_0
@Override protected void onHandleIntent(Intent intent) { Intent resultIntent = new Intent(RESULT_INTENT_ACTION); Integer result = new Computer().compute(); resultIntent.putExtra(RESULT_VALUE_INTENT_EXTRA_KEY, result); sendBroadcast(resultIntent); }
75735839_5
public String convertSpecialCharacters(String input) { ing returnInput = input; (null != input && input.contains(":")) { List<String> inputList = getListFromSpaceSeparatedTerms(input); for (String replacement : inputList) { (replacement.contains(":")) { String start = replacement.toLowerCase().substring(0, repla...
75753179_0
@ConditionalOnMissingBean @Bean public MapperFactoryBuilder<?, ?> orikaMapperFactoryBuilder() { DefaultMapperFactory.Builder orikaMapperFactoryBuilder = new DefaultMapperFactory.Builder(); if (orikaProperties.getUseBuiltinConverters() != null) { orikaMapperFactoryBuilder.useBuiltinConverters(orikaProper...
75844570_0
public static Object eval(String script, Map<String, Object> params) { try { if (params != null) { ScriptContext context = null; context = new SimpleScriptContext(); for (Map.Entry<String, Object> entry : params.entrySet()) { context.setAttribute(entry.getKey(), entry.getValue(), ScriptContext.ENGINE_S...
75856578_113
public void handle(HttpServletRequest request, PagSeguroNotificationHandler handle) { LOGGER.info("Iniciando handler de notificacoes"); if (request.getParameter("notificationCode").isEmpty() || request.getParameter("notificationType").isEmpty()) { throw new PagSeguroLibException(new IllegalArgumentExcepti...
75873961_0
public static <T> T cloneObject(T source) { T cloned = null; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream ous = new ObjectOutputStream(baos); ous.writeObject(source); ous.close(); ByteArrayInputStream bais = new ByteArrayInputStream(...
75879612_1
public void merge() { mergeByCategory(); }
75893370_48
public synchronized void initScriptsFramework(String framework) { Message msg = mJSHandler.obtainMessage(); msg.obj = framework; msg.what = WXJSBridgeMsgType.INIT_FRAMEWORK; msg.setTarget(mJSHandler); msg.sendToTarget(); }
75920378_12
@Override public BigDecimal convert(Currency from, Currency to, BigDecimal amount) { Assert.notNull(amount); Map<Currency, BigDecimal> rates = getCurrentRates(); BigDecimal ratio = rates.get(to).divide(rates.get(from), 4, RoundingMode.HALF_UP); return amount.multiply(ratio); }
75939912_4
public static List<String> configurationNames() { return configurationNames(System.getenv().keySet()); }
75974381_3
public static boolean methodAnnotatedWithRxLogSingle(ProceedingJoinPoint joinPoint) { return ((MethodSignature) joinPoint.getSignature()).getReturnType() == Single.class; }
75985902_3
public static Hasher createHasher(String hasherType) { Hasher hasher; switch (hasherType) { case "MD5": hasher = new MD5Hasher(); break; case "SHA1": hasher = new SHA1Hasher(); break; case "SHA256": hasher = new SHA256Hasher(); ...
75990052_9
public static boolean isInternalErrorURL(final String url) { return "data:text/html;charset=utf-8;base64,".equals(url); }
76003412_48
@Override public ValueEvaluation evaluate() { try { checkContractCompliance(); boolean errorIfDirNull = true; List<ValueParam> paramErrorIfDirNull = valueParams.getParams(PARAM_ERROR_IF_DIR_NULL); if (!paramErrorIfDirNull.isEmpty()) { errorIfDirNull = (boolean) paramErro...
76028699_0
@Override public String getVersion() { return version; }
76093141_6
public String tradePrecreate(long seckillId) { Seckill seckill = redisService.getSeckill(seckillId); Goods goods = goodsMapper.selectById(seckill.getGoodsId()); // 需保证商户系统端不能重复,建议通过数据库sequence生成, String outTradeNo = "tradeprecreate" + System.currentTimeMillis() + (long) (Math.random() * 1000...
76099157_7
public String replace(final String source) { if (source == null) { return null; } final StringBuilder builder = new StringBuilder(source); if (substitute(builder, 0, source.length(), null) <= 0) { return source; } return replace(builder.toString()); }
76112580_1
@GetMapping("/status") @ResponseStatus(HttpStatus.CREATED) public Mono<String> status() { return Mono.just("Status"); }
76160515_0
public static <A> Option<A> of(A value) { return value == null ? Option.none() : new Option<>(value); }
76169459_0
public SaveOperation<T> save(final @NonNull T... objectsToInsert) { final SQLiteDAO generated = getGeneratedDAO(null); final SQLiteDAO<T>[] generatedObjects = new SQLiteDAO[objectsToInsert.length]; for (int i = 0; i < objectsToInsert.length; i++) { generatedObjects[i] = getGeneratedDAO(objectsToInse...
76177416_22
@Override public Duration convert(String source) { try { if (ISO8601.matcher(source).matches()) { return Duration.parse(source); } Matcher matcher = SIMPLE.matcher(source); Assert.state(matcher.matches(), "'" + source + "' is not a valid duration"); long amount = ...
76198055_1
public void loadContributors(String owner, String repo, boolean pullToRefresh) { if (isViewAttached()) { getView().showProgress(pullToRefresh); } subscription = appRepository.contributors(owner, repo).subscribe(new Subscriber<List<Contributor>>() { @Override public v...
76209402_8
public long toLong() { long longRepresentation = this.wallTime; longRepresentation = longRepresentation << 16; //longRepresentation = (longRepresentation & 0xFFFFFFFFFFFF0000L); longRepresentation = (longRepresentation | (long)this.logical); return longRepresentation; }
76267363_172
@Override public void afterPropertiesSet() throws Exception { if (executor instanceof InitializingBean) { InitializingBean bean = (InitializingBean) executor; bean.afterPropertiesSet(); } }
76278501_46
public static Pair<Integer, String> shippingSummary(final @NonNull Reward reward) { final String shippingType = reward.shippingType(); if (!RewardUtils.isShippable(reward) || shippingType == null) { return null; } switch (shippingType) { case Reward.SHIPPING_TYPE_ANYWHERE: return Pair.create(R.s...
76279202_0
public static byte[] readDEROctetString(byte[] input) throws SerializationException { return readDEROctetString(new ByteArrayInputStream(input)); }
76284858_0
@Override public synchronized void init(final ProcessingEnvironment processingEnv) { super.init(processingEnv); versionCode = processingEnv.getOptions().get(OPTION_VERSION_CODE); versionName = processingEnv.getOptions().get(OPTION_VERSION_NAME); messager = processingEnv.getMessager(); }
76307760_18
@VisibleForTesting static boolean isAnagram(String first, String second) { // // Your code here // return true; }
76332085_0
public static GtidSourceOffset parse(String offset) { // offset can be either json object or simple gtid-set if (offset.trim().startsWith("{")) { try { return mapper.readValue(offset, GtidSourceOffset.class); } catch (IOException e) { throw Throwables.propagate(e); } } else { // simple...
76341709_2
public final static long convert2Long(Object value, long defaultValue) { if (value == null || "".equals(value.toString().trim())) { return defaultValue; } try { return Long.valueOf(value.toString()); } catch (Exception e) { try { return Double.valueOf(value.toString(...
76346666_34
@Override public Relationship buildRelation(Node parent, Node child, DocumentRelationContext context) { String documentKey = context.getDocumentKey(); if(StringUtils.isBlank(documentKey)) { return null; } RelationshipType relationType = RelationshipType.withName( documentKey ); //check if already exists It...
76375829_76
public void setAngleRange(double minAngle, double maxAngle) throws IOException { if (minAngle >= maxAngle) { throw new IllegalArgumentException("minAngle must be less than maxAngle"); } mMinAngle = minAngle; mMaxAngle = maxAngle; // clamp mAngle to new range if (mAngle < mMinAngle) { ...
76393276_0
@GetMapping(path = "/accounts/{id}") public ResponseEntity getAccount(@PathVariable Long id) { return Optional.ofNullable(getAccountResource(id)) .map(e -> new ResponseEntity<>(e, HttpStatus.OK)) .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND)); }
76405311_76
@Override public boolean test(RecordedHttpRequest incomingRequest, RecordedHttpRequest expectedRequest) { String charSet1 = incomingRequest.getCharset(); String charSet2 = expectedRequest.getCharset(); RecordedHttpBody incomingBody = incomingRequest.getHttpBody(); if (incomingBody == null) { incomingBody = ...
76431952_1
public static <T, K> Observable<GroupedObservable<K, T>> create(Observable<T> upstream, Function<? super T, ? extends K> keySelector) { return new WindowIfChangedObservable<>(upstream, keySelector); }
76436183_1
public static LindenSchema build(File schemaFile) throws Exception { Preconditions.checkNotNull(schemaFile); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document dom = db.parse(schemaFile); dom.getDocumentElement().normalize(); NodeList...
76474200_71
public static Option<Path> getTablePath(FileSystem fs, Path path) throws HoodieException, IOException { LOG.info("Getting table path from path : " + path); FileStatus fileStatus = fs.getFileStatus(path); Path directory = fileStatus.isFile() ? fileStatus.getPath().getParent() : fileStatus.getPath(); if (TableP...
76488267_34
public static List<Track> mergeTracks(final List<Track> tracks) { final List<TrackSegment> segments = tracks.stream() .flatMap(Track::segments) .collect(toUnmodifiableList()); return tracks.isEmpty() ? List.of() : List.of( tracks.get(0).toBuilder() .segments(segments) .build() ); }
76563439_0
;
76588998_285
public UserAuthorizationData getUserAuthData(String sessionToken, String integrationId, Long userId, String url) throws RemoteApiException { checkAuthToken(sessionToken); checkParam(integrationId, INTEGRATION_ID); checkParam(userId, USER_ID); checkParam(url, URL); String path = "/v1/configuration/" + ap...
76591624_9
public final int getCode() { return code; }
76600904_140
@POST @Path("/login") public Response login(@HeaderParam("Authorization") String authHeader) { if (StringUtils.isBlank(authHeader)) { return Response.status(Response.Status.UNAUTHORIZED).build(); } Optional<Pair<String, String>> auth = processAuthHeader(authHeader); if (!auth.isPresent()) { ...
76604873_18
@Override @Nullable public String getString(@NonNull final String key, @Nullable final String defValue) { return preferences.getString(key, defValue); }
76634121_13
public CompositeReadableBuffer append(byte[] array) { validateAppendable(); if (array == null || array.length == 0) { throw new IllegalArgumentException("Array must not be empty or null"); } if (currentArray == null) { currentArray = array; currentOffset = 0; } else if (con...
76641987_0
public static String getLocalIp() { try { return InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException e) { e.printStackTrace(); } return null; }
76667858_0
public EntityResult<V> get(K id) throws RestDslException { return serviceDao.get(ServiceQuery.byId(id)); }
76684353_23
@Override public void startUpdate(@NonNull final ViewGroup container) { if (container.getId() == View.NO_ID) throw new IllegalStateException( "ViewPager with adapter " + this + " requires a view id!" ); }
76684377_50
@Override public void registerOnDataSetSwapListener(@NonNull final OnDataSetSwapListener<List<I>> listener) { if (listeners == null) { this.listeners = new SwappableDataSetAdapterListeners<>(); } this.listeners.registerOnDataSetSwapListener(listener); }
76684492_7
@NonNull public Typeface getTypeface(@NonNull final Context context) { if (typeFace == null) { try { this.typeFace = Typeface.createFromAsset(context.getAssets(), filePath); } catch (Exception e) { throw new IllegalArgumentException( "Cannot create Typeface for font at path(" + filePath + "). " + ...
76684614_12
public boolean restoreHolder(@NonNull final RecyclerView.ViewHolder viewHolder, @Direction final int direction) { return restoreHolder(viewHolder, direction, null); }
76877282_1
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) { List<Map.Entry<K, V>> list = new ArrayList<>(map.entrySet()); List<Map.Entry<K, V>> sorted = Stream.of(list).sortBy(Map.Entry::getValue).toList(); Map<K, V> result = new LinkedHashMap<>(); for (Map.Entry<K, V> en...
77005273_1
public void shutdown() { LOG.debug("Shutting down RpcServer and MembershipService"); rpcServer.shutdown(); membershipService.shutdown(); sharedResources.shutdown(); this.hasShutdown = true; }
77008449_0
@Override public Result execute() { FormattingResultLog resultLog = new FormattingResultLog(); if(agentManager.getAgents().isEmpty()) { resultLog.info("No agents configured"); } for (Map.Entry<String, Agent> entry : agentManager.getAgents().entrySet()) { Agent agent = entry.getValue();...
77030088_45
public static <T> T parse(ByteBuffer encoded, Class<T> containerClass) throws Asn1DecodingException { BerDataValue containerDataValue; try { containerDataValue = new ByteBufferBerDataValueReader(encoded).readDataValue(); } catch (BerDataValueFormatException e) { throw new Asn1Decodin...
77066767_41
protected String createMessage(int nrAnalyzedBuilds, int nrRepairAttempts, int nrOfBuildsWithPatches, int[] nrOfPatchesPerTool, Date now) { String message = "Summary email from Repairnator. \n\n"; message += "This summary contains the operations of Repairnator between " + this.lastNotificationTime....
77143465_33
@Override public void processSubTypeRule(TypeSpec.Builder typeSpec, TypeModel typeModel) { SubTypeModel subTypeModel = typeModel.getSubTypes(); AnnotationSpec.Builder typeInfoAnnotation = AnnotationSpec.builder(JsonTypeInfo.class) .addMember("use", "$L", "JsonTypeInfo.Id.NAME") .addMemb...
77145569_121
@Override public List<String> getProtectionPath(final String claimName) throws ODataJPAModelException { return new ArrayList<>(0); }
77168103_6
public static <E> CompletableSource resolveScopeFromLifecycle( final LifecycleScopeProvider<E> provider) throws OutsideScopeException { return resolveScopeFromLifecycle(provider, true); }
77196845_3
public static long parseDate(byte[] data) { return parseDate(data, 0, data.length); }
77316924_0
public void popAlways(String channel, PopHandler handler) { PopTask task = new PopTask(this, channel, handler); taskList.add(task); popExecutor.submit(task); }
77317748_8
@Nullable public static String wrapWords(String line, String newLine, int watermark, boolean wrapLongWords) { if (line == null) { return null; } else { if (newLine == null) { newLine = System.lineSeparator(); } if (watermark < 1) { watermark = 1; ...
77321473_0
void update(double delta) { if (!enabled || itemLevel == 0) return; tickTimer += delta; while (tickTimer >= actualTickRate) { tickTimer -= actualTickRate; generator.process(); } }
77385607_83
public void deleteElements() { try { if (g == null) { return; } LOGGER.info("deleting elements"); // note that this will succeed whether or not pluto exists g.V().has("name", "pluto").drop().iterate(); if (supportsTransactions) { g.tx().commit(...
77403831_1
public int readByte() { if (device == null) return 0; byte[] buffer = new byte[]{0}; try { device.read(buffer, 1); } catch (IOException e) { // ignore } return buffer[0]; }
77405221_59
public static Matcher<JsonNode> jsonNull() { return INSTANCE; }
77435673_0
public void load() throws IOException { if (cleanDatabaseOnLoad) { doCreateEmptyDatabase(); } statValueCache.clear(); statValueEmpty.clear(); final StatArchiveReader reader = new StatArchiveReader(new File[] { archiveFileName }, statFilters, false); for (Object r : reader.getResourceInstList()) { fina...
77455386_0
public UserInfo login(Long userId, String userPassword) throws Exception { try { UserInfo userInfo = new UserInfo(); userInfo.setUserId(userId); //对密码进行md5解密 userPassword = MD5.getMD5Str(userPassword); UserInfo userInfo1 = userInfoDAO.get(userInfo); if (userInfo1 != n...
77481567_34
@Override public void newData(final C candleStick) { strategy.update(candleStick); switch (currentState) { case TRY_CREATE: currentOrder = creator.checkMarketEntry(this); if (currentOrder.isPresent()) { currentState = State.MANAGE_ORDER; } ...
77492072_172
public Link filterLinkParams(final Link link) { return filterLinkParams(link, !includeMementoDates); }
77496717_3
static Map<LocalDate, String> generate_multi(LocalDate start_date, LocalDate end_date, String seed) { if (start_date.isAfter(end_date)) { throw new IllegalArgumentException(); } int days = (int) (1 + ChronoUnit.DAYS.between(start_date, end_date)); // Now let's generate one password for each da...
77541577_2
public void send(JsonObject jsonMessage) { // Return the json, while separating lines with \n logsQueue.enqueue(jsonMessage.toString().getBytes(StandardCharsets.UTF_8)); }
77671214_1
public Example() { this(100); }
77675033_0
protected void configureServices(final T builder) { final Set<String> serviceNames = new LinkedHashSet<>(); // support health check if (this.properties.isHealthServiceEnabled()) { builder.addService(this.healthStatusManager.getHealthService()); serviceNames.add(HealthGrpc.getServiceDescript...
77759012_13
public static String toSlug(String text) { if (null == text) { return null; } Matcher m = pattern.matcher(text); String result = m.replaceAll("-"); if (result.endsWith("-")) { // Remove the last char if it's a dash result = result.substring(0, result.length() - 1); } ...
77796833_7
public boolean matches(Object... arguments) { int length = argumentMatchers.size(); if (length != arguments.length) return false; else for (int i = 0; i < length; i++) { ArgumentMatcher matcher = argumentMatchers.get(i); @SuppressWarnings("unchecked") bool...
77809403_6
public List<Span> consume() throws InterruptedException { List<Span> rc; synchronized (this) { // wait for an available span while (spans == null) { wait(); } rc = spans; spans = null; } return rc; }
77825195_26
@Override public String execute(final OrderProcessModel process) { LOG.debug("Process: " + process.getCode() + " in step " + getClass().getSimpleName()); final OrderModel order = process.getOrder(); if (order.getPaymentInfo().getAdyenPaymentMethod() == null) { LOG.debug("Not Adyen Payment"); ...
77831813_6
@Override public Iterator<MigrationFile> iterator() { return origin.iterator(); }
77838408_49
public final CompletableFuture<List<U>> authenticate(final List<AsyncClient<? extends Credentials, U>> currentClients, final C context, final AsyncProfileManager<U, C> manager) { final Stream<AsyncClient<? extends Credentials, U>> directClientsStream = currentClients.stream() ...
77841232_34
@Override public Map<Path, List<Media>> retrieveFiles() { log.info("Scanning for directories in {}", scanConfig.base_input_dir()); return scannerProvider.get() .searchIn(scanConfig.base_input_dir()) .withRecursion(false) .withDirectories(true) .stream() .filter(this::isPr...
77859095_56
@Override public final T get(final Duration timeout) throws CheckedFutureException { if (ex instanceof RuntimeException) throw (RuntimeException) ex; if (ex instanceof Error) throw (Error) ex; else throw new CheckedFutureException(ex); }
77936449_6
public void createTwo(boolean rollback, String first, String second) { Foo foo = new Foo(first); Foo bar = new Foo(second); em.persist(foo); em.persist(bar); if(rollback) { ctx.setRollbackOnly(); //none should get persisted, as we rollback } }
78016530_0
public <T> T create(String fullName, Class<T> clazz) { IndraFactory<T> factory; if (fullName != null) { String[] parts = fullName.split(IndraFactory.FACTORY_SEPARATOR); String item; if (parts.length > 1) { factory = getFactory(parts[0], clazz); item = fullName.su...
78045492_1
public String getUrl(String baseUrl, HashMap<String, String> params) throws WebViewOverlayException { String finalUrl = null; if (baseUrl instanceof String) { if (params == null || params.isEmpty()) { return baseUrl; } else { finalUrl = baseUrl + "/?"; int ...
78049515_1
public RelationExtractionContent doRelationExtraction(String text, boolean doCoreference, boolean isolateSentences) { final DiscourseSimplificationContent dsc = doDiscourseSimplification(text, doCoreference, isolateSentences); log.debug("doRelationExtraction for text"); final RelationExtractionCon...
78055963_4
@Override public byte[] toBytes() { byte[] feeBytes = fee.toBytes(); byte[] payerBytes = payer.toBytes(); List<Byte> requiredAuthsSerialized = new LinkedList<>(); if (this.requiredAuths != null) { for (UserAccount userAccount : this.requiredAuths) { requiredAuthsSerialized.addAll(Byt...
78070391_0
public Double getValorLiquido() { return valorLiquido; }
78089297_36
@Override public void init(Map<String, String> args) { super.init(args); this.conf = getContext().getConf(); this.srcPath = args.get(FILE_PATH); this.ecPolicyName = REPLICATION_POLICY_NAME; if (args.containsKey(EC_TMP)) { this.ecTmpPath = args.get(EC_TMP); } if (args.containsKey(BUF_SIZE) && !args.get...
78162952_7
public static OptionalInt of(int value) { return new OptionalInt(true, value); }
78224452_1
@Override public void attachView(View view) { super.attachView(view); if (messages.size() == 0) { oldMessagesDisposable = chatService.getMessages() .repeatWhen(o -> o.concatMap(v -> Observable.interval(3, TimeUnit.SECONDS))) .observeOn(AndroidSchedulers.mainThread()) ...
78267831_15
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Cell other = (Cell) obj; if (x != other.x) return false; if (y != other.y) return false; return true; }
78291176_7
public static TargetRange from(@IntRange(from = 0) int start, @IntRange(from = 0) int end) { if (end < start) { throw new IllegalArgumentException("The end of the range shouldn't be before the start"); } return new TargetRange(start, end); }
78306233_0
@NonNull public List<AutoModFlag> parseFlags(@NonNull String rawFlags) { final String[] splitFlags = rawFlags.split(","); final List<AutoModFlag> flags = new ArrayList<>(splitFlags.length); for (String rawFlag : splitFlags) { String[] parts = rawFlag.split(":", -1); if (parts.length != 2) ...
78359015_9
public ValiFieldText addMinLengthValidator(int minLength) { return addMinLengthValidator(getErrorRes(ValiFi.Builder.ERROR_RES_LENGTH_MIN), minLength); }
78391996_50
public void read(long pos, Buffer sink, long byteCount) throws IOException { if (byteCount < 0) { throw new IndexOutOfBoundsException(); } while (byteCount > 0L) { try { // Read up to byteCount bytes. byteBuffer.limit((int) Math.min(BUFFER_SIZE, byteCount)); ...
78418280_0
public List<Book> generate(int howMany) { List<Book> books = new ArrayList<>(); for (int i = 0; i < howMany; i++) { books.add(randomBook()); } return books; }
78420352_45
@ReactMethod public void removeSubviewsFromContainerWithID(int containerTag) { mUIImplementation.removeSubviewsFromContainerWithID(containerTag); }
78444970_22
public static <N> UndirectedGraph<N> compute(final UndirectedGraph<N> graph, final ToIntFunction<UndirectedGraph.Edge<N>> weighter) { final MutableUndirectedGraph<N> result = new MutableUndirectedGraph<>(); if (!graph.nodes().isEmpty()) { // chose arbitrary node to start with result.addNode(gr...
78556475_1
public final void loadAndSave() { try { load(); save(); } catch (ConfigurationStoreException e) { if (e.getCause() instanceof NoSuchFileException) { postLoad(); save(); } else { throw e; } } }
78566008_3
public static <T> Result<T> error(Throwable error) { if (error == null) { throw new NullPointerException("mError == null"); } return new Result<>(null, error); }