code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public static <E, R> R reduce(E[] array, BiFunction<R, E, R> function, R init) {
return new Reductor<>(function, init).apply(new ArrayIterator<E>(array));
} | java |
public static <E> boolean every(Iterable<E> iterable, Predicate<E> predicate) {
dbc.precondition(iterable != null, "cannot call every with a null iterable");
return new Every<E>(predicate).test(iterable.iterator());
} | java |
public static <E> boolean every(Iterator<E> iterator, Predicate<E> predicate) {
return new Every<E>(predicate).test(iterator);
} | java |
public static <E> boolean every(E[] array, Predicate<E> predicate) {
return new Every<E>(predicate).test(new ArrayIterator<E>(array));
} | java |
public static <E> int counti(Iterator<E> iterator) {
final long value = reduce(iterator, new Count<E>(), 0l);
dbc.state(value <= Integer.MAX_VALUE, "iterator size overflows an integer");
return (int) value;
} | java |
public void updateBestSolution(long time, double value, SolutionType newBestSolution){
times.add(time);
values.add(value);
bestSolution = newBestSolution;
} | java |
public static <T, U, R> Function<Pair<T, U>, R> tupled(BiFunction<T, U, R> function) {
dbc.precondition(function != null, "cannot apply a pair to a null function");
return pair -> function.apply(pair.first(), pair.second());
} | java |
public static <T, U> Predicate<Pair<T, U>> tupled(BiPredicate<T, U> predicate) {
dbc.precondition(predicate != null, "cannot apply a pair to a null predicate");
return pair -> predicate.test(pair.first(), pair.second());
} | java |
public static <T, U> Consumer<Pair<T, U>> tupled(BiConsumer<T, U> consumer) {
dbc.precondition(consumer != null, "cannot apply a pair to a null consumer");
return pair -> consumer.accept(pair.first(), pair.second());
} | java |
public static <T, U, V, R> Function<Triple<T, U, V>, R> tupled(TriFunction<T, U, V, R> function) {
dbc.precondition(function != null, "cannot apply a triple to a null function");
return triple -> function.apply(triple.first(), triple.second(), triple.third());
} | java |
public static <T, U, V> Predicate<Triple<T, U, V>> tupled(TriPredicate<T, U, V> predicate) {
dbc.precondition(predicate != null, "cannot apply a triple to a null predicate");
return triple -> predicate.test(triple.first(), triple.second(), triple.third());
} | java |
public static <T, U, V> Consumer<Triple<T, U, V>> tupled(TriConsumer<T, U, V> consumer) {
dbc.precondition(consumer != null, "cannot apply a triple to a null consumer");
return triple -> consumer.accept(triple.first(), triple.second(), triple.third());
} | java |
public ConnectorDescriptor removeAllNamespaces()
{
List<String> nameSpaceKeys = new ArrayList<String>();
java.util.Map<String, String> attributes = model.getAttributes();
for (Entry<String, String> e : attributes.entrySet())
{
final String name = e.getKey();
final String val... | java |
private void around(final CtMethod m, final String before, final String after, final List<VarDeclarationData> declarations) throws CannotCompileException, NotFoundException {
String signature = Modifier.toString(m.getModifiers()) + " " + m.getReturnType().getName() + " " + m.getLongName();
LOG.info("--- Instrumenti... | java |
public static <T> Iterable<T> oneTime(Iterator<T> iterator) {
return new OneTimeIterable<T>(iterator);
} | java |
public static <T> Iterator<T> iterator(T first, T second) {
return ArrayIterator.of(first, second);
} | java |
public static <T> Iterable<T> iterable(T first, T second) {
return ArrayIterable.of(first, second);
} | java |
@Override
public R apply(T1 first, T2 second) {
interceptor.before(first, second);
try {
return inner.apply(first, second);
} finally {
interceptor.after(first, second);
}
} | java |
@Deprecated
public static String validate(String blz) {
return VALIDATOR.validate(PackedDecimal.of(blz)).toString();
} | java |
@Override
public WeightedIndexEvaluation evaluate(SolutionType solution, DataType data) {
// initialize evaluation object
WeightedIndexEvaluation eval = new WeightedIndexEvaluation();
// add evaluations produced by contained objectives
weights.keySet().forEach(obj -> {
//... | java |
@Override
public <ActualSolutionType extends SolutionType> WeightedIndexEvaluation evaluate(Move<? super ActualSolutionType> move,
ActualSolutionType curSolution,
... | java |
@Override
public void serialize(Fachwert fachwert, JsonGenerator jgen, SerializerProvider provider) throws IOException {
serialize(fachwert.toMap(), jgen, provider);
} | java |
void configurePort(String port) {
if (StringUtils.isNotBlank(port)) {
try {
this.port = Integer.parseInt(port);
log.info("Using port {}", this.port);
} catch (NumberFormatException e) {
log.info("Unable to parse server PORT variable ({}). ... | java |
void configureClasses(String path) {
findClassesInClasspath();
if (StringUtils.isNotBlank(path)) {
// If the path is set, set up class reloading:
configureClassesReloadable(path);
}
packagePrefix = getValue(PACKAGE_PREFIX);
classesReloadable = classesUrl... | java |
private void configureAuthentication(String username, String password, String realm) {
// If the username is set, set up authentication:
if (StringUtils.isNotBlank(username)) {
this.username = username;
this.password = password;
this.realm = StringUtils.defaultIfBla... | java |
void showFilesConfiguration() {
// Message to communicate the resolved configuration:
String message;
if (filesUrl != null) {
String reload = filesReloadable ? "reloadable" : "non-reloadable";
message = "Files will be served from: " + filesUrl + " (" + reload + ")";
... | java |
void showClassesConfiguration() {
// Warning about a classes folder present in the classpath:
if (classesInClasspath != null) {
log.warn("Dynamic class reloading is disabled because a classes URL is present in the classpath. P"
+ "lease launch without including your clas... | java |
static String getValue(String key) {
String result = StringUtils.defaultIfBlank(System.getProperty(key), StringUtils.EMPTY);
result = StringUtils.defaultIfBlank(result, System.getenv(key));
return result;
} | java |
@Override
public boolean isValid(T wert) {
int length = Objects.toString(wert, "").length();
return (length >= min) && (length <= max);
} | java |
public Analysis<SolutionType> setNumRuns(String searchID, int n){
if(!searches.containsKey(searchID)){
throw new UnknownIDException("No search with ID " + searchID + " has been added.");
}
if(n <= 0){
throw new IllegalArgumentException("Number of runs should be strictly p... | java |
public Analysis<SolutionType> setNumBurnIn(String searchID, int n){
if(!searches.containsKey(searchID)){
throw new UnknownIDException("No search with ID " + searchID + " has been added.");
}
if(n <= 0){
throw new IllegalArgumentException("Number of burn-in runs should be ... | java |
public Analysis<SolutionType> addProblem(String ID, Problem<SolutionType> problem){
if(problem == null){
throw new NullPointerException("Problem can not be null.");
}
if(problems.containsKey(ID)){
throw new DuplicateIDException("Duplicate problem ID: " + ID + ".");
... | java |
public Analysis<SolutionType> addSearch(String ID, SearchFactory<SolutionType> searchFactory){
if(searchFactory == null){
throw new NullPointerException("Search factory can not be null.");
}
if(searches.containsKey(ID)){
throw new DuplicateIDException("Duplicate search ID... | java |
public AnalysisResults<SolutionType> run(){
// create results object
AnalysisResults<SolutionType> results = new AnalysisResults<>();
// log
LOGGER.info(ANALYSIS_MARKER,
"Started analysis of {} problems {} using {} searches {}.",
... | java |
public int run() {
try {
if ( compile )
{
compile();
}
String separator = "/";
String cpseperator = ":";
if (System.getProperty("os.name").contains("indows")){
separator = "\\";
cpseperator = ";";
}
String s = fileName.replace(separator, ".");
if ( ".java".equals(s.s... | java |
@Override
public void link(NGScope scope, JQElement element, JSON attrs) {
ImageResource resource = scope.get(getName());
if (resource == null) {
LOG.log(Level.WARNING, "Mandatory attribute " + getName() + " value is mssing");
return;
}
Image image = new Image... | java |
@Override
public Map<String, Object> toMap() {
Map<String, Object> map = new HashMap<>();
map.put("kontoinhaber", getKontoinhaber());
map.put("iban", getIban());
getBic().ifPresent(b -> map.put("bic", b));
return map;
} | java |
public static String repeat(char source, int times) {
dbc.precondition(times > -1, "times must be non negative");
final char[] array = new char[times];
Arrays.fill(array, source);
return new String(array);
} | java |
public static String repeat(String source, int times) {
dbc.precondition(source != null, "cannot repeat a null source");
dbc.precondition(times > -1, "times must be non negative");
final int srcLen = source.length();
final long longLen = times * (long) srcLen;
final int len = (in... | java |
public static Nummer of(long code) {
if ((code >= 0) && (code < CACHE.length)) {
return CACHE[(int) code];
} else {
return new Nummer(code);
}
} | java |
public static String validate(String nummer) {
try {
return new BigInteger(nummer).toString();
} catch (NumberFormatException nfe) {
throw new InvalidValueException(nummer, "number");
}
} | java |
@Override
public Optional<E> next() {
if (iterator.hasNext()) {
return Optional.of(iterator.next());
}
return Optional.empty();
} | java |
public LocalDate ersterArbeitstag() {
LocalDate tag = ersterTag();
switch (tag.getDayOfWeek()) {
case SATURDAY:
return tag.plusDays(2);
case SUNDAY:
return tag.plusDays(1);
default:
return tag;
}
} | java |
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 |
public static <T> Consumer<T> pipeline(Consumer<T> consumer) {
return new PipelinedConsumer<T>(Iterations.iterable(consumer));
} | java |
public static <T> Consumer<T> pipeline(Consumer<T> former, Consumer<T> latter) {
return new PipelinedConsumer<T>(Iterations.iterable(former, latter));
} | java |
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 |
public static <T> Consumer<T> pipeline(Consumer<T>... actions) {
return new PipelinedConsumer<T>(Iterations.iterable(actions));
} | java |
public static <T1, T2> BiConsumer<T1, T2> pipeline(BiConsumer<T1, T2> consumer) {
return new PipelinedBinaryConsumer<T1, T2>(Iterations.iterable(consumer));
} | java |
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 |
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 |
public static <T1, T2> BiConsumer<T1, T2> pipeline(BiConsumer<T1, T2>... actions) {
return new PipelinedBinaryConsumer<T1, T2>(Iterations.iterable(actions));
} | java |
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 |
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 |
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 |
public static void initialize()
{
if (!initialized)
{
String libraryBaseName = "JCusparse-" + JCuda.getJCudaVersion();
String libraryName =
LibUtils.createPlatformLibraryName(libraryBaseName);
LibUtils.loadLibrary(libraryName);
... | java |
private static int checkResult(int result)
{
if (exceptionsEnabled && result !=
cusparseStatus.CUSPARSE_STATUS_SUCCESS)
{
throw new CudaException(cusparseStatus.stringFor(result));
}
return result;
} | java |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
public static void start(String path) {
classMonitor = new ClassReloader(path);
Thread thread = new Thread(classMonitor, ClassReloader.class.getSimpleName());
thread.setDaemon(true);
thread.start();
} | java |
public static Integer toInteger(String parameterValue) {
Integer result = null;
if (isDigits(parameterValue))
result = Integer.valueOf(parameterValue);
return result;
} | java |
public static int toInt(String parameterValue) {
int result = -1;
if (isDigits(parameterValue))
result = Integer.parseInt(parameterValue);
return result;
} | java |
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 |
public String getStrasseKurz() {
if (PATTERN_STRASSE.matcher(strasse).matches()) {
return strasse.substring(0, StringUtils.lastIndexOfIgnoreCase(strasse, "stra") + 3) + '.';
} else {
return strasse;
}
} | java |
@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 |
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 |
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 |
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 |
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 |
@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 |
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 |
@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 |
@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 |
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 |
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
... | java |
@Override
public List<String> getDefaultProviderChain() {
List<String> list = new ArrayList<>(getProviderNames());
return list;
} | java |
@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 |
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 |
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 |
public static <E> void pipe(Iterator<E> iterator, OutputIterator<E> outputIterator) {
new ConsumeIntoOutputIterator<>(outputIterator).apply(iterator);
} | java |
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 |
public static <E> void pipe(E[] array, OutputIterator<E> outputIterator) {
new ConsumeIntoOutputIterator<>(outputIterator).apply(new ArrayIterator<>(array));
} | java |
public static <E> E first(Iterator<E> iterator) {
return new FirstElement<E>().apply(iterator);
} | java |
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 |
public static <E> E first(E[] array) {
return new FirstElement<E>().apply(new ArrayIterator<>(array));
} | java |
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 |
public Phrase createPhrase(Object data, Collection<? extends BaseStyler> stylers) throws VectorPrintException {
return initTextElementArray(styleHelper.style(new Phrase(Float.NaN), data, stylers), data, stylers);
} | java |
public Paragraph createParagraph(Object data, Collection<? extends BaseStyler> stylers) throws VectorPrintException {
return initTextElementArray(styleHelper.style(new Paragraph(Float.NaN), data, stylers), data, stylers);
} | java |
public Anchor createAnchor(Object data, Collection<? extends BaseStyler> stylers) throws VectorPrintException {
return initTextElementArray(styleHelper.style(new Anchor(Float.NaN), data, stylers), data, stylers);
} | java |
public ListItem createListItem(Object data, Collection<? extends BaseStyler> stylers) throws VectorPrintException {
return initTextElementArray(styleHelper.style(new ListItem(Float.NaN), data, stylers), data, stylers);
} | java |
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 |
@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 |
public void visit(Visitable visitable) {
StreamSupport.stream(this.spliterator(), false).forEach(visitor -> visitor.visit(visitable));
} | java |
public static br_broker reboot(nitro_service client, br_broker resource) throws Exception
{
return ((br_broker[]) resource.perform_operation(client, "reboot"))[0];
} | java |
public static br_broker stop(nitro_service client, br_broker resource) throws Exception
{
return ((br_broker[]) resource.perform_operation(client, "stop"))[0];
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.