code
stringlengths
73
34.1k
label
stringclasses
1 value
public Observable<ServerTableAuditingPolicyInner> createOrUpdateAsync(String resourceGroupName, String serverName, ServerTableAuditingPolicyInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, parameters).map(new Func1<ServiceResponse<ServerTableAuditingPolicyInner>, ...
java
public Observable<ServerTableAuditingPolicyListResultInner> listByServerAsync(String resourceGroupName, String serverName) { return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<ServerTableAuditingPolicyListResultInner>, ServerTableAuditingPolicyListResultInne...
java
@Override public void register(Builder.Registry registry) { registry.add(new AzureAdTokenFactory()); registry.add(MediaContract.class, MediaExceptionProcessor.class); registry.add(MediaRestProxy.class); registry.add(OAuthFilter.class); registry.add(ResourceLocationManager.cl...
java
public void run() { try { ReceivePump.this.receiveAndProcess(); } catch (final Exception exception) { if (TRACE_LOGGER.isErrorEnabled()) { TRACE_LOGGER.error( String.format(Locale.US, "Receive pump for eventHub (%s), consumerGroup (%s), par...
java
public void receiveAndProcess() { if (this.shouldContinue()) { this.receiver.receive(this.onReceiveHandler.getMaxEventCount()) .handleAsync(this.processAndReschedule, this.executor); } else { if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.inf...
java
public static Authenticated authenticate(AzureTokenCredentials credentials) { return new AuthenticatedImpl(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializerAda...
java
public Observable<DataMaskingPolicyInner> getAsync(String resourceGroupName, String serverName, String databaseName) { return getWithServiceResponseAsync(resourceGroupName, serverName, databaseName).map(new Func1<ServiceResponse<DataMaskingPolicyInner>, DataMaskingPolicyInner>() { @Override ...
java
public Observable<Page<DscNodeConfigurationInner>> listByAutomationAccountNextAsync(final String nextPageLink) { return listByAutomationAccountNextWithServiceResponseAsync(nextPageLink) .map(new Func1<ServiceResponse<Page<DscNodeConfigurationInner>>, Page<DscNodeConfigurationInner>>() { ...
java
public Observable<List<AssemblyDefinitionInner>> listAsync(String resourceGroupName, String integrationAccountName) { return listWithServiceResponseAsync(resourceGroupName, integrationAccountName).map(new Func1<ServiceResponse<List<AssemblyDefinitionInner>>, List<AssemblyDefinitionInner>>() { @Overr...
java
static String parseRoleIdentifier(final String trackingId) { if (StringUtil.isNullOrWhiteSpace(trackingId) || !trackingId.contains(TRACKING_ID_TOKEN_SEPARATOR)) { return null; } return trackingId.substring(trackingId.indexOf(TRACKING_ID_TOKEN_SEPARATOR)); }
java
public static MySQLManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { return new MySQLManager(new RestClient.Builder() .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) .withCredentials(credentials) .withSerializ...
java
public void delete(String resourceGroupName, String automationAccountName, UUID jobScheduleId) { deleteWithServiceResponseAsync(resourceGroupName, automationAccountName, jobScheduleId).toBlocking().single().body(); }
java
public Observable<ApplicationInsightsComponentInner> getByResourceGroupAsync(String resourceGroupName, String resourceName) { return getByResourceGroupWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<ApplicationInsightsComponentInner>, ApplicationInsightsComponentInner>() ...
java
public static void validate(Object parameter) { // Validation of top level payload is done outside if (parameter == null) { return; } Class<?> type = parameter.getClass(); if (type == Double.class || type == Float.class || type == Long...
java
public Observable<DatabaseInner> getAsync(String resourceGroupName, String serverName, String databaseName, String expand) { return getWithServiceResponseAsync(resourceGroupName, serverName, databaseName, expand).map(new Func1<ServiceResponse<DatabaseInner>, DatabaseInner>() { @Override ...
java
public List<DatabaseInner> listByServer(String resourceGroupName, String serverName, String expand, String filter) { return listByServerWithServiceResponseAsync(resourceGroupName, serverName, expand, filter).toBlocking().single().body(); }
java
public JobExecutionInner get(String resourceGroupName, String serverName, String jobAgentName, String jobName, UUID jobExecutionId) { return getWithServiceResponseAsync(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId).toBlocking().single().body(); }
java
public Observable<VirtualNetworkRuleInner> getAsync(String resourceGroupName, String accountName, String virtualNetworkRuleName) { return getWithServiceResponseAsync(resourceGroupName, accountName, virtualNetworkRuleName).map(new Func1<ServiceResponse<VirtualNetworkRuleInner>, VirtualNetworkRuleInner>() { ...
java
public Observable<Void> cancelAsync(String resourceGroupName, String registryName, String buildId) { return cancelWithServiceResponseAsync(resourceGroupName, registryName, buildId).map(new Func1<ServiceResponse<Void>, Void>() { @Override public Void call(ServiceResponse<Void> response) {...
java
public void loadNextPage() { this.currentPage = cachedPage; cachedPage = null; this.items.addAll(currentPage.items()); cachePage(currentPage.nextPageLink()); }
java
protected void setCurrentPage(Page<E> currentPage) { this.currentPage = currentPage; List<E> retrievedItems = currentPage.items(); if (retrievedItems != null) { items.addAll(retrievedItems); } cachePage(currentPage.nextPageLink()); }
java
@Beta public void putCustomEventMapping(final String eventType, final Type eventDataType) { if (eventType == null || eventType.isEmpty()) { throw new IllegalArgumentException("eventType parameter is required and cannot be null or empty"); } if (eventDataType == null) { ...
java
@Beta public Type getCustomEventMapping(final String eventType) { if (!containsCustomEventMappingFor(eventType)) { return null; } else { return this.eventTypeToEventDataMapping.get(canonicalizeEventType(eventType)); } }
java
@Beta public boolean removeCustomEventMapping(final String eventType) { if (!containsCustomEventMappingFor(eventType)) { return false; } else { this.eventTypeToEventDataMapping.remove(canonicalizeEventType(eventType)); return true; } }
java
@Beta public boolean containsCustomEventMappingFor(final String eventType) { if (eventType == null || eventType.isEmpty()) { return false; } else { return this.eventTypeToEventDataMapping.containsKey(canonicalizeEventType(eventType)); } }
java
@Beta public EventGridEvent[] deserializeEventGridEvents(final String requestContent, final SerializerAdapter<ObjectMapper> serializerAdapter) throws IOException { EventGridEvent[] eventGridEvents = serializerAdapter.<EventGridEvent[]>deserialize(requestContent, EventGridEvent[].class); for (EventGr...
java
public Observable<ApplicationInsightsComponentAvailableFeaturesInner> getAsync(String resourceGroupName, String resourceName) { return getWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<ApplicationInsightsComponentAvailableFeaturesInner>, ApplicationInsightsComponentAvail...
java
public Observable<List<RestorableDroppedDatabaseInner>> listByServerAsync(String resourceGroupName, String serverName) { return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<RestorableDroppedDatabaseInner>>, List<RestorableDroppedDatabaseInner>>() { ...
java
public static ComputerVisionClient authenticate(ServiceClientCredentials credentials, String endpoint) { return authenticate("https://{endpoint}/vision/v2.0/", credentials) .withEndpoint(endpoint); }
java
public Observable<OperationStatus> deleteAsync(UUID appId, String versionId, int exampleId) { return deleteWithServiceResponseAsync(appId, versionId, exampleId).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() { @Override public OperationStatus call(ServiceResponse<Oper...
java
public static byte[] encodeURLWithoutPadding(byte[] src) { return src == null ? null : Base64.getUrlEncoder().withoutPadding().encode(src); }
java
public static String encodeToString(byte[] src) { return src == null ? null : Base64.getEncoder().encodeToString(src); }
java
public static byte[] decodeString(String encoded) { return encoded == null ? null : Base64.getDecoder().decode(encoded); }
java
public Observable<DatabaseSecurityAlertPolicyInner> getAsync(String resourceGroupName, String serverName, String databaseName) { return getWithServiceResponseAsync(resourceGroupName, serverName, databaseName).map(new Func1<ServiceResponse<DatabaseSecurityAlertPolicyInner>, DatabaseSecurityAlertPolicyInner>() { ...
java
public Observable<DatabaseSecurityAlertPolicyInner> createOrUpdateAsync(String resourceGroupName, String serverName, String databaseName, DatabaseSecurityAlertPolicyInner parameters) { return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, databaseName, parameters).map(new Func1<ServiceRes...
java
public static List<Class<?>> getAllClasses(Class<?> clazz) { List<Class<?>> types = new ArrayList<>(); while (clazz != null) { types.add(clazz); clazz = clazz.getSuperclass(); } return types; }
java
public static Type[] getTypeArguments(Type type) { if (!(type instanceof ParameterizedType)) { return new Type[0]; } return ((ParameterizedType) type).getActualTypeArguments(); }
java
public static Type getTypeArgument(Type type) { if (!(type instanceof ParameterizedType)) { return null; } return ((ParameterizedType) type).getActualTypeArguments()[0]; }
java
public static Type getSuperType(Type type) { if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; Type genericSuperClass = ((Class<?>) parameterizedType.getRawType()).getGenericSuperclass(); if (genericSuperClass instanceof ...
java
public static Type getSuperType(Type subType, Class<?> rawSuperType) { while (subType != null && getRawClass(subType) != rawSuperType) { subType = getSuperType(subType); } return subType; }
java
public static boolean isTypeOrSubTypeOf(Type subType, Type superType) { Class<?> sub = getRawClass(subType); Class<?> sup = getRawClass(superType); return sup.isAssignableFrom(sub); }
java
public static ParameterizedType createParameterizedType(Class<?> rawClass, Type... genericTypes) { return new ParameterizedType() { @Override public Type[] getActualTypeArguments() { return genericTypes; } @Override public Type getRawT...
java
public static Type getRestResponseBodyType(Type restResponseReturnType) { // if this type has type arguments, then we look at the last one to determine if it expects a body final Type[] restResponseTypeArguments = TypeUtil.getTypeArguments(restResponseReturnType); if (restResponseTypeArguments !...
java
int calculateCode(byte[] key, long tm) { // Allocating an array of bytes to represent the specified instant // of time. byte[] data = new byte[8]; long value = tm; // Converting the instant of time from the long representation to a // big-endian array of bytes (RFC42...
java
private boolean checkCode( String secret, long code, long timestamp, int window) { byte[] decodedKey = decodeSecret(secret); // convert unix time into a 30 second "window" as specified by the // TOTP specification. Using Google's default inter...
java
private int generateScratchCode() { while (true) { byte[] scratchCodeBuffer = new byte[BYTES_PER_SCRATCH_CODE]; secureRandom.nextBytes(scratchCodeBuffer); int scratchCode = calculateScratchCode(scratchCodeBuffer); if (scratchCode != SCRATCH_CODE_INVA...
java
private String calculateSecretKey(byte[] secretKey) { switch (config.getKeyRepresentation()) { case BASE32: return new Base32().encodeToString(secretKey); case BASE64: return new Base64().encodeToString(secretKey); default: ...
java
private ICredentialRepository getValidCredentialRepository() { ICredentialRepository repository = getCredentialRepository(); if (repository == null) { throw new UnsupportedOperationException( String.format("An instance of the %s service must be " + ...
java
public ICredentialRepository getCredentialRepository() { if (this.credentialRepositorySearched) return this.credentialRepository; this.credentialRepositorySearched = true; ServiceLoader<ICredentialRepository> loader = ServiceLoader.load(ICredentialRepository.class); ...
java
public static void buildMeta(Writer writer ,String indexType,String indexName, Object params,String action,ClientOptions clientOption,boolean upper7) throws IOException { if(params instanceof Map){ buildMapMeta( writer , indexType, indexName, (Map) params, action, clientOption, upper7); return; } Obje...
java
public boolean process() throws ResourceNotFoundException, ParseErrorException { if(processed) return true; synchronized(this) { if(processed) return true; data = null; errorCondition = null; Reader is = null; /* ...
java
public String addDateDocumentsNew(String indexName, String addTemplate, List<?> beans, String refreshOption) throws ElasticSearchException{ return addDateDocuments( indexName, _doc, addTemplate, beans, refreshOption); }
java
@Deprecated public static Map<String, String> getEscapeMapping(String in, Map<String, String> headers) { return getEscapeMapping(in, headers, false, 0, 0); }
java
private void openClient(String clusterName) { logger.info("Using ElasticSearch hostnames: {} ", Arrays.toString(serverAddresses)); Settings settings = null; Settings.Builder builder = Settings.builder(); if (this.elasticUser != null && !this.elasticUser.equals("")) { builder.put("cluster.name", clusterName) ...
java
public ClientInterface getRestClient(){ if(restClient == null) { synchronized (this) { if(restClient == null) { restClient = ElasticSearchHelper.getRestClientUtil(); } } } return restClient; }
java
public ClientInterface getConfigRestClient(String elasticsearchName,String configFile){ return ElasticSearchHelper.getConfigRestClientUtil(elasticsearchName,configFile); }
java
public void setStyleClass(int from, int to, String styleClass) { setStyle(from, to, Collections.singletonList(styleClass)); }
java
TwoDimensional.Position currentLine() { int parIdx = getCurrentParagraph(); Cell<Paragraph<PS, SEG, S>, ParagraphBox<PS, SEG, S>> cell = virtualFlow.getCell(parIdx); int lineIdx = cell.getNode().getCurrentLineIndex(caretSelectionBind.getUnderlyingCaret()); return paragraphLineNavigator.p...
java
final ParagraphBox.CaretOffsetX getCaretOffsetX(CaretNode caret) { return getCell(caret.getParagraphIndex()).getCaretOffsetX(caret); }
java
public Paragraph<PS, SEG, S> restyle(S style) { return new Paragraph<>(paragraphStyle, segmentOps, segments, StyleSpans.singleton(style, length())); }
java
public Paragraph<PS, SEG, S> setParagraphStyle(PS paragraphStyle) { return new Paragraph<>(paragraphStyle, segmentOps, segments, styles); }
java
public String getText() { if(text == null) { StringBuilder sb = new StringBuilder(length()); for(SEG seg: segments) sb.append(segmentOps.getText(seg)); text = sb.toString(); } return text; }
java
public Tuple2<ReadOnlyStyledDocument<PS, SEG, S>, ReadOnlyStyledDocument<PS, SEG, S>> split(int position) { return tree.locate(NAVIGATE, position).map(this::split); }
java
public Tuple2<ReadOnlyStyledDocument<PS, SEG, S>, ReadOnlyStyledDocument<PS, SEG, S>> split( int paragraphIndex, int columnPosition) { return tree.splitAt(paragraphIndex).map((l, p, r) -> { Paragraph<PS, SEG, S> p1 = p.trim(columnPosition); Paragraph<PS, SEG, S> p2 = p.subSeq...
java
public static <PS, SEG, S> ReadOnlyStyledDocument<PS, SEG, S> constructDocument( SegmentOps<SEG, S> segmentOps, PS defaultParagraphStyle, Consumer<ReadOnlyStyledDocumentBuilder<PS, SEG, S>> configuration) { ReadOnlyStyledDocumentBuilder<PS, SEG, S> builder = new ReadOnlyStyledDocumentBui...
java
public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraph(List<SEG> segments, StyleSpans<S> styles) { return addParagraph(segments, styles, null); }
java
public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraphs0(List<Tuple2<PS, List<SEG>>> paragraphArgList, StyleSpans<S> entireDocumentStyleSpans) { return addParagraphList(paragraphArgList, entireDocumentStyleSpans, Tuple2::get1, Tuple2::get2); }
java
private void moveContentBreaks(int numOfBreaks, BreakIterator breakIterator, boolean followingNotPreceding) { if (area.getLength() == 0) { return; } breakIterator.setText(area.getText()); if (followingNotPreceding) { breakIterator.following(getPosition()); ...
java
private void insertImage() { String initialDir = System.getProperty("user.dir"); FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Insert image"); fileChooser.setInitialDirectory(new File(initialDir)); File selectedFile = fileChooser.showOpenDialog(mainStage); ...
java
CharacterHit hitTextLine(CaretOffsetX x, int line) { return text.hitLine(x.value, line); }
java
CharacterHit hitText(CaretOffsetX x, double y) { return text.hit(x.value, y); }
java
@Override public void selectRangeExpl(int anchorParagraph, int anchorColumn, int caretParagraph, int caretColumn) { selectRangeExpl(textPosition(anchorParagraph, anchorColumn), textPosition(caretParagraph, caretColumn)); }
java
public static LogMonitor logMonitor() { return new LogMonitor() { @Override public void corruption(long bytes, String reason) { System.out.println(String.format("corruption of %s bytes: %s", bytes, reason)); } @Override ...
java
@Override public void seek(Slice targetKey) { if (restartCount == 0) { return; } int left = 0; int right = restartCount - 1; // binary search restart positions to find the restart position immediately before the targetKey while (left < right) { ...
java
private static BlockEntry readEntry(SliceInput data, BlockEntry previousEntry) { requireNonNull(data, "data is null"); // read entry header int sharedKeyLength = VariableLengthQuantity.readVariableLengthInt(data); int nonSharedKeyLength = VariableLengthQuantity.readVariableLengthInt...
java
public static boolean setCurrentFile(File databaseDir, long descriptorNumber) throws IOException { String manifest = descriptorFileName(descriptorNumber); String temp = tempFileName(descriptorNumber); File tempFile = new File(databaseDir, temp); writeStringToFileSync(man...
java
public boolean isBaseLevelForKey(Slice userKey) { // Maybe use binary search to find right entry instead of linear search? UserComparator userComparator = inputVersion.getInternalKeyComparator().getUserComparator(); for (int level = this.level + 2; level < NUM_LEVELS; level++) { ...
java
public boolean shouldStopBefore(InternalKey internalKey) { // Scan to find earliest grandparent file that contains key. InternalKeyComparator internalKeyComparator = inputVersion.getInternalKeyComparator(); while (grandparentIndex < grandparents.size() && internalKeyComparator.compare(intern...
java
public Slice copySlice(int index, int length) { checkPositionIndexes(index, index + length, this.length); index += offset; byte[] copiedArray = new byte[length]; System.arraycopy(data, index, copiedArray, 0, length); return new Slice(copiedArray); }
java
public Slice slice(int index, int length) { if (index == 0 && length == this.length) { return this; } checkPositionIndexes(index, index + length, this.length); if (index >= 0 && length == 0) { return Slices.EMPTY_SLICE; } return new Slice(data...
java
public ByteBuffer toByteBuffer(int index, int length) { checkPositionIndexes(index, index + length, this.length); index += offset; return ByteBuffer.wrap(data, index, length).order(LITTLE_ENDIAN); }
java
private LogChunkType readNextChunk() { // clear the current chunk currentChunk = Slices.EMPTY_SLICE; // read the next block if necessary if (currentBlock.available() < HEADER_SIZE) { if (!readNextBlock()) { if (eof) { return EOF; ...
java
private void reportCorruption(long bytes, String reason) { if (monitor != null) { monitor.corruption(bytes, reason); } }
java
private void reportDrop(long bytes, Throwable reason) { if (monitor != null) { monitor.corruption(bytes, reason); } }
java
public T get() throws InterruptedException { if (!valueReady.await((long) (timeout * 1000), TimeUnit.MILLISECONDS)) { String msg = String.format("BlockingVariable.get() timed out after %1.2f seconds", timeout); throw new SpockTimeoutError(timeout, msg); } return value; }
java
private void handleWhereBlock(Method method) { Block block = method.getLastBlock(); if (!(block instanceof WhereBlock)) return; new DeepBlockRewriter(this).visit(block); WhereBlockRewriter.rewrite((WhereBlock) block, this); }
java
private void handleFeatureIncludes(SpecInfo spec, IncludeExcludeCriteria criteria) { if (criteria.isEmpty()) return; for (FeatureInfo feature : spec.getAllFeatures()) if (hasAnyAnnotation(feature.getFeatureMethod(), criteria.annotations)) feature.setExcluded(false); }
java
@Override public void visitField(FieldNode gField) { PropertyNode owner = spec.getAst().getProperty(gField.getName()); if (gField.isStatic()) return; Field field = new Field(spec, gField, fieldCount++); field.setShared(AstUtil.hasAnnotation(gField, Shared.class)); field.setOwner(owner); spec....
java
private boolean constructorMayHaveBeenAddedByCompiler(ConstructorNode constructor) { Parameter[] params = constructor.getParameters(); Statement firstStat = constructor.getFirstStatement(); return AstUtil.isJointCompiled(spec.getAst()) && constructor.isPublic() && params != null && params.length == 0 ...
java
@Nullable public ExpressionStatement rewrite(ExpressionStatement stat) { try { if (!isInteraction(stat)) return null; createBuilder(); setCount(); setCall(); addResponses(); build(); return register(); } catch (InvalidSpecCompileException e) { resources.getErro...
java
private Object createEmptyWrapper(Class<?> type) { if (Number.class.isAssignableFrom(type)) { Method method = ReflectionUtil.getDeclaredMethodBySignature(type, "valueOf", String.class); if (method != null && method.getReturnType() == type) { return ReflectionUtil.invokeMethod(type, method, "0");...
java
@Deprecated public void await(int value, TimeUnit unit) throws Throwable { await(TimeUtil.toSeconds(value, unit)); }
java
private static RunContext createBottomContext() { File spockUserHome = SpockUserHomeUtil.getSpockUserHome(); DelegatingScript script = new ConfigurationScriptLoader(spockUserHome).loadAutoDetectedScript(); List<Class<?>> classes = new ExtensionClassesLoader().loadClassesFromDefaultLocation(); return new...
java
public static void closeQuietly(@Nullable final Socket... sockets) { if (sockets == null) return; for (Socket socket : sockets) { if (socket == null) return; try { socket.close(); } catch (IOException ignored) {} } }
java
public static String getText(Reader reader) throws IOException { try { StringBuilder source = new StringBuilder(); BufferedReader buffered = new BufferedReader(reader); String line = buffered.readLine(); while (line != null) { source.append(line); source.append('\n'); ...
java
public static OperatingSystem getCurrent() { String name = System.getProperty("os.name"); String version = System.getProperty("os.version"); String lowerName = name.toLowerCase(); if (lowerName.contains("linux")) return new OperatingSystem(name, version, Family.LINUX); if (lowerName.contains("mac os...
java
private boolean forbidUseOfSuperInFixtureMethod(MethodCallExpression expr) { Method currMethod = resources.getCurrentMethod(); Expression target = expr.getObjectExpression(); if (currMethod instanceof FixtureMethod && target instanceof VariableExpression && ((VariableExpression)target).isSu...
java
public static Throwable getRootCause(Throwable exception) { Assert.notNull(exception); return exception.getCause() == null ? exception : getRootCause(exception.getCause()); }
java
public static List<Throwable> getCauseChain(Throwable exception) { Assert.notNull(exception); List<Throwable> result = new ArrayList<>(); collectCauseChain(exception, result); return result; }
java
public static Type getArrayComponentType(Type type) { if (type instanceof Class) { Class<?> clazz = (Class<?>)type; return clazz.getComponentType(); } else if (type instanceof GenericArrayType) { GenericArrayType aType = (GenericArrayType) type; return aType.getGenericComponentType(); } else { retu...
java