_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q17700
Rechnungsmonat.letzterArbeitstag
train
public LocalDate letzterArbeitstag() { LocalDate tag = letzterTag(); switch (tag.getDayOfWeek()) { case SATURDAY: return tag.minusDays(1); case SUNDAY: return tag.minusDays(2); default: return tag; } }
java
{ "resource": "" }
q17701
Pipelines.pipeline
train
public static <T> Consumer<T> pipeline(Consumer<T> consumer) { return new PipelinedConsumer<T>(Iterations.iterable(consumer)); }
java
{ "resource": "" }
q17702
Pipelines.pipeline
train
public static <T> Consumer<T> pipeline(Consumer<T> former, Consumer<T> latter) { return new PipelinedConsumer<T>(Iterations.iterable(former, latter)); }
java
{ "resource": "" }
q17703
Pipelines.pipeline
train
public static <T> Consumer<T> pipeline(Consumer<T> first, Consumer<T> second, Consumer<T> third) { return new PipelinedConsumer<T>(Iterations.iterable(first, second, third)); }
java
{ "resource": "" }
q17704
Pipelines.pipeline
train
public static <T> Consumer<T> pipeline(Consumer<T>... actions) { return new PipelinedConsumer<T>(Iterations.iterable(actions)); }
java
{ "resource": "" }
q17705
Pipelines.pipeline
train
public static <T1, T2> BiConsumer<T1, T2> pipeline(BiConsumer<T1, T2> consumer) { return new PipelinedBinaryConsumer<T1, T2>(Iterations.iterable(consumer)); }
java
{ "resource": "" }
q17706
Pipelines.pipeline
train
public static <T1, T2> BiConsumer<T1, T2> pipeline(BiConsumer<T1, T2> former, BiConsumer<T1, T2> latter) { return new PipelinedBinaryConsumer<T1, T2>(Iterations.iterable(former, latter)); }
java
{ "resource": "" }
q17707
Pipelines.pipeline
train
public static <T1, T2> BiConsumer<T1, T2> pipeline(BiConsumer<T1, T2> first, BiConsumer<T1, T2> second, BiConsumer<T1, T2> third) { return new PipelinedBinaryConsumer<T1, T2>(Iterations.iterable(first, second, third)); }
java
{ "resource": "" }
q17708
Pipelines.pipeline
train
public static <T1, T2> BiConsumer<T1, T2> pipeline(BiConsumer<T1, T2>... actions) { return new PipelinedBinaryConsumer<T1, T2>(Iterations.iterable(actions)); }
java
{ "resource": "" }
q17709
Pipelines.pipeline
train
public static <T1, T2, T3> TriConsumer<T1, T2, T3> pipeline(TriConsumer<T1, T2, T3> consumer) { return new PipelinedTernaryConsumer<T1, T2, T3>(Iterations.iterable(consumer)); }
java
{ "resource": "" }
q17710
Pipelines.pipeline
train
public static <T1, T2, T3> TriConsumer<T1, T2, T3> pipeline(TriConsumer<T1, T2, T3> former, TriConsumer<T1, T2, T3> latter) { return new PipelinedTernaryConsumer<T1, T2, T3>(Iterations.iterable(former, latter)); }
java
{ "resource": "" }
q17711
Pipelines.pipeline
train
public static <T1, T2, T3> TriConsumer<T1, T2, T3> pipeline(TriConsumer<T1, T2, T3> first, TriConsumer<T1, T2, T3> second, TriConsumer<T1, T2, T3> third) { return new PipelinedTernaryConsumer<T1, T2, T3>(Iterations.iterable(first, second, third)); }
java
{ "resource": "" }
q17712
JCusparse.initialize
train
public static void initialize() { if (!initialized) { String libraryBaseName = "JCusparse-" + JCuda.getJCudaVersion(); String libraryName = LibUtils.createPlatformLibraryName(libraryBaseName); LibUtils.loadLibrary(libraryName); ...
java
{ "resource": "" }
q17713
JCusparse.checkResult
train
private static int checkResult(int result) { if (exceptionsEnabled && result != cusparseStatus.CUSPARSE_STATUS_SUCCESS) { throw new CudaException(cusparseStatus.stringFor(result)); } return result; }
java
{ "resource": "" }
q17714
JCusparse.cusparseCsrmvEx_bufferSize
train
public static int cusparseCsrmvEx_bufferSize( cusparseHandle handle, int alg, int transA, int m, int n, int nnz, Pointer alpha, int alphatype, cusparseMatDescr descrA, Pointer csrValA, int csrValAtype, ...
java
{ "resource": "" }
q17715
AbstractDecimal.add
train
public T add(T addend) { if (addend == null) { throw new IllegalArgumentException("invalid (null) addend"); } BigDecimal sum = this.value.add(addend.value); return newInstance(sum, sum.scale()); }
java
{ "resource": "" }
q17716
AbstractDecimal.subtract
train
public T subtract(T subtrahend) { if (subtrahend == null) { throw new IllegalArgumentException("invalid (null) subtrahend"); } BigDecimal difference = this.value.subtract(subtrahend.value); return newInstance(difference, difference.scale()); }
java
{ "resource": "" }
q17717
AbstractDecimal.multiply
train
public T multiply(T multiplier) { if (multiplier == null) { throw new IllegalArgumentException("invalid (null) multiplier"); } BigDecimal product = this.value.multiply(multiplier.value); return newInstance(product, this.value.scale()); }
java
{ "resource": "" }
q17718
AbstractDecimal.mod
train
public T mod(T modulus) { if (modulus == null) { throw new IllegalArgumentException("invalid (null) modulus"); } double difference = this.value.doubleValue() % modulus.doubleValue(); return newInstance(BigDecimal.valueOf(difference), this.value.scale()); }
java
{ "resource": "" }
q17719
AbstractDecimal.divide
train
public T divide(T divisor) { if (divisor == null) { throw new IllegalArgumentException("invalid (null) divisor"); } BigDecimal quotient = this.value.divide(divisor.value, ROUND_BEHAVIOR); return newInstance(quotient, this.value.scale()); }
java
{ "resource": "" }
q17720
MapperSourceGenerator.computeExtendedInterfaces
train
private static List<DAType> computeExtendedInterfaces(List<DAInterface> interfaces) { Optional<DAType> functionInterface = from(interfaces) .filter(DAInterfacePredicates.isGuavaFunction()) .transform(toDAType()) .filter(notNull()) .first(); if (functionInterface.isPresent()) { ...
java
{ "resource": "" }
q17721
ClassReloader.start
train
public static void start(String path) { classMonitor = new ClassReloader(path); Thread thread = new Thread(classMonitor, ClassReloader.class.getSimpleName()); thread.setDaemon(true); thread.start(); }
java
{ "resource": "" }
q17722
Parameter.toInteger
train
public static Integer toInteger(String parameterValue) { Integer result = null; if (isDigits(parameterValue)) result = Integer.valueOf(parameterValue); return result; }
java
{ "resource": "" }
q17723
Parameter.toInt
train
public static int toInt(String parameterValue) { int result = -1; if (isDigits(parameterValue)) result = Integer.parseInt(parameterValue); return result; }
java
{ "resource": "" }
q17724
Adresse.validate
train
public static void validate(Ort ort, String strasse, String hausnummer) { if (StringUtils.isBlank(strasse)) { throw new InvalidValueException(strasse, "street"); } validate(ort, strasse, hausnummer, VALIDATOR); }
java
{ "resource": "" }
q17725
Adresse.getStrasseKurz
train
public String getStrasseKurz() { if (PATTERN_STRASSE.matcher(strasse).matches()) { return strasse.substring(0, StringUtils.lastIndexOfIgnoreCase(strasse, "stra") + 3) + '.'; } else { return strasse; } }
java
{ "resource": "" }
q17726
Adresse.toMap
train
@Override public Map<String, Object> toMap() { Map<String, Object> map = new HashMap<>(); map.put("plz", getPLZ()); map.put("ortsname", getOrtsname()); map.put("strasse", getStrasse()); map.put("hausnummer", getHausnummer()); return map; }
java
{ "resource": "" }
q17727
DatamappingHelper.findDataMapping
train
public static Datamappingtype findDataMapping(Object data, String id, Datamappingstype dataMappingConfig) { if (null != data) { Class clazz = (Class) ((data instanceof Class) ? data : data.getClass()); for (Datamappingtype dt : dataMappingConfig.getDatamapping()) { if (dt.isRegex() &...
java
{ "resource": "" }
q17728
DatamappingHelper.getContainers
train
public static List<StartContainerConfig> getContainers(Class clazz) { if (!cacheSCC.containsKey(clazz)) { cacheSCC.put(clazz, new ArrayList<>(1)); ContainerStart cs = (ContainerStart) clazz.getAnnotation(ContainerStart.class); if (cs != null) { cacheSCC.get(clazz).add(fromCo...
java
{ "resource": "" }
q17729
DatamappingHelper.getElements
train
public static List<ElementConfig> getElements(Class clazz) { if (!cacheEC.containsKey(clazz)) { cacheEC.put(clazz, new ArrayList<>(1)); Element e = (Element) clazz.getAnnotation(Element.class); if (e != null) { cacheEC.get(clazz).add(fromAnnotation(e)); } E...
java
{ "resource": "" }
q17730
IBAN.getFormatted
train
public String getFormatted() { String input = this.getUnformatted() + " "; StringBuilder buf = new StringBuilder(); for (int i = 0; i < this.getUnformatted().length(); i+= 4) { buf.append(input, i, i+4); buf.append(' '); } return buf.toString().trim(); ...
java
{ "resource": "" }
q17731
IBAN.getLand
train
@SuppressWarnings({"squid:SwitchLastCaseIsDefaultCheck", "squid:S1301"}) public Locale getLand() { String country = this.getUnformatted().substring(0, 2); String language = country.toLowerCase(); switch (country) { case "AT": case "CH": language = "de"...
java
{ "resource": "" }
q17732
FachwertFactory.getFachwert
train
public Fachwert getFachwert(Class<? extends Fachwert> clazz, Object... args) { Class[] argTypes = toTypes(args); try { Constructor<? extends Fachwert> ctor = clazz.getConstructor(argTypes); return ctor.newInstance(args); } catch (ReflectiveOperationException ex) { ...
java
{ "resource": "" }
q17733
DocxService.loadPackage
train
@Programmatic public WordprocessingMLPackage loadPackage(final InputStream docxTemplate) throws LoadTemplateException { final WordprocessingMLPackage docxPkg; try { docxPkg = WordprocessingMLPackage.load(docxTemplate); } catch (final Docx4JException ex) { throw new Lo...
java
{ "resource": "" }
q17734
AbstractFieldStyler.makeField
train
@Override public PdfFormField makeField() throws IOException, DocumentException, VectorPrintException { switch (getFieldtype()) { case TEXT: return ((TextField) bf).getTextField(); case COMBO: return ((TextField) bf).getComboField(); case LIST: re...
java
{ "resource": "" }
q17735
Help.getParameterizables
train
public static <P extends Parameterizable> Set<P> getParameterizables(Package javaPackage, Class<P> clazz) throws IOException, FileNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { Set<P> parameterizables = new HashSet<>(50...
java
{ "resource": "" }
q17736
JamMetricsDependencyProcessor.deploy
train
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); ...
java
{ "resource": "" }
q17737
WaehrungenSingletonSpi.getDefaultProviderChain
train
@Override public List<String> getDefaultProviderChain() { List<String> list = new ArrayList<>(getProviderNames()); return list; }
java
{ "resource": "" }
q17738
WaehrungenSingletonSpi.getCurrencies
train
@Override public Set<CurrencyUnit> getCurrencies(CurrencyQuery query) { Set<CurrencyUnit> result = new HashSet<>(); for (Locale locale : query.getCountries()) { try { result.add(Waehrung.of(Currency.getInstance(locale))); } catch (IllegalArgumentException ex) ...
java
{ "resource": "" }
q17739
Consumers.all
train
public static <E> List<E> all(E[] array) { final Function<Iterator<E>, ArrayList<E>> consumer = new ConsumeIntoCollection<>(new ArrayListFactory<E>()); return consumer.apply(new ArrayIterator<>(array)); }
java
{ "resource": "" }
q17740
Consumers.dict
train
public static <K, V> Map<K, V> dict(Pair<K, V>... array) { final Function<Iterator<Pair<K, V>>, HashMap<K, V>> consumer = new ConsumeIntoMap<>(new HashMapFactory<K, V>()); return consumer.apply(new ArrayIterator<>(array)); }
java
{ "resource": "" }
q17741
Consumers.pipe
train
public static <E> void pipe(Iterator<E> iterator, OutputIterator<E> outputIterator) { new ConsumeIntoOutputIterator<>(outputIterator).apply(iterator); }
java
{ "resource": "" }
q17742
Consumers.pipe
train
public static <E> void pipe(Iterable<E> iterable, OutputIterator<E> outputIterator) { dbc.precondition(iterable != null, "cannot call pipe with a null iterable"); new ConsumeIntoOutputIterator<>(outputIterator).apply(iterable.iterator()); }
java
{ "resource": "" }
q17743
Consumers.pipe
train
public static <E> void pipe(E[] array, OutputIterator<E> outputIterator) { new ConsumeIntoOutputIterator<>(outputIterator).apply(new ArrayIterator<>(array)); }
java
{ "resource": "" }
q17744
Consumers.first
train
public static <E> E first(Iterator<E> iterator) { return new FirstElement<E>().apply(iterator); }
java
{ "resource": "" }
q17745
Consumers.first
train
public static <E> E first(Iterable<E> iterable) { dbc.precondition(iterable != null, "cannot call first with a null iterable"); return new FirstElement<E>().apply(iterable.iterator()); }
java
{ "resource": "" }
q17746
Consumers.first
train
public static <E> E first(E[] array) { return new FirstElement<E>().apply(new ArrayIterator<>(array)); }
java
{ "resource": "" }
q17747
DefaultElementProducer.createElementByStyler
train
public <E extends Element> E createElementByStyler(Collection<? extends BaseStyler> stylers, Object data, Class<E> clazz) throws VectorPrintException { // pdfptable, Section and others do not have a default constructor, a styler creates it E e = null; return styleHelper.style(e, data, stylers); }
java
{ "resource": "" }
q17748
DefaultElementProducer.createPhrase
train
public Phrase createPhrase(Object data, Collection<? extends BaseStyler> stylers) throws VectorPrintException { return initTextElementArray(styleHelper.style(new Phrase(Float.NaN), data, stylers), data, stylers); }
java
{ "resource": "" }
q17749
DefaultElementProducer.createParagraph
train
public Paragraph createParagraph(Object data, Collection<? extends BaseStyler> stylers) throws VectorPrintException { return initTextElementArray(styleHelper.style(new Paragraph(Float.NaN), data, stylers), data, stylers); }
java
{ "resource": "" }
q17750
DefaultElementProducer.createAnchor
train
public Anchor createAnchor(Object data, Collection<? extends BaseStyler> stylers) throws VectorPrintException { return initTextElementArray(styleHelper.style(new Anchor(Float.NaN), data, stylers), data, stylers); }
java
{ "resource": "" }
q17751
DefaultElementProducer.createListItem
train
public ListItem createListItem(Object data, Collection<? extends BaseStyler> stylers) throws VectorPrintException { return initTextElementArray(styleHelper.style(new ListItem(Float.NaN), data, stylers), data, stylers); }
java
{ "resource": "" }
q17752
DefaultElementProducer.makeImageTranslucent
train
public static BufferedImage makeImageTranslucent(BufferedImage source, float opacity) { if (opacity == 1) { return source; } BufferedImage translucent = new BufferedImage(source.getWidth(), source.getHeight(), BufferedImage.TRANSLUCENT); Graphics2D g = translucent.createGraphics(); ...
java
{ "resource": "" }
q17753
DefaultElementProducer.getIndex
train
@Override public Section getIndex(String title, int nesting, List<? extends BaseStyler> stylers) throws VectorPrintException, InstantiationException, IllegalAccessException { if (nesting < 1) { throw new VectorPrintException("chapter numbering starts with 1, wrong number: " + nesting); } i...
java
{ "resource": "" }
q17754
ComposableVisitor.visit
train
public void visit(Visitable visitable) { StreamSupport.stream(this.spliterator(), false).forEach(visitor -> visitor.visit(visitable)); }
java
{ "resource": "" }
q17755
br_broker.reboot
train
public static br_broker reboot(nitro_service client, br_broker resource) throws Exception { return ((br_broker[]) resource.perform_operation(client, "reboot"))[0]; }
java
{ "resource": "" }
q17756
br_broker.stop
train
public static br_broker stop(nitro_service client, br_broker resource) throws Exception { return ((br_broker[]) resource.perform_operation(client, "stop"))[0]; }
java
{ "resource": "" }
q17757
br_broker.force_reboot
train
public static br_broker force_reboot(nitro_service client, br_broker resource) throws Exception { return ((br_broker[]) resource.perform_operation(client, "force_reboot"))[0]; }
java
{ "resource": "" }
q17758
br_broker.force_stop
train
public static br_broker force_stop(nitro_service client, br_broker resource) throws Exception { return ((br_broker[]) resource.perform_operation(client, "force_stop"))[0]; }
java
{ "resource": "" }
q17759
br_broker.start
train
public static br_broker start(nitro_service client, br_broker resource) throws Exception { return ((br_broker[]) resource.perform_operation(client, "start"))[0]; }
java
{ "resource": "" }
q17760
CommitVisitor.visit
train
@Override public void visit(Visitable visitable) { if (isCommitable(visitable)) { ObjectUtils.setField(visitable, "lastModifiedBy", ((Auditable) visitable).getModifiedBy()); ObjectUtils.setField(visitable, "lastModifiedOn", ((Auditable) visitable).getModifiedOn()); ObjectUtils.setField(visitable...
java
{ "resource": "" }
q17761
CommitVisitor.isCommitable
train
protected boolean isCommitable(Object visitable) { return (visitable instanceof Auditable && (target == null || identity(visitable) == identity(target))); }
java
{ "resource": "" }
q17762
PrettySharedPreferences.apply
train
@TargetApi(Build.VERSION_CODES.GINGERBREAD) public void apply() { if (editing == null) { return; } try { editing.apply(); } catch (Exception ex) { editing.commit(); // Fallback in case low api lever. } editing = null; }
java
{ "resource": "" }
q17763
PrettySharedPreferences.commit
train
public boolean commit() { if (editing == null) { return false; } final boolean result = editing.commit(); editing = null; return result; }
java
{ "resource": "" }
q17764
sdxtools_image.get_filtered
train
public static sdxtools_image[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception { sdxtools_image obj = new sdxtools_image(); options option = new options(); option.set_filter(filter); sdxtools_image[] response = (sdxtools_image[]) obj.getfiltered(service, option); return respo...
java
{ "resource": "" }
q17765
ObjectFactoryReferenceHolder.set
train
public static synchronized void set(final ObjectFactory objectFactory) { Assert.state(objectFactoryReference == null, "The ObjectFactory reference is already set to ({0})", objectFactoryReference); objectFactoryReference = objectFactory; }
java
{ "resource": "" }
q17766
ns_ns_runningconfig.get
train
public static ns_ns_runningconfig get(nitro_service client, ns_ns_runningconfig resource) throws Exception { resource.validate("get"); return ((ns_ns_runningconfig[]) resource.get_resources(client))[0]; }
java
{ "resource": "" }
q17767
VictimsSQL.setUp
train
protected void setUp() throws SQLException { Connection connection = getConnection(); try { if (!isSetUp(connection)) { Statement stmt = connection.createStatement(); stmt.execute(Query.CREATE_TABLE_RECORDS); stmt.execute(Query.CREATE_TABLE_FIL...
java
{ "resource": "" }
q17768
VictimsSQL.statement
train
protected PreparedStatement statement(Connection connection, String query) throws SQLException { return connection.prepareStatement(query); }
java
{ "resource": "" }
q17769
VictimsSQL.setObjects
train
protected PreparedStatement setObjects(Connection connection, String query, Object... objects) throws SQLException { PreparedStatement ps = statement(connection, query); setObjects(ps, objects); return ps; }
java
{ "resource": "" }
q17770
VictimsSQL.selectRecordId
train
protected int selectRecordId(String hash) throws SQLException { int id = -1; Connection connection = getConnection(); try { PreparedStatement ps = setObjects(connection, Query.GET_RECORD_ID, hash); ResultSet rs = ps.executeQuery(); try { ...
java
{ "resource": "" }
q17771
VictimsSQL.insertRecord
train
protected int insertRecord(Connection connection, String hash) throws SQLException { int id = -1; PreparedStatement ps = setObjects(connection, Query.INSERT_RECORD, hash); ps.execute(); ResultSet rs = ps.getGeneratedKeys(); try { while (rs.next()) { ...
java
{ "resource": "" }
q17772
VictimsSQL.deleteRecord
train
protected void deleteRecord(Connection connection, String hash) throws SQLException { int id = selectRecordId(hash); if (id > 0) { String[] queries = new String[] { Query.DELETE_FILEHASHES, Query.DELETE_METAS, Query.DELETE_CVES, Query.DELET...
java
{ "resource": "" }
q17773
AbstractCacheableService.withCaching
train
protected VALUE withCaching(KEY key, Supplier<VALUE> cacheLoader) { return getCache() .map(CachingTemplate::with) .<VALUE>map(template -> template.withCaching(key, () -> { setCacheMiss(); return cacheLoader.get(); })) .orElseGet(cacheLoader); }
java
{ "resource": "" }
q17774
xen_websensevpx_image.get_filtered
train
public static xen_websensevpx_image[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception { xen_websensevpx_image obj = new xen_websensevpx_image(); options option = new options(); option.set_filter(filter); xen_websensevpx_image[] response = (xen_websensevpx_image[]) obj.getfiltere...
java
{ "resource": "" }
q17775
OrderedComparator.compare
train
@Override public int compare(final Ordered ordered1, final Ordered ordered2) { return (ordered1.getIndex() < ordered2.getIndex() ? -1 : (ordered1.getIndex() > ordered2.getIndex() ? 1 : 0)); }
java
{ "resource": "" }
q17776
RunnableUtils.safeSleep
train
private static boolean safeSleep(long milliseconds) { boolean interrupted = false; long timeout = (System.currentTimeMillis() + milliseconds); while (System.currentTimeMillis() < timeout) { try { Thread.sleep(milliseconds); } catch (InterruptedException cause) { interrup...
java
{ "resource": "" }
q17777
Threshold.accumulate
train
public void accumulate(List<? extends StandardMetricResult> metricValues) { if (metricValues == null || metricValues.isEmpty()) return; for (StandardMetricResult v : metricValues) { if (lastOffset < v.offset) values.put(v.value.intValue()); } lastOffset = ListUtils.last(metri...
java
{ "resource": "" }
q17778
Threshold.isExceeded
train
public boolean isExceeded() { lastAggregatedValue = getAggregatedValue(); lastExceededValue = false; switch (operator) { case lessThan: lastExceededValue = (lastAggregatedValue < thresholdValue); break; case greaterThan: lastExceededValue =...
java
{ "resource": "" }
q17779
Threshold.getReason
train
public String getReason() { if (lastExceededValue) { return String.format("Metric '%s' has aggregated-value=%d %s %d as threshold", metric.name(), lastAggregatedValue, operator.symbol, thresholdValue); } else { return String.format("Metric %s: aggregated-value=%d", metric.name(),...
java
{ "resource": "" }
q17780
ns_ssl_certkey_policy.get
train
public static ns_ssl_certkey_policy get(nitro_service client) throws Exception { ns_ssl_certkey_policy resource = new ns_ssl_certkey_policy(); resource.validate("get"); return ((ns_ssl_certkey_policy[]) resource.get_resources(client))[0]; }
java
{ "resource": "" }
q17781
Exceptions.rethrowConsumer
train
public static <T, E extends Throwable> @NonNull Consumer<T> rethrowConsumer(final @NonNull ThrowingConsumer<T, E> consumer) { return consumer; }
java
{ "resource": "" }
q17782
Exceptions.rethrowBiConsumer
train
public static <T, U, E extends Throwable> @NonNull BiConsumer<T, U> rethrowBiConsumer(final @NonNull ThrowingBiConsumer<T, U, E> consumer) { return consumer; }
java
{ "resource": "" }
q17783
Exceptions.rethrowFunction
train
public static <T, R, E extends Throwable> @NonNull Function<T, R> rethrowFunction(final @NonNull ThrowingFunction<T, R, E> function) { return function; }
java
{ "resource": "" }
q17784
Exceptions.rethrowBiFunction
train
public static <T, U, R, E extends Throwable> @NonNull BiFunction<T, U, R> rethrowBiFunction(final @NonNull ThrowingBiFunction<T, U, R, E> function) { return function; }
java
{ "resource": "" }
q17785
Exceptions.rethrowPredicate
train
public static <T, E extends Throwable> @NonNull Predicate<T> rethrowPredicate(final @NonNull ThrowingPredicate<T, E> predicate) { return predicate; }
java
{ "resource": "" }
q17786
Exceptions.rethrowRunnable
train
public static <E extends Throwable> @NonNull Runnable rethrowRunnable(final @NonNull ThrowingRunnable<E> runnable) { return runnable; }
java
{ "resource": "" }
q17787
Exceptions.rethrowSupplier
train
public static <T, E extends Throwable> @NonNull Supplier<T> rethrowSupplier(final @NonNull ThrowingSupplier<T, E> supplier) { return supplier; }
java
{ "resource": "" }
q17788
Exceptions.rethrow
train
public static <E extends Throwable> @NonNull RuntimeException rethrow(final @NonNull Throwable exception) throws E { throw (E) exception; }
java
{ "resource": "" }
q17789
Exceptions.unwrap
train
public static @NonNull Throwable unwrap(final @NonNull Throwable throwable) { if(throwable instanceof InvocationTargetException) { final /* @Nullable */ Throwable cause = throwable.getCause(); if(cause != null) { return cause; } } return throwable; }
java
{ "resource": "" }
q17790
ns_ns_savedconfig.get
train
public static ns_ns_savedconfig get(nitro_service client, ns_ns_savedconfig resource) throws Exception { resource.validate("get"); return ((ns_ns_savedconfig[]) resource.get_resources(client))[0]; }
java
{ "resource": "" }
q17791
VictimsResultCache.create
train
protected void create(File cache) throws VictimsException { try { FileUtils.forceMkdir(cache); } catch (IOException e) { throw new VictimsException("Could not create an on disk cache", e); } }
java
{ "resource": "" }
q17792
VictimsResultCache.purge
train
public void purge() throws VictimsException { try { File cache = new File(location); if (cache.exists()) { FileUtils.deleteDirectory(cache); } create(cache); } catch (IOException e) { throw new VictimsException("Could not purge ...
java
{ "resource": "" }
q17793
VictimsResultCache.hash
train
protected String hash(String key) throws VictimsException { try { MessageDigest mda = MessageDigest .getInstance(MessageDigestAlgorithms.SHA_256); return Hex.encodeHexString(mda.digest(key.getBytes())); } catch (NoSuchAlgorithmException e) { throw ...
java
{ "resource": "" }
q17794
VictimsResultCache.exists
train
public boolean exists(String key) { try { key = hash(key); return FileUtils.getFile(location, key).exists(); } catch (VictimsException e) { return false; } }
java
{ "resource": "" }
q17795
VictimsResultCache.delete
train
public void delete(String key) throws VictimsException { key = hash(key); try { FileUtils.forceDelete(FileUtils.getFile(location, key)); } catch (IOException e) { throw new VictimsException(String.format( "Could not delete the cached entry from disk: %...
java
{ "resource": "" }
q17796
VictimsResultCache.add
train
public void add(String key, Collection<String> cves) throws VictimsException { key = hash(key); if (exists(key)) { delete(key); } String result = ""; if (cves != null) { result = StringUtils.join(cves, ","); } try { ...
java
{ "resource": "" }
q17797
VictimsResultCache.get
train
public HashSet<String> get(String key) throws VictimsException { key = hash(key); try { HashSet<String> cves = new HashSet<String>(); String result = FileUtils.readFileToString( FileUtils.getFile(location, key)).trim(); for (String cve : StringUtil...
java
{ "resource": "" }
q17798
Base64.decode
train
public final static byte[] decode(byte[] sArr) { // Check special case int sLen = sArr.length; // Count illegal characters (including '\r', '\n') to know what size the returned array will be, // so we don't have to reallocate & copy it later. int sepCnt = 0; // Number of...
java
{ "resource": "" }
q17799
SelectionSort.sort
train
@Override public <E> List<E> sort(final List<E> elements) { for (int index = 0, size = elements.size(), length = (size - 1); index < length; index++) { int minIndex = index; for (int j = (index + 1); j < size; j++) { if (getOrderBy().compare(elements.get(j), elements.get(minIndex)) < 0) { ...
java
{ "resource": "" }