id
stringlengths
7
14
text
stringlengths
1
37.2k
125770258_0
@UiHandler("showButton") void handleShowButtonClick(ClickEvent e) { if (bananaCount != 0) { foodMultipleSelect.getSelectedItems() .forEach(item -> Notify.notify(item.toString())); } else { notify("No banana, no food."); } eventBus.fireEvent(new ChangeViewEvent("showButton")); }
125814700_0
static boolean isJavaLangType(String type){ return JAVA_LANG_TYPE.contains(type); }
125817998_23
@POST @Path("{id}/censor") public Response censorBook(@PathParam("id") String id) { final Books matchingBooks = books.list().filterById(id); if (null == id || matchingBooks.isEmpty() || matchingBooks.first().getStatus() == States.CENSORED) { return Response.status(Response.Status.BAD_REQUEST).entity("Co...
125843963_15
@GET @Context @Path("/questionsold") @Produces(MediaType.APPLICATION_JSON) public RESTQuestions getQuestionsJSON(@Context ServletContext context, @QueryParam("domain") String domain, @QueryParam("type") List<String> questionTypes, @QueryParam("limit") int maxNrOfQuestions) { logger.info("REST Request - Get questions\n...
125942409_0
public void switchStore(Store storeToSwitchTo) { Cart cart = (Cart) session.get("CART"); DeliveryInformation deliveryInformation = (DeliveryInformation) session.get("DELIVERY_INFO"); if (storeToSwitchTo == null) { if (cart != null) { for (Item item : cart.getItems()) { if...
125985734_86
@Override public void customize(WebServerFactory server) { setMimeMappings(server); // When running in an IDE or with ./mvnw spring-boot:run, set location of the static web assets. setLocationForStaticAssets(server); /* * Enable HTTP/2 for Undertow - https://twitter.com/ankinson/status/82925616770...
126002586_21
public static GPKeyInfoTemplate fromBytes(byte[] buf) throws TLVException { ArrayList<GPKeyInfo> infos = new ArrayList<>(); // KIT is a constructed TLV TLVConstructed kitTlv = TLVConstructed.readConstructed(buf).asConstructed(TAG_KEY_INFO_TEMPLATE); // for each child for (TLV kiTlv : kitTlv.getChild...
126022604_1
public static Calendar getCalendarForLocale(Calendar oldCalendar, Locale locale) { if (locale == null) throw new IllegalArgumentException("You must specify the Locate value"); if (oldCalendar == null) return Calendar.getInstance(locale); long currentTimeMillis = oldCalendar.getTimeInMillis...
126131240_3
public static void subscibe(Server server){ //TODO 订阅指定数据,只有数据改变才会触发 }
126149876_50
@Override public String loadScript(CatalystInstanceImpl instance) { while (true) { try { return getDelegateLoader().loadScript(instance); } catch (Exception e) { if (e.getMessage() == null || !e.getMessage().startsWith(RECOVERABLE)) { throw e; } mLoaders.pop(); mRecovere...
126250036_0
@Override public Class<?> getValueType() { return String.class; }
126275473_1175
@Override public Promise<ResourceResponse, ResourceException> createInstance(Context context, CreateRequest request) { String principalName = "unknown"; try { final Subject subject = getSubject(context); principalName = PrincipalRestUtils.getPrincipalNameFromSubject(subject); final JsonR...
126316912_98
public String deProvision(boolean isTokenExpired) { logInfo("Start Deprovisioning"); if (!provisioningLock.tryLock()) { String msg = "Provisioning in progress"; logInfo(msg); return msg; } try { if (notProvisioned()) { logInfo("Finished Deprovisioning : Fail...
126365965_8
public static String hashpw(String password, String salt) throws IllegalArgumentException { BCrypt B; String real_salt; byte passwordb[], saltb[], hashed[]; char minor = (char) 0; int rounds, off = 0; StringBuilder rs = new StringBuilder(); if (salt == null) { throw new IllegalArgum...
126439064_170
public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { checkArgument(b.signum() >= 0, "b must be positive or zero"); checkArgument(numBytes > 0, "numBytes must be positive"); byte[] src = b.toByteArray(); byte[] dest = new byte[numBytes]; boolean isFirstByteOnlyForSign = src[0] == 0; ...
126522483_0
public final void parse(byte[] buf, short off, short len, BERHandler handler) { // initialize state mVars[VAR_BUF_OFF] = off; mVars[VAR_BUF_LEN] = len; mVars[VAR_POSN] = 0; mVars[VAR_DEPTH] = 0; // parse nodes while input lasts parseMultiple(buf, handler, len); }
126590345_3
@NonNull public static Lifebus<ActivityEvent> create(@NonNull Activity activity) { final Application application = activity.getApplication(); if (application == null) { throw new IllegalStateException("Provided activity '" + activity.getClass().getName() + "' " + "has no Application info...
126665656_0
public static void main(String[] args) throws IOException, InterruptedException { CliOptions options = new CliOptions(); CmdLineParser p = new CmdLineParser(options); if (args.length == 0) { System.out.println("Usage: java -jar war-packager-cli.jar -configPath=mywar.yml [-version=1.0-SNAPSHOT] [-tmp...
126705523_2
@Override @ServiceValidation public DTO getDto (final DTO dto){ return dto; }
126711206_181
@Override @SuppressWarnings("squid:S00117") public Signature sign(final byte[] data) { if (!this.getKeyPair().hasPrivateKey()) { throw new CryptoException("cannot sign without private key"); } Hasher hasher32 = Hashes::sha512; Hasher hasher64 = Hashes::sha512; // Hash the private key to improve randomne...
126785618_6
public static boolean areFieldsValid(CoconutView... views) { boolean ret = true; for (CoconutView view : views) { CoconutInput inputView = view.getCoconutView(); if (inputView == null || inputView.isOptional()) { continue; } String input = inputView.getInput(); ...
126825296_298
void fetchAndRunCommands() { ConsumerRecords<CommandId, Command> records = commandStore.getNewCommands(); log.trace("Found {} new writes to command topic", records.count()); for (ConsumerRecord<CommandId, Command> record : records) { CommandId commandId = record.key(); Command command = record.value(); ...
126844782_4
@Override public Optional<ContractEventDetails> getLatestContractEvent( String eventSignature, String contractAddress) { int page = eventStore.isPagingZeroIndexed() ? 0 : 1; final PageRequest pagination = new PageRequest(page, 1, new Sort(Sort.Direction.DESC, "blockNumber")); final Pag...
126886615_2
@Override public boolean areContentsTheSame(MODEL oldModel, MODEL newModel) { return oldModel == newModel; }
126941683_6
private List<String> listFilesWithRegexs(String folderName, boolean all, String[] regexs) { List<String> paths = listFilesHandler(folderName, all); if (regexs == null || regexs.length == 0) { return paths; } List<String> result = new ArrayList<String>(); for (String filePath : paths) { ...
127004420_52
@Override public EvaluationResult evaluate(List<CAS> aCas, DataSplitter aDataSplitter) { // Prepare a map where we store the mapping from labels to numeric label IDs - i.e. // which index in the label vector represents which label Object2IntMap<String> tagsetCollector = new Object2IntOpenHashMap<>(); /...
127047174_1
@GetMapping("/stores-by-metro-area") public Collection<StoreByMetroAreaProjection> listStoresByLocation(@RequestParam String metroArea) { return repository.findAllProjectedByLocation(metroArea); }
127063666_2
public void connect(URI url) throws Exception { connect(url, false); }
127102257_1
public static String sign(byte[] sign, String keyStorePath, String alias, String password) throws Exception { // 获得证书 X509Certificate x509Certificate = (X509Certificate) getCertificate( keyStorePath, alias, password); // 获取私钥 KeyStore ks = getKeyStore(keyStorePath, ...
127160868_1
public Money add(Money money) { BigDecimal total = this.getAmount().add(money.getAmount()); return new Money(total); }
127163887_0
static Point2D thrustVector(final float rotation, final float thurstAcceleration) { return new Point2D.Float(-thurstAcceleration*(float)Math.sin(rotation), thurstAcceleration*(float)Math.cos(rotation)); }
127330859_9
public boolean shouldApplyFeatureWithFlag(long flagId) { final Optional<FlagDTO> flag = featureFlagsRepo.getFlag(flagId); return flag.map(FlagDTO::getPortionIn).map(this::randomWithinPortion) .orElse(false); }
127346527_5
public Resolved<Set<T>> resolve(List<T> props, DefaultProperties defProps) { if (props == null) { return resolvedEmptyProps(); } DefaultProperties defaultProperties = createDefaultProperties(defProps); List<Resolved<T>> allResults = resolveAllProperties(props, defaultProperties); List<String> allErrors =...
127407755_12
@PutMapping("/users/{userId}/projects/{projectId}/changeIsDone") public void archiveActivateProject( @PathVariable Integer projectId, @RequestBody Boolean isDoneToBecome) { projectRepository.archiveOrActivateProjectById(isDoneToBecome, projectId); }
127408313_0
@Override public void add(T value) { _quantileEstimationGK.insert(value); }
127468887_24
@Override public Status read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) { try { Statement stmt; Select.Builder selectBuilder; if (fields == null) { selectBuilder = QueryBuilder.select().all(); } else { selectBuilder = QueryBuilder.select(); ...
127471055_64
@GetMapping("/movie/delete/{id}") public String deleteMovie( @PathVariable("id") final UUID id, @RequestParam(value = "returnUrl", defaultValue = "") final String returnUrl, final RedirectAttributes redirectAttributes, final Authentication authentication, final Model model) { try { fina...
127518477_1
@SuppressWarnings("unchecked") public <I, O> List<O> execute(final I input, final Collection<ExecuteUnit<I, O>> executeUnits, Long timeout, TimeUnit timeUnit) { if (executeUnits.size() == 1) { try { return Lists.newArrayList(executeUnits.iterator().next().execute(in...
127546760_23
public void match(List<Student> students){ // allMatch用于检测是否全部都满足指定的参数行为,如果全部满足则返回true boolean isAdult = students.stream().allMatch(student -> student.getAge() >= 18); System.out.println("allMatch: isAdult " + isAdult); // anyMatch则是检测是否存在一个或多个满足指定的参数行为,如果满足则返回true boolean hasWhu = students.stream(...
127565224_36
@Override public Multiset<K> keys() { return new ArrayListMultiset<>(map.entrySet() .stream() .flatMap(this::toKeys) .collect(Collectors.toList())); }
127577048_6
void backgroundCompaction() throws IOException { checkState(mutex.isHeldByCurrentThread()); compactMemTableInternal(); Compaction compaction; if (manualCompaction != null) { compaction = versions.compactRange(manualCompaction.level, new InternalKey(manualCompaction.begin, MAX_SEQUENCE_NUMBER, VALU...
127623072_6
public static <K, V> TypeLiteral<Map<K, V>> mapOf(Class<? extends K> keyType, Class<? extends V> valueType) { return new TypeLiteral<>(Map.class, keyType, valueType); }
127727728_0
@ReadOperation public List<Object> versions() { if (endpointResult.isEmpty()) { try { endpointResult = Stream .of(resourcePatternResolver.getResources(SOFA_BOOT_VERSION_PROPERTIES)) .map(this::loadProperties).collect(Collectors.toList()); } catch (...
127777820_0
public synchronized ImmutableSet<Feature> getFeatures() { return ImmutableSet.copyOf(features.values()); }
127900860_0
@Override public Proxy getProxy(Task task) { return proxies.get(incrForLoop()); }
127906050_0
public static CipherStorage newInstance(Context context, Storage storage) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return new CipherStorageAndroidKeystore(context, storage); } return new CipherStorageSharedPreferencesKeystore(context, storage); }
127906883_15
public static long getMillSecond(String data){ long time = Long.parseLong(data); if(data.length() == LENGTH_SECOND){ time = Long.parseLong(data) * 1000; } else if(data.length() == LENGTH_MILLISECOND){ time = Long.parseLong(data); } else if(data.length() == LENGTH_MICROSECOND){ t...
127918464_1
@Override public DataSet<Field> fetchData(Connector connector, Cube cube) { SelectJoinStep<Record> fact = using((DataSource) null, null).select(cube.getFields().stream().map((c) -> { return field(c.asField()).as(c.getColumnNameAlias()); }).collect(Collectors.toList())).from(cube.getFact().getTableName()); cube.ge...
128018428_130
public static void putTokenCacheNode(long tokenId, TokenCacheNode cacheNode) { TOKEN_CACHE_NODE_MAP.put(tokenId, cacheNode); }
128022542_2
@Override public String doOCR(File imageFile) throws TesseractException { return doOCR(imageFile, null); }
128027255_0
public static String getLocalHost() throws UnknownHostException { InetAddress inetAddress = InetAddress.getLocalHost(); System.out.println(inetAddress.getHostAddress()); return inetAddress.getHostAddress(); }
128056094_15
@Override public boolean hasBeanOfName(String name) { return locators.stream() .map(locator -> locator.hasBeanOfName(name)) .filter(Boolean::booleanValue) .findFirst().orElse(false); }
128169626_1
public Optional<ZoneId> query(double latitude, double longitude) { final List<ZoneId> result = index.query(latitude, longitude); return result.size() > 0 ? Optional.of(result.get(0)) : Optional.empty(); }
128191219_0
public FontBuilder fontArial() { return Styles.fontArial(); }
128219123_103
public Optional<GatekeeperRDSInstance> getOneInstance(AWSEnvironment environment, String dbInstanceIdentifier, String instanceName) { logger.info(dbInstanceIdentifier); Long startTime = System.currentTimeMillis(); List<String> securityGroupIds = sgLookupService.fetchSgsForAccountRegion(environment); Ama...
128272183_81
public static CatalogService getCatalogService(HttpClient httpClient) throws ConnectorSDKException { ConnectorSDKUtil adobeResourceUtil = ConnectorSDKUtil.getInstance(); String catalogEndpoint = adobeResourceUtil.getEndPoint(ResourceName.CATALOG); return new CatalogServiceImpl(catalogEndpoint, httpClient); ...
128309964_0
public String getExpression() { Map<Integer, List<Integer>> nodes = getPhenome(); String[] expressions = new String[genome.size() + getOutputs().size()]; Set<Integer> keysSet = nodes.keySet(); Integer[] keys = keysSet.toArray(new Integer[0]); List<Integer> actualNodes = null; String alph = "ABCD...
128393918_215
@Override public double logProb(IntegerTensor x) { return Multinomial.withParameters(n.getValue(), p.getValue(), validationEnabled).logProb(x).sumNumber(); }
128403104_0
public int get(int index) { int bitStartIndex = index * bitsPreEntry; int arrayStartIndex = bitStartIndex >>> 6; // bitStartIndex / 64 int arrayEndIndex = (bitStartIndex + bitsPreEntry - 1) >>> 6; Validate.inclusiveBetween(0, array.length - 1, arrayEndIndex); int offset = bitStartIndex & 63; // bitS...
128535513_29
public static String toString(final InputStream in, final String encoding) throws IOException { return new String(streamToByteArray(in), encoding); }
128639728_0
@Override protected Collection<Class<? extends Annotation>> getIdentifyingAnnotations() { logger.debug("getIdentifyingAnnotations return {" + Chaincode.class.getName() + "}"); return Collections.singleton(Chaincode.class); }
128753992_42
public int countDown(int n) { if (0 <= n) { // bug here n--; } return n; }
128853331_0
@PostMapping("/qq/{qq}") @BussinessLog(value = "获取QQ信息", platform = PlatformEnum.WEB) public ResponseVO qq(@PathVariable("qq") String qq) { if (StringUtils.isEmpty(qq)) { return ResultUtil.error(""); } Map<String, String> resultMap = new HashMap<>(4); String nickname = "匿名"; String json = Re...
129093497_7
public boolean addAdmin(String name, String password, String phone, String realName ,Integer adminId) throws InvalidArgumentException { //判断是否存在相同号码账号 if (StringUtils.isBlank(name)) throw new InvalidArgumentException("用户名不能为空!"); if (StringUtils.isBlank(phone)) throw new InvalidArgumentExc...
129100096_33
@Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); } EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, ...
129118555_5
@Override public void validate(Content content, Issues issues) { Struct formData = content.getStruct(formDataProperty); String action = content.getString(formActionProperty); // Validate form fields if (formData != null && formData.get(FormEditor.FORM_ELEMENTS) != null) { Struct formElements = formData.ge...
129126757_5
public String getPeriodUIString(PeriodType periodType, Date date, Locale locale) { String formattedDate; Date initDate = getNextPeriod(periodType, date, 0); Calendar cal = getCalendar(); cal.setTime(getNextPeriod(periodType, date, 1)); cal.add(Calendar.DAY_OF_YEAR, -1); Date endDate = cal.getT...
129169685_0
}
129194897_0
public static String getArtist(String lrcString) { String pattern = "\\[ar:(.*)\\]"; Pattern r = Pattern.compile(pattern); Matcher m = r.matcher(lrcString); if (m.find()) { return m.group(1); } else { return null; } }
129196583_5
public Flux<ServiceMessage> invokeMany( ServiceMessage message, BiFunction<ServiceMessage, Class<?>, ServiceMessage> dataDecoder) { return Flux.from(invoke(toRequest(message, dataDecoder))).map(this::toResponse); }
129207304_0
protected List<RpcBindingMethodInfo> parseSofaMethods(SofaMethod[] sofaMethods) { List<RpcBindingMethodInfo> rpcBindingMethodInfos = new ArrayList<RpcBindingMethodInfo>(); for (SofaMethod sofaMethod : sofaMethods) { RpcBindingMethodInfo rpcBindingMethodInfo = new RpcBindingMethodInfo(); rpcBind...
129259201_27
@Override public Object saveState(FacesContext context) { if (context == null) { throw new NullPointerException(); } Object[] result = null; Object superState = super.saveState(context); Object validatorsState = ((validators != null) ? validators.saveState(context) : null); if (superS...
129428289_6
public BaseConsent login(String appId, String sessionId, String sessionData, String username, String password, BaseClient.CookieStorage cookieStorage) throws UserLoginFailedException { String result = this.client.login(appId, sessionId, sessionData, username, password, cookieStorage); if(Strings.isNullOrEmpty(r...
129498280_9
@RequestMapping(path = "/account", method = RequestMethod.POST) public ResponseEntity<Account> addAccount(@RequestBody Account account) { return ResponseEntity.status(HttpStatus.CREATED).body(service.addAccount(account)); }
129501565_13
public List<T> flatten() { List<T> list = new ArrayList<T>(); Deque<Octree<T>> queue = new ArrayDeque<>(); queue.push(this); while (queue.size() > 0) { Octree<T> tree = queue.pop(); if (tree.item != null) { list.add(tree.item); } for (int oct = 0; oct < 8; ...
129508952_16
public static synchronized String getCountryName(Context context) { String countryName = ""; try { Locale locale = context.getApplicationContext().getResources().getConfiguration().locale; countryName = locale.getDisplayCountry(); } catch (Exception e) { countryName =...
129699491_18
public static <T> T getValueFromProtectedField(Object object, String fieldName) { Class<?> clazz = object.getClass(); try { Field field = clazz.getDeclaredField(fieldName); if (!field.isAccessible()) { field.setAccessible(true); } return (T) field.get(object); } c...
129712230_1
public static Object getPrivateField(Class<?> clazz, Object target, String fieldName) { Field field = ReflectionUtils.findField(clazz, fieldName); if (field != null) { ReflectionUtils.makeAccessible(field); return ReflectionUtils.getField(field, target); } return null; }
129740723_0
public ArrayList<Integer> getDepots() { return depots; }
129769092_246
public static boolean allHaveSameLength(Object... arrays) { if (arrays.length < 1) { return true; } int length = Array.getLength(arrays[0]); for (Object array : arrays) { if (Array.getLength(array) != length) { return false; } } return true; }
129771138_842
public boolean isWrongConsentData() { return CollectionUtils.isEmpty(psuDataList) || tppInformation == null || tppInformation.getTppInfo() == null; }
129848791_18
protected String getSchedulerName() { Object[] args = getJoinPoint().getArgs(); if (args == null || args.length == 0) return null; RxScheduler rxScheduler = RxScheduler.fromClass(args[0].getClass()); return rxScheduler != null ? rxScheduler.name() : args[0].getClass().getSimpleName(); }
129892661_69
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } LotteryTicket other = (LotteryTicket) obj; if (lotteryNumbers == null) { if (other.lotteryNumbers != null) { return...
129937852_18
public OpenIDConnectClientBuilder setClientId(String clientId) { if (clientId == null || clientId.trim().isEmpty()) throw new IllegalArgumentException("ClientID must not be null or empty"); this.clientId = clientId.trim(); return this; }
129954828_55
ClientRequest request() { return requestContext; }
129972128_93
JSONObject getBody() { return body; }
129984910_1
public static String getPrintSize(long size) { float printSize = (float)size / 1024/ 1024; return String.format("%.1fMB", printSize); }
130000911_104
public static byte[] encode(Object input) { Value val = new Value(input); if (val.isList()) { List<Object> inputArray = val.asList(); if (inputArray.isEmpty()) { return encodeLength(inputArray.size(), OFFSET_SHORT_LIST); } byte[] output = ByteUtil.EMPTY_BYTE_ARRAY; ...
130195883_0
public Observable<TotalResEntity.Register> register(String username, String password, String repassword) { return mWanApiService.register(username, password, repassword) .map(new WanHttpResultFunc<TotalResEntity.Register>()) .compose(RxSchedulers.<TotalResEntity.Register>io_main()); }
130200142_1
public String getMeasureId() { return String.format("%s_measure_%s_%s", Utils.getAndroidID(getContentResolver()), Utils.getUniversalTimestamp(), Utils.getSaltString(16)); }
130308047_3
@Override public void onException(String summary, Throwable error) { zlgSupplier.get().w(summary, error); }
130327993_3
@Override public IdRpcService.GenerateIdResponse process(IdRpcService.GenerateIdRequest request) throws NotFoundException, SystemException, UserException { IdRpcService.GenerateIdResponse.Builder response = IdRpcService.GenerateIdResponse.newBuilder(); for(int i = 0; i < request.getCount(); i++){ Long ...
130383787_0
public List<CardBin> getCardBins(){ CardBinRequest.Builder request = CardBinRequest.newBuilder(); request.setUserName(rpcUserName); request.setPassword(rpcPassword); CardBinResponse response = client.execute(CARD_BIN_SERVICE_NAME, request.build(), CardBinResponse.class); return response.getCardBinList(); }
130464600_4
public static StringPropertyValidationRules textValidator() { return new StringPropertyValidationRules(false, 32); }
130481756_44
@Override public void write(AssetResponse assetResponse, @Nullable MediaType mediaType, HttpOutputMessage httpOutputMessage) throws IOException { // Get meta data Asset asset = assetResponse.getAsset(); AssetMetaData metaData = asset.getMetaData(); // Set header values httpOutputMessage.getHeaders() .setCont...
130492560_2
@Override public JsonNode deserialize(String topic, byte[] data) { if (data == null) { return null; } try { return mapper.readTree(data); } catch (Exception e) { throw new SerializationException("Error deserializing from " + new String(data), e); } }
130509793_1
public static String colored(String message) { return message != null ? ChatColor.translateAlternateColorCodes('&', message) : null; }
130510170_0
public static String getHtmlCharset(byte[] htmlContent) { String charset = Charset.defaultCharset().name(); return getHtmlCharset(htmlContent, charset); }
130603282_52
public void stopStreamAdapter(AdapterStreamDescription adapterStreamDescription) throws AdapterException { stopAdapter(adapterStreamDescription); }
130709430_86
@Override public LogLevel apply(LogDefinition definition) { return min(definition.getLevel(), definition.getIfEnabledLevel()); }