id
stringlengths
7
14
text
stringlengths
1
37.2k
64304762_1
@RequestMapping("/product") public String getProductById(@RequestParam("id") String productId, Model model) { model.addAttribute("product", productService.getProductById(productId)); return "product"; }
64339521_6
@Nullable @Override public UUID getCorrelationId() { return mCorrelationId; }
64340716_77
public static Type getPropertyType(Class<?> beanClass, String field) { try { return INSTANCE.findPropertyType(beanClass, field); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw handleReflectionException(beanClass, field, e); } }
64371551_1
void doLogin(String userName, String password) { if (isLoginAttemptExceeded()) { loginView.showErrorMessageForMaxLoginAttempt(); return; } if (userName.equals("nj") && password.equals("tdd")) { loginView.showLoginSuccessMessage(); resetLoginAttempt(); return; } ...
64405938_0
@Override public String getQuery(DBpediaResource resource, int option) { return constructQuery(resource, this.excludeNames+option); }
64431348_524
static String generateFullMetricDescription(String metricName, Metric metric) { return "Collected from " + SOURCE + " (metric=" + metricName + ", type=" + metric.getClass().getName() + ")"; }
64458355_0
protected void setMainArgs(String[] mainArgs) { this.arguments = new BundledJarRunner.Arguments.Builder() .from(arguments) .setMainArgs(mainArgs) .createArguments(); }
64487983_122
public static void main(String[] args) throws Exception { CamelContext context = new DefaultCamelContext(); context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("stream:in").to("direct:greetings"); from("direct:greetings").to("stream:out"); } }...
64510591_31
public final Single<T> read() { return Single.defer(() -> Single.fromObservable(builder.processorProviders .<T>process(getConfigProvider(exceptionAdapter.placeholderLoader(), new EvictDynamicKey(false), false, null)))) .onErrorResumeNext(exceptionAdapter::stripPlaceholderLoaderExce...
64529819_0
;
64537232_9
public static BoardState parseState(String s) throws IllegalArgumentException { if (s == null) { throw new IllegalArgumentException("No config sequence given. String must not be null."); } else if (!s.startsWith(">")) { throw new IllegalArgumentException("Config sequence does not start with an >"); } else if (!s...
64558143_221
public static void postSticky(final String tag) { postSticky(tag, NULL); }
64565477_5
@Override public JsonNode getConfiguration() { return ConfigurationUtils.Properties.fromMap(System.getenv()); }
64608558_1
public Rule getRule() { return this.rule; }
64658258_0
public Calendar periodBegin(Calendar time) { return periodBegin(time, 0); }
64719557_101
@Override public void sendRedirect(String location) throws IOException { throw new UnsupportedOperationException(); }
64751214_2
public Collection<Category> getAllCategories() { return categoryRepository.findAll(); }
64767540_1
@Deprecated public boolean isLDAPEnabled(XWikiContext context) { return isLDAPEnabled(); }
64772578_2
public static Error parseError(String errorBody) { try { Error error = null; if (errorBody.trim().charAt(0) == '[') { JSONArray errorArray = new JSONArray(errorBody); JSONObject errorArrayJSONObject = errorArray.getJSONObject(0); if (errorArrayJSONObject.has("typ...
64774221_0
public static BridgeHttpRule create(HttpRule httpRule) { if (!httpRule.getGet().isEmpty()) { return new BridgeHttpRule(httpRule.getGet(), HttpMethod.GET, httpRule.getBody()); } else if (!httpRule.getPost().isEmpty()) { return new BridgeHttpRule(httpRule.getPost(), HttpMethod.POST, httpRule.getBo...
64785879_7
public void sendName(String destinationName, String firstName, String lastName) throws JMSException { String text = firstName + " " + lastName; // create a JMS TextMessage TextMessage textMessage = session.createTextMessage(text); // create the Destination to which messages will be sent Destination des...
64790683_1
@GET @Produces(MediaType.APPLICATION_JSON) @Path("/{categoryId}") public Category get(@PathParam("categoryId") Integer categoryId) { return em.find(Category.class, categoryId); }
64873196_8
@Override public Integer next() { if (!hasNext()) throw new IllegalStateException("position out of bounds reached"); return pos++; }
65041301_17
@VisibleForTesting Single<Reply<List<User>>> getUsersReply(Integer lastIdQueried, final boolean refresh) { int safeId = lastIdQueried == null ? FIRST_DEFAULT_ID : lastIdQueried; Single<List<User>> apiCall = githubUsersApi .getUsers(safeId, USERS_PER_PAGE) .compose(networkResponse.process()); return ...
65071174_2
public String[] tokenize(String s) { t<String> tokens = new ArrayList<String>(); lean inTok = false; ingBuilder curr = new StringBuilder(); (int i = 0; i < s.length(); i++) { if (StringUtil.isWhitespace(s.charAt(i))) { (inTok) { stemmer.stem(); String tok = stemmer.toString(); stemmer.reset(); tokens.ad...
65077465_3
private static Map<String, String> validate(@NotNull Map<String, String> runnerParams, boolean runtime) { final Map<String, String> invalids = new HashMap<String, String>(); invalids.putAll(AWSCommonParams.validate(runnerParams, !runtime)); final String s3BucketName = runnerParams.get(S3_BUCKET_NAME_PARAM); i...
65084302_122
@Override public void doFilter(ApiContext apiContext, Future<ApiContext> completeFuture) { for (int i = 0; i < apiContext.requests().size(); i++) { RpcRequest request = apiContext.requests().get(i); if (request instanceof HttpRpcRequest) { replace(apiContext, (HttpRpcRequest) request); ...
65089775_0
public boolean awaitFulfill(final Instant waitingSince) throws IOException { while (true) { awaitFulfill(waitingSince, Duration.ONE_DAY); } }
65144978_0
public void base64Image2PNG(String base64Image, File outFile) throws IOException { try (FileOutputStream imageOutFile = new FileOutputStream(outFile)) { // Converting a Base64 String into Image byte array byte[] imageByteArray = Base64.getDecoder().decode(base64Image); imageOutFile.write(ima...
65158020_24
public String replace(String origin, String replacement) { if (origin == null) { return null; } if (replacement == null) { return origin; } Matcher matcher = PATTERN.matcher(origin); String result = matcher.replaceAll(replacement); return result; }
65185727_6
@NotNull public static String generateViewName(@NotNull String basename, @NotNull OrientationHandler.Size size, @NotNull OrientationHandler.Orientation orientation) { if (basename.equals(QuarkFXApplication.HOME_VIEW)) return basename; return basename + " " + size.name() + " " + orientation.name() + " Vi...
65194280_0
public synchronized Path getTempDir() throws IOException { Path tempDir = new Path(prefix+Integer.toString(seqNum++)); if(fileSystem!=null) { while (dirs.contains(tempDir) || fileSystem.exists(tempDir)) { tempDir = new Path(prefix+Integer.toString(seqNum++)); } } else { while (dirs.contains(tempDir...
65245890_41
public boolean isDuplicateFilteringEnabled() { return filterDuplicates; }
65259211_52
@Override public Object apply(SqlFunctionExecutionContext context) { Object arg = context.getArgument(0); Object format = null; if (context.getNumberOfArguments() >= 2) { format = context.getArgument(1); } if (arg instanceof String && isNumeric(String.valueOf(arg))) { String str = St...
65266635_0
public double divide(int num1, int num2){ return num1/num2; }
65277100_0
protected void updateValue(final V value) { if(inWillChangeEvent) { throw new IllegalStateException("Value can not change while willChangeEvents are handled!"); } if (this.value != value) { boolean canChange = fireWillChangeEvent(value); if(canChange) { try { ...
65312676_1
public AIServiceContext build() { if (sessionId == null) { throw new IllegalStateException("Session id is undefined"); } return new PlainAIServiceContext(sessionId, timeZone); }
65356302_30
@Override public CheckResult check() { try { Request request = new Request.Builder().url(endpoint) .post(RequestBody.create(MediaType.parse("application/json"), "[]")).build(); try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) { return CheckResult....
65398296_64
static EnvironmentConfig create(EnvironmentExtension extension) throws EnvironmentConfigException { if (extension == null) { throw new EnvironmentConfigException(PLUGIN_MESSAGE_BUNDLE.getMessage("DEPLOYER_PLUGIN_ERROR_EXTENSION_OR_CONFIG_NULL")); } // Initialize the config object EnvironmentCon...
65402989_8
@NonNull @Override public Option<Float> getFloat(@NonNull final String key) { return getObject(key) .ofType(Float.class); }
65441815_0
public List<Entry<String, Double>> sort(Map<String, Double> map) { List<Entry<String, Double>> list = new ArrayList<Map.Entry<String, Double>>(map.entrySet()); Comparator<Entry<String, Double>> comparator = new Comparator<Entry<String, Double>>(){ public int compare(Entry<String, Double> one, Entry<String, Double> ...
65505864_3
@Override public List<Map<String, String>> taskConfigs(int maxTasks) { // Each task will get the exact same configuration. Delegate all config validation to the task. ArrayList<Map<String, String>> configs = new ArrayList<>(); for (int i = 0; i < maxTasks; i++) { Map<String, String> config = new HashMap<>(pro...
65507705_13
@Override public Observable<ServerInfo> getServerInfo() { return withVersionRequestCheck(mService.getServerInfo()); }
65559078_9
static BigDecimal getPrice(List<Book> books) { return Function1.of(HarryPotter::getBookSets) .andThen(HarryPotter::getBundles) .andThen(HarryPotter::adjustBundles) .andThen(HarryPotter::getPriceForBundles) .apply(books); }
65582397_2
public static LogServiceRequestProto toReadLogRequestProto(LogName name, long start, int total) { LogNameProto logNameProto = LogNameProto.newBuilder().setName(name.getName()).build(); ReadLogRequestProto.Builder builder = ReadLogRequestProto.newBuilder(); builder.setLogName(logNameProto); builder.setStar...
65604083_16
public static int[] natural(int n) { final int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = i; } return a; }
65606855_51
public List<CheckInDetail> getCheckInDetails(Attendee attendee, List<CheckInDetail> checkInDetails) { String[] checkInTimes = attendee.getCheckinTimes().split(","); String[] checkOutTimes = attendee.getCheckoutTimes().split(","); for (int i = 0; i < checkInTimes.length + checkOutTimes.length; i++) { ...
65701037_10
@Override public void modifyText(String title, String oldString, String modifyString) { if (StringUtils.isEmpty(modifyString)) { view.showTip(title + "不能为空"); return; } // 旧文字为空或旧文字和新文字不相等,视为已修改 boolean isModify = oldString == null || !oldString.equals(modifyString); view.modifyText...
65751573_64
public Map<String, Object> convertRecord(SinkRecord record, KafkaSchemaRecordType recordType) { Schema kafkaConnectSchema = recordType == KafkaSchemaRecordType.KEY ? record.keySchema() : record.valueSchema(); Object kafkaConnectStruct = recordType == KafkaSchemaRecordType.KEY ? record.key() : record.value(); if (...
65800867_31
public ProfileResult process(List<Run> runs) { if (runs.isEmpty()) { return null; } List<RootSingleProfileResult> results = new ArrayList<>(); for (Run run : runs) { results.add(processSingleRun(run)); } if (results.size() == 1) { return results.get(0); } return ...
65812017_1
public BranchAlgebra concat(BranchAlgebra right) { branches.addAll(right.branches); space.merge(right.space); return this; }
65853610_0
@SuppressWarnings("unchecked") public void addItem(Variable variable) { if (!registeredDataTypes.containsKey(variable.getDataType().getName())) { throw new IllegalStateException(String.format( Locale.getDefault(), "There is no registered data type that matches %s. Are you sure you ran " + ...
65855862_4
public static Map<String, String> getKnownLibraryVersions() { Map<String, String> results = new HashMap<>(); for (String knownProjectGroup : KNOWN_PROJECT_GROUPS) { String versions = VersioningUtils.summarize(VersioningUtils.getProjectHistogram( project -> project.getCoordinates().getGroup().equals(know...
65927678_11
@Override public void result(int requestCode, int resultCode, Intent data) { // If a recording was successfully saved, show snackbar if (MonitoringActivity.REQUEST_MONITORING == requestCode) { if (resultCode == Activity.RESULT_OK) { // Refresh recordings loadData(true); ...
65931687_6
@PUT @Path("/attendee/{id}") @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) public Attendee updateAttendee(@PathParam("id") String id, Attendee attendee) { Attendee original = getAttendee(id); original.setName(attendee.getName()); Attendee updated = selectedAttendeeDAO.updateAttendee(original); ...
65946712_2
public static Class<?> getReturnArrayType(Method method) { Class<?> returnType = method.getReturnType(); return returnType.getComponentType(); }
65947212_2
static int getItemSizeBytes(Map<String, AttributeValue> item) { try { int itemSize = 0; for (Entry<String, AttributeValue> entry : item.entrySet()) { itemSize += entry.getKey() != null ? entry.getKey().getBytes(CHARACTER_ENCODING).length : 0; itemSize += entry.getValue() != null ? getAttributeSize...
65963317_10
@Override public Object eval(final Reader reader, final ScriptContext context) throws ScriptException { return eval(readFully(reader), context); }
65973286_4
@Override public TableSchema getTableSchema() { return flinkSchema; }
65975333_76
public Object getData() { return data; }
65977170_25
@Override public String getContent() { String health = getHealth().getContent(); if (activeItem != null) { String item = activeItem.getItemSymbol(direction, activeItemUsage); return Direction.BACKWARD.equals(direction) ? item + content + health : health + content + item; } return Directi...
65980850_2
public Field fields() { return new Field(this); }
65993144_168
@Override public DestContextTypeMap resolveContext(DestContextsTypeMap destContexts) throws ConversionException { ContextInfo seqContextInfo = new ContextInfoBuilder() .setSequenceType(SequenceType.VIDEO) .setSequenceUuid(getSequenceUUID()) .build(); Integer width = getMinRe...
66000206_190
public static TimeValueBuilder builder() { return new TimeValueBuilder(); }
66020851_21
public static <T, U extends T> Builder<T, U> builder(Class<T> interfaceClass, U delegate) { return new Builder<>(interfaceClass, delegate); }
66027126_68
@Override public URI rewritten(URI location, HttpRequest<?> request) { // Note: this will look simpler when we switched to uri-toolkit // parse the given URI Uri uri = new LazyUri(new Precoded(location.toString())); // create updated ParameterList ParameterList parameters = uri.query().isPresent() ...
66062805_14
public static List<ColumnValue> eval(ShardEvalContext ctx, Set<String> shardColumns, boolean isRange) { return eval(ctx, shardColumns, isRange, false); }
66080823_11
@Override public boolean isPlaceholder(String pattern, int position) { return pattern.length() > position + 1 && pattern.charAt(position) == '{' && pattern.charAt(position + 1) == '}'; }
66136602_9
private static boolean unpackPackage(File ourDir, InputStream is, Map<String, String> md5List, CompressMode mode) { if (!ourDir.exists()) { return false; } boolean uncompressResult = false; if (mode == CompressMode.ZIP) { uncompressResult = FileUtils...
66157799_1
@TX public List<Team> listEqual(Integer rating) { return new Team().queryTeamsRatingEqualTo(rating); }
66187270_2
public static INDArray padWithEdge(INDArray src, int len) { int channel = src.size(0); int height = src.size(1); int width = src.size(2); INDArray dst = Nd4j.zeros(channel, height + len * 2, width + len * 2); for (int h = 0; h < dst.size(1); h++) { for (int w = 0; w < dst.size(2); w++) { ...
66192759_3
public String getTokenId() { return tokenId; }
66259813_6
public static <T> T from(Class<T> actionCreator) { Object creator = classCache.get(actionCreator); if (creator == null) { creator = createCreator(actionCreator); classCache.put(actionCreator, creator); } return (T) creator; }
66266995_14
int createNetwork(Params params) throws Exception { Log.d(Tag.NAME, "Get connected network id..."); int connectedNetId = getConnectedNetworkWithSsid(params.quotedSsid); if (connectedNetId != NO_ID) { Log.d(Tag.NAME, "Configured network found. It is connected"); return connectedNetId; } ...
66281816_15
public Disposable manageViewDisposable(@NonNull final Disposable disposable) { if (mUiDisposables == null) { throw new IllegalStateException("view disposable can't be handled" + " when there is no view"); } mUiDisposables.add(disposable); return disposable; }
66285950_133
@Override public void filter(final PlacementHostSelectionTaskState state, final Map<String, HostSelection> hostSelectionMap, final HostSelectionFilterCompletion callback) { //In case this is a clustering operation we want to continue even if desc._cluster <= 1 if (!isActive() && state.resourceC...
66303306_216
static <T> PeekingIterator<T> create(Iterator<T> iterator, Duration duration, long minimum) { return new TimeLimitedIterator<>(iterator, duration, minimum); }
66321621_1
public SampleActor() { receive(ReceiveBuilder. match(Double.class, d -> { sender().tell(d.isNaN() ? 0 : d, self()); }). match(Integer.class, i -> { sender().tell(i * 10, self()); }). match(String.class, s -> s.startsWith("guard"), s -> { sender().tell("startsWith(guard): " + s.to...
66343128_20
public static Builder builder() { return new Builder(); }
66507191_1
public ResponseContainer<List<Legislator>> fetchLegislatorListByCoordinates(Location location) { NetworkResponse<LegislatorResponse> networkResponse = NetworkExecutor.execute(mOkHttpClient, new GetLegislatorsByCoordinates(location), new JsonObjectResponseHandler<LegislatorResponse>() { @Override pub...
66541104_0
public static LoadPatchError record(int type, Exception e) { return new LoadPatchError(type, e); }
66551974_0
public static HintSQLInfo parserHintSQL(String sql){ if (sql == null) return null; HintSQLInfo hintSQLInfo = new HintSQLInfo(sql); Map<String,String> hintKv = new HashMap<String,String>(); int endIndex = sql.indexOf("*/"); if (endIndex !=-1 ){ String hintPart = sql.substring(0,endI...
66572810_1
@Override public HLAPITransaction getTransaction(TID hash) throws HLAPIException { try { ByteString result = query("getTran", Collections.singletonList(hash.toString())); byte[] resultStr = result.toByteArray(); if (resultStr.length == 0) return null; if (result.toString("UTF8").cont...
66596294_0
@Override public long add(long... operands) { long ret = 0; for (long operand : operands) { ret += operand; } return ret; }
66666501_63
@Override public int getNetworkTimeout() throws SQLException { throw error(); }
66676274_2347
public List<AfaTipoUsoMdto> pesquisar(Integer firstResult, Integer maxResult, String orderProperty, boolean asc, AfaTipoUsoMdto elemento) { return getAfaTipoUsoMdtoDAO().pesquisar(firstResult, maxResult, orderProperty, asc, elemento); }
66750234_31
public FeedModel transform(Feed entity){ FeedModel feed = new FeedModel(); feed.setImage(entity.getImage()); feed.setBody(entity.getBody()); feed.setTitle(entity.getTitle()); feed.setIndex(entity.getIndex()); return feed; }
66772740_9
@Override public int compareTo(ImagePlane o) { int tCompare = Integer.compare(t, o.t); if (tCompare != 0) return tCompare; int zCompare = Integer.compare(z, o.z); if (zCompare != 0) return zCompare; return Integer.compare(c, o.c); }
66814930_94
public static String stripTrailing(final String string, final char ch) { //// Preconditons if (string == null) { throw new InvalidParameterException("string cannot be null"); } int index = string.length(); if (index == 0) { return string; } while (true) { if (index == 0) { break; } ...
66862644_7
Dimension decodeBmpDimension(BufferedSource bmpSource) throws IOException { // Bmp stores in little endian bmpSource.skip(18); int w = bmpSource.readIntLe(); int h = bmpSource.readIntLe(); return new Dimension(w, h); }
66888160_0
public static void main(String args[]) { Options options = initOptions(); HelpFormatter formatter = new HelpFormatter(); CommandLineParser parser = new DefaultParser(); try { // parse the command line arguments CommandLine line = parser.parse(options, args); if (line.hasOption(H...
66918551_0
Future<HonoConnection> clientFactoryConnect(DisconnectListener<HonoConnection> disconnectHandler) { LOG.info("Connecting to IoT Hub messaging endpoint..."); clientFactory.addDisconnectListener(disconnectHandler); return clientFactory.connect(); }
66920833_2
public Class getJavaClass() { return javaClass; }
66977907_0
@Override public List<DotnetProjectDependency> getDependencies() { final List<DotnetProjectDependency> list = new ArrayList<>(); final NodeList packageRefElems = (NodeList) xpath("/Project/ItemGroup/PackageReference", XPathConstants.NODESET); if (packageRefElems != null && packageRefElems.getL...
67013967_7
boolean gradesContains(int grade) { return this.grades.contains(grade); }
67019969_205
@Override public DeleteRouteResult deleteRoute( DeleteRouteRequest deleteRouteRequest) { ExecutionContext executionContext = createExecutionContext( deleteRouteRequest); KscRequestMetrics kscRequestMetrics = executionContext .getKscRequestMetrics(); kscRequestMetrics.startEvent(Field.ClientExecuteTime); Req...
67037282_0
public static String format(Locale locale, Currency currency, double value) { NumberFormat format = NumberFormat.getCurrencyInstance(locale); format.setCurrency(currency); format.setMaximumFractionDigits(currency.getDefaultFractionDigits()); format.setGroupingUsed(true); String formatted = format.f...
67046748_0
public static int getLengthOfLongestWord(String string) { int longestWordLength = 0; Matcher m = Pattern.compile("\\s*(\\S+)", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE).matcher(string); while(m.find()) { longestWordLength = Math.max(longestWordLength, m.group(1).length()); } return longestWordLength; }
67053037_36
@Override public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable { for (ConditionalMethodHandler handler : delegateHandlers) { if (handler.supports(thisMethod)) { return handler.invoke(self, thisMethod, proceed, args); } } throw new IllegalStateException(String....
67059803_10
public static List<ResponseValue> filterMergeResults(List<ResponseValue> results, List<String> requestValues, int limit, SortType sort) { List<String> keepSet = requestValues == null ? new LinkedList<>() : requestValues; if (keepSet.size() > results.size()) ...