id
stringlengths
7
14
text
stringlengths
1
37.2k
88406700_2
@NonNull public static Observable<Intent> receives(@NonNull final Context context, @NonNull final IntentFilter intentFilter) { return Observable.create(new ObservableOnSubscribe<Intent>() { @Override public void subscribe(final ObservableEmitter<Intent> emitter) { final BroadcastReceiver receive...
88435530_1
static<M extends FlaxModel> M getModel(Class modelClass) { return getModel(modelClass, 0); }
88485241_3
public void setAllPwm(int on, int off) throws IOException { if (i2cDevice != null) { try { i2cDevice.writeRegByte(ALL_LED_ON_L, (byte) (on & 0xFF)); i2cDevice.writeRegByte(ALL_LED_ON_H, (byte) (on >> 8)); i2cDevice.writeRegByte(ALL_LED_OFF_L, (byte) (off & 0xFF)); i2cDevice.writeRegByte(AL...
88544701_185
@Override public Subscription awaitComplete() throws SubscriptionCancelledException { for (;;) { assertSubscriptionStateNotClosed(); Subscription cur = currentSubscription.get(); if (cur != null) { try { cur.awaitComplete(); return this; ...
88621169_2
@EventHandler // Mark this method as an Axon Event Handler public void on(ProductAddedEvent productAddedEvent) { repo.save(new Product(productAddedEvent.getId(), productAddedEvent.getName())); LOG.info("A product was added! Id={} Name={}", productAddedEvent.getId(), productAddedEvent.getName()); }
88657105_4
public static AddressSelectorBinder simpleAddressSelector() { return new SimpleAddressSelectorBinder(Optional.empty()); }
88711981_23
@Override public InternalMessage convert(Message_1_0 serverMessage, NamedAddressSpace addressSpace) { Object bodyObject = MessageConverter_from_1_0.convertBodyToObject(serverMessage); final AMQMessageHeader convertHeader = convertHeader(serverMessage, addressSpace, bodyObject); return InternalMessage.conver...
88777477_44
public <T> ObjectRepository<T> getRepository(NitriteConfig nitriteConfig, Class<T> type) { return getRepository(nitriteConfig, type, null); }
88787780_15
public static String toHexString(byte[] bytes) { return toHexString(bytes, 0, bytes.length); }
88794099_0
@NotNull public Resource getModelLocation() { return modelLocation; }
88820221_9
;
88831074_192
public String getDir() { return dir; }
88832698_0
@GetMapping public String getDataWithCache() { Long startTime = System.currentTimeMillis(); long timestamp = this.cacheDao.getDataWithCache() ; Long endTime = System.currentTimeMillis(); System.out.println("耗时: " + (endTime - startTime)); return timestamp+""; }
88860621_0
public static String calculateTypeName(CompilationUnit compilationUnit, FullyQualifiedJavaType fqjt) { if (fqjt.getTypeArguments().size() > 0) { return calculateParameterizedTypeName(compilationUnit, fqjt); } if(compilationUnit == null || typeDoesNotRequireImport(fqjt) ...
88873634_2
@Override @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) public Drawable getDividerDrawable() { Drawable divider = super.getDividerDrawable(); if (divider instanceof SpaceDrawable) { return null; } return divider; }
88944428_6
public static Tracer resolveTracer() { return resolveTracer(null); }
88962042_13
static ClassesTransformer<JavaClass> classes() { return new AbstractClassesTransformer<JavaClass>("classes") { @Override public Iterable<JavaClass> doTransform(JavaClasses collection) { return collection; } }; }
88978812_18
public Color nextColor(Color color) { return successor.get(color); }
88985813_8
long getConsistentApplicationModelVersion() { long applicationModelVersion = 0; if (m_beforePostProcessingVersion > 0) { applicationModelVersion = m_beforePostProcessingVersion; } // since we already validate version after postprocessing no need to validate it again, so if set override the initi...
89094025_0
public void tic() { double newAveragedDouble = DECAY * (buffer.dequeue() + buffer.peek()) / 2; buffer.enqueue(newAveragedDouble); }
89108465_0
public static StringBuffer writeTo(StringBuffer sb, StringWritable... values) throws IllegalArgumentException { checkNotNull(sb, "sb"); if(null == values || values.length == 0) { return sb; } writeStringWritableToStringBuffer(values[0], sb); int i = 1; while (i < values.length) { ...
89109684_3
@SuppressWarnings("rawtypes") @Override public void generate(String targetPath, Object model, Any config) throws IOException { if (StringUtils.isBlank(targetPath)) { logger.error("Output location is not specified."); return; } if (!config.keys().contains(CONFIG_SPECGENERATION)) { logger.error("Missing con...
89138130_116
public static SnowFilter parse(String text) throws StringParseException { FilterParser parser = new FilterParser(text); SnowFilter retval = new SnowFilter(); // This keeps track of whether the currently built clause is to be placed in the filter with an AND. If false, the // clause will be placed in the filter...
89139973_10
@Override public synchronized void add(URI associatedUri, HttpCookie cookie) { URI uri = new OriginUri(cookie, associatedUri).uri(); Set<HttpCookie> targetCookies = cookiesCache.get(uri); if (targetCookies == null) { targetCookies = new HashSet<>(); cookiesCache.put(uri, targetCookies); ...
89188081_1
void initialize() { Locale persistedLocale = persistor.load(); if (persistedLocale != null) try { currentLocale = resolver.resolve(persistedLocale); } catch (UnsupportedLocaleException e) { persistedLocale = null; } if (persistedLocale == null) { Def...
89189554_0
public void destoryDB() { mDbOpenHelper = null; DataBaseOpenHelper.clearInstance(); }
89198062_28
public Object getStateToBind(Object orig, Name name, Context ctx, Hashtable<?,?> env) throws NamingException { if (orig instanceof org.omg.CORBA.Object) { return orig; } if (!(orig instanceof Remote)) { return null; } ORB orb = getORB( ctx ) ; if (orb == null) { /...
89208595_2
public static long generate() { return generate(DEFAULT_SHARD_ID); }
89212553_9
@NonNull public Stage direct(@NonNull ViewGroup container) { return direct(container, container.getId()); }
89217740_4
static List<Cluster> filterClusters( List<Cluster> clusters, List<ClusterPlacement> allPlacements) { Set<String> clusterPlacements = allPlacements.stream() .map(ClusterPlacement::token) .collect(toSet()); return clusters.stream() .filter(cluster -> clusterPlacements.contains(placement(clu...
89220387_0
@DeleteMapping("/{id}") public void delete(@PathVariable Long id) { System.out.println(id); bookService.delete(id); }
89221572_36
public static <T> T lz4Stream( InputStream is, final int expectedSize, final BytesConsumer<T> consumer) throws IOException { is = ensureMarkSupported(is); if (isCompressed(is)) { return readStream(is, expectedSize, consumer); } else { final FastByteArrayOutputStream baos = new FastByteArrayOutputStrea...
89231271_0
public static void parse(String template, Handler handler) { assert template != null; assert handler != null; int pos = 0; final int length = template.length(); State state = State.OutsideParam; StringBuilder builder = new StringBuilder(); while (pos < length) { char c = template.charAt(pos++); switch (state...
89233128_4
public VariableElement[] getEnumConstants(TypeElement clazz) { List<? extends Element> elements = env.getElementUtils().getAllMembers(clazz); Collection<VariableElement> constants = new ArrayList<VariableElement>(); for (Element element : elements) { if (element.getKind().equals(ElementKind.ENUM_CON...
89239936_2
public static RequestLog getRequestLog(String name) { String lookup = serverToComponent.get(name); if (lookup != null) { name = lookup; } String loggerName = "http.requests." + name; String appenderName = name + "requestlog"; Log logger = LogFactory.getLog(loggerName); if (logger instanceof Log4JLog...
89252015_0
static String getActiveHttpProxy(Settings s) { String retVal = null; for (Proxy p : s.getProxies()) { if (p.isActive() && "http".equals(p.getProtocol())) { StringBuilder sb = new StringBuilder(); String user = p.getUsername(); String pwd = p.getPassword(); ...
89259438_0
public TracingHttpClientBuilder disableInjection() { this.injectDisabled = true; return this; }
89302682_1
public String encrypt(String randomStr, String text) throws AesException { ByteGroup byteCollector = new ByteGroup(); byte[] randomStrBytes = randomStr.getBytes(CHARSET); byte[] textBytes = text.getBytes(CHARSET); byte[] networkBytesOrder = getNetworkBytesOrder(textBytes.length); byte[] appidBytes = appId.getByte...
89335647_1
@VisibleForTesting void checkAndroidVersionCompatibility() { if (!supportedByArtist()) { mView.showIncompatibleAndroidVersionDialog(); } }
89412712_8
public static boolean getBooleanProperty(Properties props, String name, boolean def) { urn getBoolean(getProp(props, name), def); }
89435838_9
@Override public int remaining() { return ((len > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) len); }
89485344_21
public double getAmountDelta() { double amountDelta = 0.0; for (Transaction transaction : this.transactionSupplier.getAll()) { amountDelta += transaction.booking().getAmount(); } return amountDelta; }
89507222_6
public Task<Void> migrate(boolean cleanupDigitsSession) { final FirebaseUser currentUser = mFirebaseAuth.getCurrentUser(); final String sessionJson = mStorageHelpers.getDigitsSessionJson(); final Context context = mApp.getApplicationContext(); final RedeemableDigitsSessionBuilder builder; // If the...
89524112_2
private static JCommander createCommander(CommandContainer commandContainer, String[] args) { JCommander.Builder builder = JCommander.newBuilder(); for (String operation : commandContainer.getAllCommands()) { CommandContainer.Command command = commandContainer.getCommand(operation); builder.addC...
89576260_7
public static boolean isThereJobCallbackProperty(Props props, JobCallbackStatusEnum status) { if (props == null || status == null) { throw new NullPointerException("One of the argument is null"); } String jobCallBackUrl = firstJobcallbackPropertyMap.get(status); return props.containsKey(jobCallBackUrl...
89588723_1
public static String urlDecode(String encode){ try { return URLDecoder.decode(encode,"UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; }
89607184_16
@GetMapping("/manage/managers") @RowCustom(distinct = true, dramatizer = JQueryDataTableDramatizer.class) public RowDefinition list(String name, String department, String realName) { return new RowDefinition<Manager>() { @Override public Class<Manager> entityClass() { return Manager.clas...
89617755_61
@Override public long getLong( int rowOffset ) throws InvalidAccessException { final long result; switch ( getType().getMinorType() ) { // 1. Regular type: case BIGINT: result = innerAccessor.getLong( rowOffset ); break; // 2. Converted-from types: case TINYINT: result = innerAcce...
89644636_7
public byte[] getModel(String modelUri) { return getModel(new DefaultResourceLoader().getResource(modelUri)); }
89676913_0
public static <T> T get(String key, Function<String, T> parser, T defaultValue) { return get(System.getProperties(), key, parser, defaultValue); }
89684482_0
@Override public CallAdapter<?, ?> get(@Nonnull final Type returnType, @Nonnull final Annotation[] annotations, @Nonnull final Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedType)) { throw new IllegalState...
89730191_2
public static void setTheme(@NonNull PrimaryColor primaryColor, @NonNull AccentColor accentColor) { setTheme(new ColorTheme(primaryColor, accentColor)); }
89738443_0
public static void onLoggedIn(String token) { DigitalOcean.authToken = token; if (okHttpClient == null) { OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder() .addInterceptor(new Interceptor() { @Override public Response intercept(Chain...
89762510_23
@DeleteMapping("/{id}") public void removeGirl(@PathVariable("id") Integer id) { girlRepository.deleteById(id); }
89791542_4
@Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { if (position == 0 && positionOffsetPixels == 0 && !isAnimating()) { onPageSelected(0); } if (isAnimating() && lastPosition != position || positionOffsetPixels == 0) { endAnimation(position); ...
89856316_30
public Event map(VEvent event, TimeZone defaultTimeZone) { Event result = new Event(); nullSave(() -> { final DateTime start = new DateTime(event.getDateStart().getValue().getTime(), DateTimeZone.forTimeZone(defaultTimeZone)); result.setStart(start, event.getDateStart().getValue().hasTime()); }); null...
89961630_1
@SafeVarargs public static final TagValue[][] getTagCombinations(Class<? extends TagValue>... tagValueClazzes) { int combinations = 1; for (Class<? extends TagValue> clazz : tagValueClazzes) { combinations *= clazz.getEnumConstants().length; } TagValue[][] result = new TagValue[combinations...
90011594_29
public void run(SchedulerMode mode) { mActionsToRemove.clear(); startNewActions(); runActions(mode); startDefaultSubsystemActions(mode); readyForNextRun(); }
90020587_0
public List<Trade> createRandomData(int number) throws Exception { // TODO Auto-generated method stub return null; }
90026142_0
public void truncateSuffix(long newEndIndex) { if (newEndIndex >= getLastLogIndex()) { return; } LOG.info("Truncating log from old end index {} to new end index {}", getLastLogIndex(), newEndIndex); while (!startLogIndexSegmentMap.isEmpty()) { Segment segment = startLogIndexS...
90036492_1
static MergedItem newRow(int type, long id) { return new MergedItem(type, id, false); }
90043355_117
public void apply(int n, float[] x, float[] y) { Conv.conv(_filter.length,-(_filter.length-1)/2,_filter,n,0,x,n,0,y); }
90045866_1
public static Map<String, ParamDefaultValue> getParamsDefaultValuesUseAlsoDB(IDataSet dataSet) { Map<String, ParamDefaultValue> res = DataSetUtilities.getParamsDefaultValues(dataSet); if (res != null) { return res; } logger.warn("No params default values found on dataSet. I try from db."); // res=null, load dat...
90096766_23
@PostMapping("/authenticate") @Timed public ResponseEntity authorize(@Valid @RequestBody LoginVM loginVM, HttpServletResponse response) { UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginVM.getUsername(), loginVM.getPassword()); try { Authe...
90135592_5
public void pushEvent(EventLog eventLogEntry, NakadiEvent nakadiEvent) { long eventSize; try { eventSize = objectMapper.writeValueAsBytes(nakadiEvent).length; } catch (Exception e) { log.error("Could not serialize event {} of type {}, skipping it.", eventLogEntry.getId(), eventLogEntry.getE...
90140540_5
public Organisation getOrganisation(String organization) throws ApiException { ApiResponse<Organisation> resp = getOrganisationWithHttpInfo(organization); return resp.getData(); }
90153418_10
@Override public UserEntity save(UserEntity userEntity) { return userRepository.save(userEntity); }
90198241_2
protected ASimulator() { }
90217436_135
public long getStoreFreeOfDifferentStorageType(String storageType) throws MetaStoreException { try { int sid = 0; if (storageType.equals("ram")) { sid = 0; } if (storageType.equals("ssd")) { sid = 1; } if (storageType.equals("disk")) { sid = 2; } if (storageType.e...
90226261_4
@Override public PayloadWrapper<CustomerPayload> extractData(ResultSet rs) throws SQLException, DataAccessException { CustomerPayload customerPayload = null; if (rs.next()) { customerPayload = new CustomerPayload(); customerPayload.setId(rs.getString("ID")); customerPayload.setName(rs.getString("NAME")); } re...
90329901_92
public String getString(Object input) { String ret = ""; if (input != null) { if (input instanceof String) { ret = (String) input; } else if (input instanceof byte[]) { ret = new String((byte[]) input); } else { ret = input.toString(); } } return ret; }
90330610_6
public static List<String> sanitizeTopicFilter(String topicFilter) { if (StringUtils.isEmpty(topicFilter)) throw new IllegalArgumentException("Empty topic filer"); if (!topicFilter.contains("+") && !topicFilter.contains("#")) throw new IllegalArgumentException("Topic filter does not contain wildcard"); ...
90375338_3
public static Set<Class<?>> getClasses(final String packageName) { Reflections reflections = new Reflections(packageName); return reflections.getTypesAnnotatedWith(Entity.class); }
90393998_1
public <T> T fromHtml(String html, Class<T> classOfT) { return fromHtml(html, (Type) classOfT); }
90406775_23
public String dump(Unit unit) { StringBuilder buf = new StringBuilder(); buf.append(unit).append(":\n"); Map<Unit, UnitFactor> map = factors.get(unit); for (Unit base : map.keySet()) { UnitFactor factor = map.get(base); buf.append(" ").append(factor).append(" "); buf.append(factor.rational().compu...
90442475_0
@Override public void loadFileInfos() { mFileInfosRepository .listFileInfos(mDirectory) .observeOn(mSchedulerProvider.ui()) .subscribe(new Action1<List<FileInfo>>() { @Override public void call(List<FileInfo> fileInfos) { if (fi...
90446318_3
@Override public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException { User user = userRepository.findByUsername(s); log.info("user is found! -> " + user.getUsername()); if (user == null) { log.info("user is not found!"); throw new UsernameNotFoundException(s); } ...
90461984_0
public String convert(String text, int position) { HashMap<Character, String> hashMap = fonts.get(position); ArrayList<String> chars = new ArrayList<>(); for (int i = 0; i < text.length(); i++) { String s = hashMap.get(Character.toUpperCase(text.charAt(i))); if (s == null) { thr...
90489106_2
public static Dataset concat(Dataset d1, Dataset d2) { double[][] X = concat(d1.getX(), d2.getX()); double[] y = concat(d1.getY(), d2.getY()); return new Dataset(X, y); }
90643804_7
@RequestMapping(value = "/{username}/duplication", method = RequestMethod.GET) @ApiOperation(value = "查询用户名是否重复", response = Boolean.class) @ApiResponses(value = {@ApiResponse(code = 401, message = "未登录")}) public boolean isUsernameDuplicated(@PathVariable("username") String username) { if (service.findByUsername(u...
90646801_4
public final String populateFrom(final LatexContext context) { requireNonNull(context); final VelocityEngine velocityEngine = initializeEngine(); final VelocityContext velocityContext = prepareContext(context); return evaluateTemplate(velocityContext, velocityEngine); }
90675730_96
public String format(final Quantity.Format format, final int exponent) { switch (format) { case DECIMAL_SI: return getDecimalSiSuffix(exponent); case BINARY_SI: return getBinarySiSuffix(exponent); case DECIMAL_EXPONENT: return exponent == 0 ? "" : "e" + exponent; default: throw...
90725839_1
static void loadProperties(Properties properties) throws InitConfigurationException { if (instance == null) { instance = getConfigInstance(); } ConfigurationUtils.loadProperties(properties, instance); }
90792480_1
protected float computeValueByOffset(float positionOffset) { positionOffset = computeByTimeShift(positionOffset); positionOffset = computeByInterpolator(positionOffset); return computeExactPosition(x1, x2, positionOffset); }
90798597_2
@Override public void deleteImage() { mImagesRepository.deleteImage(mImage); mView.displayImageDeleted(); }
90798624_1
@Override public void loadPosts() { mView.setLoadingPosts(true); mData.getPosts(new DataSource.GetPostsCallback() { @Override public void onPostsLoaded(Post[] posts) { mView.setLoadingPosts(false); mView.hideError(); if (posts != null && posts.length > 0) { ...
90847405_0
private String updateImagesPath(String template) { return template.replaceAll(IMAGE_PATH_REGEX, IMAGE_PATH_REPLACEMENT); }
90860455_7
public Node applyTo(Node root, Set<Node> finalNodes) throws DialogRewriteException, RepositoryException { // check if the 'replacement' node exists if (!ruleNode.hasNode("replacement")) { throw new DialogRewriteException("The rule does not define a replacement node"); } // if the replac...
90881605_2
public Pager(BiFunction<Long, Long, T> fetchFn, Long limit, Long pageSize) { Function<RequestPager.Page, T> fn = (page) -> { try { return fetchFn.apply(page.getLimit(), page.getOffset()); } catch (Exception e) { Long start = page.getOffset(); Long end = s...
90886387_3
public void clear() { mItems.clear(); mBinderListCache.clear(); mViewHolderToItemPositionCache.clear(); mItemPositionToFirstViewHolderPositionCache.clear(); mViewHolderPreparedCache.clear(); mPreviousBoundViewHolderPosition = NO_PREVIOUS_BOUND_VIEWHOLDER; }
90917301_4
public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, errorMessage); }...
90936492_25
public int loreSize(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return 0; List<String> lores = IM.getLore(); if (lores == null) return 0; return lores.size(); }
90972254_0
;
90985502_0
public static String classnameFromFilename(final String filename) { Objects.requireNonNull(filename); return StreamSupport.stream( Paths.get(filename.replaceFirst("\\.class$", "")).spliterator(), false) .map(Path::toString) .collect(Collectors.joining(".")); }
91037889_4
void onReportDataError(Throwable throwable) { Timber.e(throwable, "report error"); view.displayReportError(); }
91054623_7
public static int getPid() { RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); String name = runtime.getName(); // format: "pid@hostname" try { return Integer.parseInt(name.substring(0, name.indexOf('@'))); } catch (Exception e) { return -1; } }
91104663_9
@Nullable public static List<String> parseOptStringList(@Nullable JSONArray jsonArray) { if (jsonArray == null) { return null; } final List<String> list = new ArrayList<>(); for (int i = 0; i < jsonArray.length(); i++) { final String item = jsonArray.optString(i, null); if (ite...
91120647_47
@Override public void write( Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, Writer stream, Object entry) throws IOException, WebApplicationException { Class<?> componentType = getComp...
91155672_2
@GET @Produces(MediaType.APPLICATION_JSON) public static Response get() { return Responses.ok(Webhooks.instance().hooks()); }
91247102_8
@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, ...