id stringlengths 7 14 | text stringlengths 1 37.2k |
|---|---|
163179422_1 | public static Identifier withPath(Identifier base, String path) {
return transformer(base).path(path).apply();
} |
163191196_0 | public static String sign(String secret, String method, String path,
Map<String, String> headers,
Map<String, String> querys,
Map<String, String> bodys,
List<String> signHeaderPrefixList) {
try {
Mac hmac... |
163244687_111 | public static boolean compareAndIncreaseOnly(final AtomicLong target, final long value) {
long prev = target.get();
while (value > prev) {
boolean updated = target.compareAndSet(prev, value);
if (updated)
return true;
prev = target.get();
}
return false;
} |
163387337_170 | @Override
public Map<Integer,ArrayList<Object>> getParameters() {
return parameters;
} |
163399836_3 | public static HBaseClient getInstance() {
if (instance == null) {
synchronized (HBaseClient.class) {
if (instance == null) {
instance = new HBaseClient();
}
}
}
return instance;
} |
163468664_0 | public int minus(long goodsId, int delta) {
if (goodsId < 1) {
log.error("goodsId<1");
return 0;
}
final String queryVersionSql = "SELECT stock, version from " + TABLE_NAME + " WHERE id=?";
Map<String, Object> map = jdbcTemplate.queryForMap(queryVersionSql, new Object[]{goodsId}
... |
163474295_49 | @ApiOperation(value = "根据标签id查询文章", notes = "根据标签id查询文章")
@GetMapping("/tag/{tagId}")
public JsonData<Page<ArticleDto>> findArticleByTagId(@PathVariable String tagId,
@PageableDefault(sort = "create_at", direction = DESC) Pageable pageable) {
Page<ArticleDto> result... |
163514144_9 | @Nullable
public static ArgType replaceClassGenerics(RootNode root, ArgType instanceType, ArgType typeWithGeneric) {
if (typeWithGeneric == null) {
return null;
}
if (instanceType.isGeneric()) {
List<GenericInfo> generics = root.getClassGenerics(instanceType);
if (generics.isEmpty()) {
return null;
}
Ar... |
163566292_1 | @Nullable
public SwaggerV2Documentation get(String serviceName) {
return storage.get(serviceName);
} |
163648692_206 | @PreAuthorize("hasAuthority('VIEW_CLIENT_ACL_SUBJECTS')")
public List<AccessRightHolderDto> findAccessRightHolders(ClientId clientId, String memberNameOrGroupDescription,
XRoadObjectType subjectType, String instance, String memberClass, String memberGroupCode,
String subsystemCode) throws ClientNotFound... |
163652398_6 | @Override
public boolean isPrimarySwitch(GroupAddress ga) {
// pre-select based on super
boolean isPotentialPrimary = super.isPrimarySwitch(ga);
if (!isPotentialPrimary) {
LOG.debug("Not a primary switch GA due to DPT mismatch: {}", ga);
return false;
}
// filter out addresses with similar name but not primar... |
163711177_0 | public static String format(String format, Object... arguments) {
return MessageFormatter.arrayFormat(format, arguments).getMessage();
} |
163795687_31 | @Override
public long getSequenceNumber() throws Exception {
return redisService.increaseAndGet(key("/sequence"), 1);
} |
163808152_100 | @Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
// 如果是 fetch 请求,则不做任何处理
if(RequestUtil.isFetch(httpServletRequest)) {
chain.doFilter(request, response)... |
163840922_7 | @Override
public String getEncodedTppQwacCert(HttpServletRequest httpRequest) {
if (httpRequest.getHeader(HEADER_NAME) == null) {
return null;
}
String certificateWithTabs = httpRequest.getHeader(HEADER_NAME);
return certificateWithTabs.replaceAll("\t", "");
} |
164034455_1 | public static boolean getTrueWithProbability(double probability) {
probability *= 100;
int randomProbability = ThreadLocalRandom.current().nextInt(0, 100);
return probability > randomProbability;
} |
164049286_4 | @Override
public boolean insertGroup(Group group) {
group.setCreateTime(new Date());
group.setModifiedTime(new Date());
return groupDao.insertGroup(group);
} |
164079951_0 | @GetMapping("/departments")
public List<Department> departments() {
return this.departmentDao.findAll();
} |
164091262_177 | public QueryProcedure createQueryProcedure(String sql) {
RelNode originalLogicalPlan = buildLogicalPlan(sql);
RelNode optimizedPlan = optimizeLogicalPlan(originalLogicalPlan);
TreeNode treeNode = optimizedPlan.accept(new LogicalViewShuttle());
SubtreeSyncopator subtreeSyncopator = new SubtreeSyncopator... |
164098851_3 | @ApiOperation(value = "Retrieve all todos for a user by passing in his name", notes = "A list of matching todos is returned. Currently pagination is not supported.", response = Todo.class, responseContainer = "List", produces = "application/json")
@GetMapping("/users/{name}/todos")
public List<Todo> retrieveTodos(@Path... |
164113249_6 | @Override
protected void doFilterInternal(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse,
FilterChain filterChain
) throws ServletException, IOException {
String header = httpServletRequest.getHeader(tokenProperties.getH... |
164181730_0 | public IMessage pullMessage(IPipe pipe) throws IOException {
// there is no need for sync here, the readers use semaphore locks
if (this.pipe == pipe) {
if (reader == null) {
init();
}
if (reader.hasMoreTags()) {
IRTMPEvent msg = null;
ITag tag = reade... |
164305542_22 | public static String convert(ProtoDomain pd, String messageName)
throws IOException, StatusRuntimeException {
Descriptors.Descriptor descriptor = pd.getDescriptorByName(messageName);
if (descriptor == null) {
throw Status.fromCode(Status.Code.NOT_FOUND)
.withDescription(String.format("The contract :... |
164404731_7 | public <T> T call(final Callable<T> callable) throws Exception {
return call(null, callable);
} |
164421483_0 | public SwitcherService getSwitcherService() {
return this.switcherService;
} |
164497122_3 | public Geometry build(Relation entity) {
// Check whether the relation is a multipolygon
Map<String, String> tags = entity.getTags();
if (!"multipolygon".equals(tags.get("type"))) {
return null;
}
// Collect the members of the relation
List<LineString> members = entity.getMembers()
.stream()
... |
164546163_13 | @Override
protected Spliterator<T> spliterator() {
if (iterationStarted) {
throw new IllegalStateException("ScanReadResult can only be iterated once.");
}
iterationStarted = true;
return new ScanReadResultSpliterator();
} |
164875108_24 | public TracingProvider(Tracer tracer) {
this.tracer = tracer;
} |
164962081_1 | public int getStatusCode() {
return statusCode;
} |
164972617_10 | public synchronized boolean tryWriteLock() {
if (!isFree()) {
return false;
} else {
status = -1;
return true;
}
} |
165007814_10 | @Override
public Page download(Request request, Task task) {
if (task == null || task.getSite() == null) {
throw new NullPointerException("task or site can not be null");
}
CloseableHttpResponse httpResponse = null;
CloseableHttpClient httpClient = getHttpClient(task.getSite());
Proxy proxy ... |
165026546_174 | DiagnosisSet convertDiagnosisSet(int[] diagnosisSet) {
final List<DiagnosisElement> elements = Arrays.stream(diagnosisSet)
.mapToObj(this::convertDiagnosisElement)
.collect(Collectors.toList());
return new DiagnosisSet(elements);
} |
165063056_1 | public Handler<RoutingContext> createPost(String serviceName) {
return routingContext -> {
try {
FileFormat fileFormat;
String diagramSource;
MIMEHeader contentType = routingContext.parsedHeaders().contentType();
if (contentType != null && contentType.value() != null && contentType.value()... |
165246320_82 | @Override
@GetMapping(value = "/list")
public ResponseEntity<List<MetaProjectListVO>> list(@Valid MetaProjectQO metaProjectQO) {
List<MetaProjectListVO> list = metaProjectService.list(metaProjectQO);
return ResponseEntity.ok(list);
} |
165292138_11 | @GET
@Path("/{projectName}/{exploratoryName}/{computationalName}")
@Produces(MediaType.APPLICATION_JSON)
public Response fetchSchedulerJobForComputationalResource(@Auth UserInfo userInfo,
@PathParam("exploratoryName") String exploratoryName,
@PathParam("projectName") String projectName,
... |
165543540_0 | @Transactional
public void calculateBonus(Bonus bonus) {
if (bonusRepository.existsById(bonus.getId())) {
log.info("Bonus id {} already exists - ignored", bonus.getId());
} else {
bonusRepository.save(bonus);
}
} |
165549674_5 | @Override
public byte[] getValue() {
return myValue;
} |
165671355_2 | public static double calculateHeadingToPoint(double currentHeading, int currentX, int currentY, int targetX,
int targetY) {
// throw new RuntimeException("implement me!");
if(currentX == targetX && currentY == targetY)
return 0.0;
double degreess = Math.atan2(targetY - currentY, targetX - currentX) / Math.PI * 1... |
165674292_59 | @JSMethod(uiThread = true)
public void clearNavBarMoreItem(String param, JSCallback callback) {
if (WXSDKEngine.getActivityNavBarSetter() != null) {
if (WXSDKEngine.getActivityNavBarSetter().clearNavBarMoreItem(param)) {
if (callback != null) {
callback.invoke(MSG_SUCCESS);
... |
165758293_75 | public org.apache.hadoop.hive.metastore.api.Partition getPartition(String dbName, String tblName, String partitionName)
throws TException {
checkArgument(StringUtils.isNotEmpty(dbName), "dbName cannot be null or empty");
checkArgument(StringUtils.isNotEmpty(tblName), "tblName cannot be null or empty");
checkA... |
165787430_1 | public static ArrayList<Integer> fizzBuzzBazz(){
ArrayList<Integer> fizz = new ArrayList<Integer>();
int loopNumber;
System.out.println("Enter a whole number:");
//Create buffered reader in try catch so buffered reader auto closes.
try(BufferedReader reader = new BufferedReader(new InputStreamReader... |
165861304_3 | public static List<SocialMessage> translate(List<Status> statuses) {
if (statuses == null) {
return null;
}
List<SocialMessage> socialMessages = statuses.stream().map(status -> {
SocialMessage message = new SocialMessage(status.getText());
message.setId(status.getId());
message.setNumOfLikes(stat... |
165869297_0 | @Override
public PhoneticWordDist getPhonetic(String word1, String word2) {
// return the distance
PhoneticWordDist phoneticWordDist = new PhoneticWordDist(word1, word2, null,null,-1) ;
try {
String phoneticWord1 = executeJavaStript(word1).toString();
String phoneticWord2 = executeJavaStript(word2).toString();
... |
165964380_1 | @Override
public <T> void setMember(Object scope, String member, T val)
{
JSObject jsObj = ((DomjnateJSObjectAccess)scope).__DomjnateGetJSObjectFromProxy();
jsObj.setMember(member, DomjnateFx.unwrapObject(val, this));
} |
165997095_1 | public static ElasticsearchEvolutionConfig configure() {
return new ElasticsearchEvolutionConfig();
} |
166023376_12 | public Method getSetterMethodForField(final Class<?> fieldClass, final String fieldName, final Class<?> fieldType) {
final String cacheKey = "SetterMethod-" + fieldClass.getName() + '-' + fieldName;
return CACHE_MANAGER.getFromCache(cacheKey, Method.class).orElseGet(() -> {
try {
Method meth... |
166116543_0 | @Override
public Optional<String> getSubFromToken(String token) {
try {
Jws<Claims> claimsJws = Jwts.parser().setSigningKey(secret).parseClaimsJws(token);
return Optional.ofNullable(claimsJws.getBody().getSubject());
} catch (Exception e) {
return Optional.empty();
}
} |
166249209_1 | public Optional<Double> getGlobalAverageForLine(int line) {
List<LineExecution> filteredHistory = getLatestVersionAttributeForLine(line, new ArrayList<>(), l -> l.getPerformance().getRequestProfileHistory(), p -> p.getProfileStartTimestamp());
OptionalDouble average = filteredHistory.stream().mapToLong(f -> f.g... |
166365902_11 | public static Float getFloat(Map param, String key) {
if (param == null || isEmpty(key)) {
return null;
}
Object v = param.get(key);
if (v == null) {
return null;
}
return parseFloat(v.toString());
} |
166387176_29 | public static <E> List<E> quotientList( final List<E> list, final int n, final int k ) {
if ( n <= 0 || k < 0 || k >= n ) {
throw new IllegalArgumentException( "n must be positive; k must be between 0 and n - 1" );
}
final int size = (list.size() + n - k - 1) / n;
return new AbstractList<E>() {
... |
166396744_4 | public static byte[] encrypt(byte[] decrypted, SecretKeySpec aes) throws InvalidKeyException, IllegalArgumentException {
final ByteBuffer output = ByteBuffer.allocate(NONCE_SIZE + decrypted.length + OVERHEAD);
final Cipher cipher;
try {
cipher = Cipher.getInstance(CIPHER);
} catch (NoSuchAlgorit... |
166411274_1 | @Override
public void watchEvent(String eventId, EventCallback callback) {
try {
final String path = "/proxy/events";
final String eventpath = "/proxy/events/" + eventId;
LOG.info("watching " + path);
PathChildrenCache cache = new PathChildrenCache(client, path, true);
// ho... |
166515022_733 | @VisibleForTesting
public static BigDecimal average(LongDecimalWithOverflowAndLongState state, DecimalType type)
{
BigDecimal sum = new BigDecimal(Decimals.decodeUnscaledValue(state.getLongDecimal()), type.getScale());
BigDecimal count = BigDecimal.valueOf(state.getLong());
if (state.getOverflow() != 0) {
... |
166629127_1 | public static int calculatePolygonSidesFromAngle(double angle) {
throw new RuntimeException("implement me!");
} |
166637026_9 | public synchronized void append(final Event event)
throws IOException, InterruptedException {
checkAndThrowInterruptedException();
// If idleFuture is not null, cancel it before we move forward to avoid a
// close call in the middle of the append.
if (idleFuture != null) {
idleFuture.cancel(false);
... |
166837677_2 | @OnClose
public void onClose() {
logger.info("webSocket: /webSocket/demo on Close");
} |
166956579_6 | public final boolean match(MediaType contentType) {
boolean match = getMediaType().includes(contentType);
return (!isNegated() ? match : !match);
} |
167107390_1 | public String render(String html) {
return render(html, new HashMap<>(0));
} |
167128801_2 | @Scheduled(cron = "0 0 17,18,19 ? * MON-FRI")
public void runUpdateOfDailyIndex() {
boolean isHoliday = holidayCalendarService.isHoliday(new Date());
if (isHoliday) {
return;
}
try {
List<ExecuteInfo> list = taskService.getPendingTaskListById(Task.UpdateOfDailyIndex.getId());
exe... |
167216638_260 | @Override
public DataFetcher<OAuth2ApplicationScopeAliases> createOAuth2ApplicationScopeAliasesDataFetcher() {
return environment -> {
long companyId = util.getLongArg(environment, "companyId");
long userId = util.getLongArg(environment, "userId", util.getDefaultUserId());
String userName = ... |
167261547_272 | public Set<Principal> getDeniedReaders() {
return getClonedCopy(deniedReaders, ImmutableSet.toImmutableSet());
} |
167412136_28 | public void fetchNews() {
disposable.add(apiClient.fetchNews()
.doOnEvent((newsList, throwable) -> onLoading())
.compose(rxSingleSchedulers.applySchedulers())
.subscribe(this::onSuccess,
this::onError));
} |
167418760_4 | @Override
public String getKeyString(String keyId) {
if (keyId.startsWith("/SmartThings")) {
if (localPublicKeyStr == null) {
throw new IllegalStateException("Public key file not set up"
+ " properly. Please see README (Configure Public Key) for"
+ " directions an... |
167431476_86 | @Subscribe
public void onChatMessage(ChatMessage chatMessage)
{
if (chatMessage.getType() != ChatMessageType.SERVER && chatMessage.getType() != ChatMessageType.FILTERED)
{
return;
}
String message = chatMessage.getMessage();
Matcher matcher = KILLCOUNT_PATTERN.matcher(message);
if (matcher.find())
{
String ... |
167468844_0 | public static List<URL> getResources(String name) throws IOException {
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
return Collections.list(classLoader.getResources(name));
} |
167492840_26 | public static String getIssuerName(String cellName, String namespace) {
if (StringUtils.isEmpty(namespace)) {
namespace = Constants.DEFAULT_NAMESPACE;
}
if (cellName.equals(Constants.COMPOSITE_CELL_NAME)) {
return new StringBuilder(cellName).append(Constants.STS_SERVICE).append(".")
... |
167560273_3 | boolean isNewYearEve(LocalDate date) {
return date.getDayOfMonth() == 31 && date.getMonthValue() == 12;
} |
167594750_0 | public boolean send(String recipient, String doi){
String sender = "Geodisy.Info@ubc.ca";
String host = "localhost";
String subject = "Please update you dataset if you want map-based searching for it";
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
String msgBody =... |
167634307_0 | @Transactional
public Person createPerson(String name) {
if (name == null || name.trim().length() == 0) {
throw new IllegalArgumentException("Person name cannot be empty!");
} else if (personRepository.existsById(name)) {
throw new IllegalArgumentException("Person has already been created!");
}
Person person = ... |
167839264_0 | public void sendVerifyEMail(EmailEvent event) {
SimpleMailMessage helper = new SimpleMailMessage();
helper.setFrom("insomnia163@163.com");
helper.setTo(event.getToEmail());
helper.setSubject(event.getSubject());
helper.setText("验证码: " + mEmailService.generateVerifyCode(event.getToEmail()));
mail... |
167954168_7 | public Completable deleteUser() {
return Completable.fromAction(userDao::deleteAll);
} |
168063420_0 | @Override
public boolean accept(CfService service) {
return service.existsByTagIgnoreCase("configuration");
} |
168190985_181 | @Override
protected void handleModelChanged(SubsystemContext<PlaceMonitorSubsystemModel> context, Model model, AlertScratchPad scratchPad) {
Map<String, Date> lowBatteries = context.model().getLowBatteryNotificationSent();
// remove all previous alerts for which we now have no record of a low battery notificatio... |
168419532_1 | public static Properties getLocalProperties(String fileName) {
Properties properties = new Properties();
InputStream inputStream = ServiceHelper.class.getClassLoader().getResourceAsStream(fileName);
try {
properties.load(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
... |
168531964_0 | public int compare(String s1, String s2)
{
int result = strnatcmp0(s1, s2, true);
return(result);
} |
168665843_2 | @PatchMapping("/books/{id}")
Book patch(@RequestBody Map<String, String> update, @PathVariable Long id) {
return repository.findById(id)
.map(x -> {
String author = update.get("author");
if (!StringUtils.isEmpty(author)) {
x.setAuthor(author);
... |
168828077_274 | public ItemValue mapVal(Map<String, String> mapVal) {
this.mapVal = mapVal;
return this;
} |
169045057_4 | public List<Employee> allInFRIR() {
return this.employeeRepository.findAll(EmployeeSpecifications.workInDepartmentFRIR);
} |
169045197_5 | @Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {
if (bean instanceof SimpleRabbitListenerContainerFactory) {
SimpleRabbitListenerContainerFactory factory = (SimpleRabbitListenerContainerFactory) bean;
registerIdempotentInterceptor(factory);
} ... |
169100341_5 | @Override
public Map<Long, CIMServerResVO> loadRouteRelated() {
Map<Long, CIMServerResVO> routes = new HashMap<>(64);
RedisConnection connection = redisTemplate.getConnectionFactory().getConnection();
ScanOptions options = ScanOptions.scanOptions()
.match(ROUTE_PREFIX + "*")
.buil... |
169102492_121 | public void setCompletedStatus(UUID aggregatorID) {
if (this.status != JobStatus.RUNNING) {
throw new JobQueueFailure(jobID, batchID, String.format("Cannot complete. JobStatus: %s", this.status));
}
if (!this.patients.isEmpty() && (this.patientIndex == null || this.getPatients().size() != this.patie... |
169158153_22 | @Override
public void apply(final String[] tags, final long value, final long timestamp) {
super.apply(tags, value, timestamp);
} |
169246391_13 | @Override
public Record nextRecord(final boolean coerceTypes, final boolean dropUnknownFields)
throws IOException, MalformedRecordException {
String protocol = reader.readLine();
return mapInlineProtocol(protocol, coerceTypes, dropUnknownFields);
} |
169292412_2 | public static int getDefaultResolutionIndex(final Context context,
final List<VideoStream> videoStreams) {
String defaultResolution = computeDefaultResolution(context,
R.string.default_resolution_key, R.string.default_resolution_value);
return getDefaultRe... |
169318041_2 | String getStartingMessage() {
StringBuilder sb = new StringBuilder();
String sdnRx = getVersionOf(Node.class).map(v -> "SDN/RX v" + v).orElse("an unknown version of SDN/RX");
String sdC = getVersionOf(AbstractMappingContext.class).map(v -> "Spring Data Commons v" + v)
.orElse("an unknown version of Spring Data C... |
169410903_89 | @Override
public Map<AttributeType, SetVariableValidator> getVariableValidators() {
return variableValidators;
} |
169530455_2 | public TrieResult<T> getLastOnPath(CharSequence key) {
return getLastOnPath(key, 0);
} |
169625797_41 | public Node rewrite(Node root) throws RewriteException, RepositoryException {
logger.debug("Rewriting page's content tree rooted at {}", root.getPath());
/*
* Description of the algorithm:
* - traverse the tree rooted at root's parent in pre-order
* - skip any node that isn't in the original roo... |
169697931_0 | public boolean evaluate(Evaluatable evaluatable, JsonNode node) {
return evaluatable.accept(new LogicEvaluator(new EvaluationContext(parseContext.parse(node), this)));
} |
169709790_3 | @Override
public StreamObserver<RouteNote> routeChat(final StreamObserver<RouteNote> responseObserver) {
logger.info("RouteChat");
return new StreamObserver<RouteNote>() {
@Override
public void onNext(RouteNote note) {
List<RouteNote> notes = getOrCreateNotes(note.getLocation());
... |
169711172_1 | public static QueryLocation fromRadians(double latitude, double longitude) {
QueryLocation queryLocation = new QueryLocation();
queryLocation.latitude = latitude;
queryLocation.longitude = longitude;
queryLocation.checkBounds();
return queryLocation;
} |
169802047_99 | public Template resolveBy(Resolver resolver, DeclaringComponent currentComponent) {
String replaced = content.replace("${this@templateName}", templateNameWithoutBrackets());
Matcher m = pattern.matcher(replaced);
if (!m.find()) return withContent(replaced);
StringBuffer result = new StringBuffer();
... |
169815639_0 | @Override
public void fetchApodData() {
view.hideApod();
view.showProgressBar();
apodInteractor.getApodDataFromRemote(new ApodDetailsInteractor.onDetailsFetched() {
@Override
public void onSuccess(Apod apodFetchedData) {
if(isViewAttached()){
view.hideProg... |
169872920_32 | public final ObservableList<Series<X, Y>> getData() {
return dataProperty().get();
} |
169934394_1 | @Override
public boolean accept(AuditEvent event) {
List<Edit> editList = fileEditMap.get(event.getFileName());
if (CollectionUtils.isEmpty(editList)) {
return false;
}
for (Edit edit : editList) {
if (edit.getBeginB() < event.getLine() && edit.getEndB() >= event.getLine()) {
... |
169959995_13 | public static JogadorBuilder builder() {
return new JogadorBuilder();
} |
170136874_2 | @Override
public String toString() {
return address;
} |
170458565_0 | public static <A extends Annotation> boolean isAnnotationPresent(AnnotatedElement element, Class<A> target) {
return getMergedAnnotation(element, target) != null;
} |
170551715_5 | @Override
public String toString() {
return value;
} |
170565218_0 | public static boolean longEnough(String password) {
return password.length() >= 8;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.