code
stringlengths
73
34.1k
label
stringclasses
1 value
private String getSuperMethodCallParameters(ExecutableElement sourceMethod) { return sourceMethod .getParameters() .stream() .map(parameter -> parameter.getSimpleName().toString()) .collect(Collectors.joining(", ")); }
java
private void addEmitEventCall(ExecutableElement originalMethod, MethodSpec.Builder proxyMethodBuilder, String methodCallParameters) { String methodName = "$emit"; if (methodCallParameters != null && !"".equals(methodCallParameters)) { proxyMethodBuilder.addStatement("vue().$L($S, $L)", met...
java
private boolean isHookMethod(TypeElement component, ExecutableElement method, Set<ExecutableElement> hookMethodsFromInterfaces) { if (hasAnnotation(method, HookMethod.class)) { validateHookMethod(method); return true; } for (ExecutableElement hookMethodsFromInterface : hookMethodsFromInte...
java
private String getNativeNameForJavaType(TypeMirror typeMirror) { TypeName typeName = TypeName.get(typeMirror); if (typeName.equals(TypeName.INT) || typeName.equals(TypeName.BYTE) || typeName.equals(TypeName.SHORT) || typeName.equals(TypeName.LONG) || typeName.equals(TypeName.FLO...
java
private void processInjectedFields(TypeElement component) { getInjectedFields(component).stream().peek(this::validateField).forEach(field -> { String fieldName = field.getSimpleName().toString(); addInjectedVariable(field, fieldName); injectedFieldsName.add(fieldName); }); }
java
private void processInjectedMethods(TypeElement component) { getInjectedMethods(component) .stream() .peek(this::validateMethod) .forEach(this::processInjectedMethod); }
java
private void addInjectedVariable(VariableElement element, String fieldName) { TypeName typeName = resolveVariableTypeName(element, messager); // Create field FieldSpec.Builder fieldBuilder = FieldSpec.builder(typeName, fieldName, Modifier.PUBLIC); // Copy field annotations element .getAnno...
java
public LocalVariableInfo addLocalVariable(String typeQualifiedName, String name) { return contextLayers.getFirst().addLocalVariable(typeQualifiedName, name); }
java
public DestructuredPropertyInfo addDestructuredProperty(String propertyType, String propertyName, LocalVariableInfo destructuredVariable) { return contextLayers.getFirst() .addDestructuredProperty(propertyType, propertyName, destructuredVariable); }
java
public VariableInfo findVariable(String name) { for (ContextLayer contextLayer : contextLayers) { VariableInfo variableInfo = contextLayer.getVariableInfo(name); if (variableInfo != null) { return variableInfo; } } return null; }
java
public void addImport(String fullyQualifiedName) { String[] importSplit = fullyQualifiedName.split("\\."); String className = importSplit[importSplit.length - 1]; classNameToFullyQualifiedName.put(className, fullyQualifiedName); }
java
public String getFullyQualifiedNameForClassName(String className) { if (!classNameToFullyQualifiedName.containsKey(className)) { return className; } return classNameToFullyQualifiedName.get(className); }
java
public void addStaticImport(String fullyQualifiedName) { String[] importSplit = fullyQualifiedName.split("\\."); String symbolName = importSplit[importSplit.length - 1]; methodNameToFullyQualifiedName.put(symbolName, fullyQualifiedName); propertyNameToFullyQualifiedName.put(symbolName, fullyQualifiedNa...
java
public String getFullyQualifiedNameForMethodName(String methodName) { if (!methodNameToFullyQualifiedName.containsKey(methodName)) { return methodName; } return methodNameToFullyQualifiedName.get(methodName); }
java
public String getFullyQualifiedNameForPropertyName(String propertyName) { if (!propertyNameToFullyQualifiedName.containsKey(propertyName)) { return propertyName; } return propertyNameToFullyQualifiedName.get(propertyName); }
java
public Optional<Integer> getCurrentLine() { if (currentSegment == null) { return Optional.empty(); } return Optional.of(currentSegment.getSource().getRow(currentSegment.getBegin())); }
java
@JsIgnore public static void initWithoutVueLib() { if (!isVueLibInjected()) { throw new RuntimeException( "Couldn't find Vue.js on init. Either include it Vue.js in your index.html or call VueGWT.init() instead of initWithoutVueLib."); } // Register custom observers for Collection and Map...
java
@JsIgnore public static void onReady(Runnable callback) { if (isReady) { callback.run(); return; } onReadyCallbacks.push(callback); }
java
public static void resolveRichTextField(ArrayResource array, CDAClient client) { for (CDAEntry entry : array.entries().values()) { ensureContentType(entry, client); for (CDAField field : entry.contentType().fields()) { if ("RichText".equals(field.type())) { resolveRichDocument(entry, f...
java
private static void resolveRichDocument(CDAEntry entry, CDAField field) { final Map<String, Object> rawValue = (Map<String, Object>) entry.rawFields().get(field.id()); if (rawValue == null) { return; } for (final String locale : rawValue.keySet()) { final Object raw = rawValue.get(locale); ...
java
private static void resolveRichLink(ArrayResource array, CDAEntry entry, CDAField field) { final Map<String, Object> rawValue = (Map<String, Object>) entry.rawFields().get(field.id()); if (rawValue == null) { return; } for (final String locale : rawValue.keySet()) { final CDARichDocument do...
java
private static void resolveOneLink(ArrayResource array, CDAField field, String locale, CDARichNode node) { if (node instanceof CDARichHyperLink && ((CDARichHyperLink) node).data instanceof Map) { final CDARichHyperLink link = (CDARichHyperLink) node; final Ma...
java
private static boolean isLink(Object data) { try { final Map<String, Object> map = (Map<String, Object>) data; final Map<String, Object> sys = (Map<String, Object>) map.get("sys"); final String type = (String) sys.get("type"); final String linkType = (String) sys.get("linkType"); final...
java
public <T> T getField(String locale, String key) { return localize(locale).getField(key); }
java
public Flowable<Transformed> one(String id) { try { return baseQuery() .one(id) .filter(new Predicate<CDAEntry>() { @Override public boolean test(CDAEntry entry) { return entry.contentType().id() .equals(contentTypeId); } ...
java
public CDACallback<Transformed> one(String id, CDACallback<Transformed> callback) { return Callbacks.subscribeAsync( baseQuery() .one(id) .filter(new Predicate<CDAEntry>() { @Override public boolean test(CDAEntry entry) { return entry.conte...
java
public Flowable<Collection<Transformed>> all() { return baseQuery() .all() .map( new Function<CDAArray, Collection<Transformed>>() { @Override public Collection<Transformed> apply(CDAArray array) { final ArrayList<Transformed> result = new Arra...
java
public CDACallback<Collection<Transformed>> all(CDACallback<Collection<Transformed>> callback) { return Callbacks.subscribeAsync( baseQuery() .all() .map( new Function<CDAArray, List<Transformed>>() { @Override public List<Transform...
java
@SuppressWarnings("unchecked") public <T> T getAttribute(String key) { return (T) attrs.get(key); }
java
public Flowable<CDAArray> all() { return client.cacheAll(false) .flatMap( new Function<Cache, Publisher<Response<CDAArray>>>() { @Override public Publisher<Response<CDAArray>> apply(Cache cache) { return client.service.array(client.spaceId, client.envi...
java
public static ImageOption jpegQualityOf(int quality) { if (quality < 1 || quality > 100) { throw new IllegalArgumentException("Quality has to be in the range from 1 to 100."); } return new ImageOption("q", Integer.toString(quality)); }
java
public String apply(String url) { return format( getDefault(), "%s%s%s=%s", url, concatenationOperator(url), operation, argument); }
java
@SuppressWarnings("unchecked") public <C extends CDACallback<CDASpace>> C fetchSpace(C callback) { return (C) Callbacks.subscribeAsync(observeSpace(), callback, this); }
java
public static void ensureContentType(CDAEntry entry, CDAClient client) { CDAContentType contentType = entry.contentType(); if (contentType != null) { return; } String contentTypeId = extractNested(entry.attrs(), "contentType", "sys", "id"); try { contentType = client.cacheTypeWithId(con...
java
@SuppressWarnings("unchecked") public <C extends CDACallback<CDAArray>> C all(C callback) { return (C) Callbacks.subscribeAsync(baseQuery().all(), callback, client); }
java
public static CamundaBpmProducer createProducer(final CamundaBpmEndpoint endpoint, final ParsedUri uri, final Map<String, Object> parameters) throws IllegalArgumentException { switch (uri.getType()) { case StartProcess: return new StartProcessProducer(endpoint, parameters); ...
java
protected void removeExcessiveInProgressTasks(Queue<Exchange> exchanges, int limit) { while (exchanges.size() > limit) { // must remove last Exchange exchange = exchanges.poll(); releaseTask(exchange); } }
java
@SuppressWarnings("rawtypes") public static Map<String, Object> prepareVariables(Exchange exchange, Map<String, Object> parameters) { Map<String, Object> processVariables = new HashMap<String, Object>(); Object camelBody = exchange.getIn().getBody(); if (camelBody instanceof String) { ...
java
@Override public void close() { if (closed) { return; } if (SHOULD_CHECK && !txn.isReadOnly()) { txn.checkReady(); } LIB.mdb_cursor_close(ptrCursor); kv.close(); closed = true; }
java
public long count() { if (SHOULD_CHECK) { checkNotClosed(); txn.checkReady(); } final NativeLongByReference longByReference = new NativeLongByReference(); checkRc(LIB.mdb_cursor_count(ptrCursor, longByReference)); return longByReference.longValue(); }
java
public boolean put(final T key, final T val, final PutFlags... op) { if (SHOULD_CHECK) { requireNonNull(key); requireNonNull(val); checkNotClosed(); txn.checkReady(); txn.checkWritesAllowed(); } kv.keyIn(key); kv.valIn(val); final int mask = mask(op); final int rc =...
java
public void renew(final Txn<T> newTxn) { if (SHOULD_CHECK) { requireNonNull(newTxn); checkNotClosed(); this.txn.checkReadOnly(); // existing newTxn.checkReadOnly(); newTxn.checkReady(); } checkRc(LIB.mdb_cursor_renew(newTxn.pointer(), ptrCursor)); this.txn = newTxn; }
java
public long runFor(final long duration, final TimeUnit unit) { final long deadline = System.currentTimeMillis() + unit.toMillis(duration); final ExecutorService es = Executors.newSingleThreadExecutor(); final Future<Long> future = es.submit(this); try { while (System.currentTimeMillis() < deadline...
java
public static Version version() { final IntByReference major = new IntByReference(); final IntByReference minor = new IntByReference(); final IntByReference patch = new IntByReference(); LIB.mdb_version(major, minor, patch); return new Version(major.intValue(), minor.intValue(), patch. ...
java
public void copy(final File path, final CopyFlags... flags) { requireNonNull(path); if (!path.exists()) { throw new InvalidCopyDestination("Path must exist"); } if (!path.isDirectory()) { throw new InvalidCopyDestination("Path must be a directory"); } final String[] files = path.list...
java
public List<byte[]> getDbiNames() { final List<byte[]> result = new ArrayList<>(); final Dbi<T> names = openDbi((byte[]) null); try (Txn<T> txn = txnRead(); Cursor<T> cursor = names.openCursor(txn)) { if (!cursor.first()) { return Collections.emptyList(); } do { fi...
java
public EnvInfo info() { if (closed) { throw new AlreadyClosedException(); } final MDB_envinfo info = new MDB_envinfo(RUNTIME); checkRc(LIB.mdb_env_info(ptr, info)); final long mapAddress; if (info.f0_me_mapaddr.get() == null) { mapAddress = 0; } else { mapAddress = info.f0...
java
public Stat stat() { if (closed) { throw new AlreadyClosedException(); } final MDB_stat stat = new MDB_stat(RUNTIME); checkRc(LIB.mdb_env_stat(ptr, stat)); return new Stat( stat.f0_ms_psize.intValue(), stat.f1_ms_depth.intValue(), stat.f2_ms_branch_pages.longValue(), ...
java
public void sync(final boolean force) { if (closed) { throw new AlreadyClosedException(); } final int f = force ? 1 : 0; checkRc(LIB.mdb_env_sync(ptr, f)); }
java
public Txn<T> txn(final Txn<T> parent, final TxnFlags... flags) { if (closed) { throw new AlreadyClosedException(); } return new Txn<>(this, parent, proxy, flags); }
java
@SuppressWarnings("checkstyle:ReturnCount") public static int compareBuff(final DirectBuffer o1, final DirectBuffer o2) { requireNonNull(o1); requireNonNull(o2); if (o1.equals(o2)) { return 0; } final int minLength = Math.min(o1.capacity(), o2.capacity()); final int minWords = minLength ...
java
public boolean delete(final T key) { try (Txn<T> txn = env.txnWrite()) { final boolean ret = delete(txn, key); txn.commit(); return ret; } }
java
public boolean delete(final Txn<T> txn, final T key) { return delete(txn, key, null); }
java
public Cursor<T> openCursor(final Txn<T> txn) { if (SHOULD_CHECK) { requireNonNull(txn); txn.checkReady(); } final PointerByReference cursorPtr = new PointerByReference(); checkRc(LIB.mdb_cursor_open(txn.pointer(), ptr, cursorPtr)); return new Cursor<>(cursorPtr.getValue(), txn); }
java
public Stat stat(final Txn<T> txn) { if (SHOULD_CHECK) { requireNonNull(txn); txn.checkReady(); } final MDB_stat stat = new MDB_stat(RUNTIME); checkRc(LIB.mdb_stat(txn.pointer(), ptr, stat)); return new Stat( stat.f0_ms_psize.intValue(), stat.f1_ms_depth.intValue(), ...
java
@Override public void close() { if (state == RELEASED) { return; } if (state == READY) { LIB.mdb_txn_abort(ptr); } keyVal.close(); state = RELEASED; }
java
protected String getNextLine(int newlineCount) throws IOException { if (newlineCount == 0) { return ""; } StringBuffer str = new StringBuffer(); int b; while (pis.available() > 0) { b = pis.read(); if (b == -1) { return ""; ...
java
public static Transport getTransport(SocketAddress addr) throws IOException { Transport trans; try { log.debug("Connecting TCP"); trans = TCPInstance(addr); if (!trans.test()) { throw new IOException("Agent is unreachable via TCP"); } ...
java
public static Transport TCPInstance(SocketAddress addr) throws IOException { Socket sock = new Socket(); sock.setSoTimeout(getTimeout()); sock.connect(addr); StreamTransport trans = new StreamTransport(); trans.setStreams(sock.getInputStream(), sock.getOutputStream()); t...
java
public static Transport UDPInstance(SocketAddress addr) throws IOException { DatagramSocket sock = new DatagramSocket(); sock.setSoTimeout(getTimeout()); sock.connect(addr); StreamTransport trans = new StreamTransport(); trans.setStreams(new UDPInputStream(sock), new UDPOutputSt...
java
public ProgressBar maxHint(long n) { if (n < 0) progress.setAsIndefinite(); else { progress.setAsDefinite(); progress.maxHint(n); } return this; }
java
public static <R, S> Tuple2<R, S> create(R r, S s) { return new Tuple2<R, S>(r, s); }
java
public static BigDecimal factorial(int n) { if (n < 0) { throw new ArithmeticException("Illegal factorial(n) for n < 0: n = " + n); } if (n < factorialCache.length) { return factorialCache[n]; } BigDecimal result = factorialCache[factorialCache.length - 1]; return result.multiply(factorialRecursion(f...
java
public static BigDecimal pi(MathContext mathContext) { checkMathContext(mathContext); BigDecimal result = null; synchronized (piCacheLock) { if (piCache != null && mathContext.getPrecision() <= piCache.precision()) { result = piCache; } else { piCache = piChudnovski(mathContext); return piCac...
java
public static BigDecimal e(MathContext mathContext) { checkMathContext(mathContext); BigDecimal result = null; synchronized (eCacheLock) { if (eCache != null && mathContext.getPrecision() <= eCache.precision()) { result = eCache; } else { eCache = exp(ONE, mathContext); return eCache; } ...
java
private BigRational multiply(BigDecimal value) { BigDecimal n = numerator.multiply(value); BigDecimal d = denominator; return of(n, d); }
java
public static BigRational valueOf(int integer, int fractionNumerator, int fractionDenominator) { if (fractionNumerator < 0 || fractionDenominator < 0) { throw new ArithmeticException("Negative value"); } BigRational integerPart = valueOf(integer); BigRational fractionPart = valueOf(fractionNumerator...
java
public static BigRational valueOf(double value) { if (value == 0.0) { return ZERO; } if (value == 1.0) { return ONE; } if (Double.isInfinite(value)) { throw new NumberFormatException("Infinite"); } if (Double.isNaN(value)) { throw new NumberFormatException("NaN"); } return val...
java
public static BigRational valueOf(String string) { String[] strings = string.split("/"); BigRational result = valueOfSimple(strings[0]); for (int i = 1; i < strings.length; i++) { result = result.divide(valueOfSimple(strings[i])); } return result; }
java
public static BigRational min(BigRational... values) { if (values.length == 0) { return BigRational.ZERO; } BigRational result = values[0]; for (int i = 1; i < values.length; i++) { result = result.min(values[i]); } return result; }
java
public static BigRational max(BigRational... values) { if (values.length == 0) { return BigRational.ZERO; } BigRational result = values[0]; for (int i = 1; i < values.length; i++) { result = result.max(values[i]); } return result; }
java
public BigComplex add(BigComplex value) { return valueOf( re.add(value.re), im.add(value.im)); }
java
public BigComplex subtract(BigComplex value) { return valueOf( re.subtract(value.re), im.subtract(value.im)); }
java
public BigComplex multiply(BigComplex value) { return valueOf( re.multiply(value.re).subtract(im.multiply(value.im)), re.multiply(value.im).add(im.multiply(value.re))); }
java
public BigDecimal absSquare(MathContext mathContext) { return re.multiply(re, mathContext).add(im.multiply(im, mathContext), mathContext); }
java
public BigComplex round(MathContext mathContext) { return valueOf(re.round(mathContext), im.round(mathContext)); }
java
public boolean strictEquals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; BigComplex other = (BigComplex) obj; return re.equals(other.re) && im.equals(other.im); }
java
protected BigRational getFactor(int index) { while (factors.size() <= index) { BigRational factor = getCurrentFactor(); factors.add(factor); calculateNextFactor(); } return factors.get(index); }
java
protected static DBFField createField(DataInput in, Charset charset, boolean useFieldFlags) throws IOException { DBFField field = new DBFField(); byte t_byte = in.readByte(); /* 0 */ if (t_byte == (byte) 0x0d) { return null; } byte[] fieldName = new byte[11]; in.readFully(fieldName, 1, 10); /* 1-10 */ ...
java
protected void write(DataOutput out, Charset charset) throws IOException { // Field Name out.write(this.name.getBytes(charset)); /* 0-10 */ out.write(new byte[11 - this.name.length()]); // data type out.writeByte(this.type.getCode()); /* 11 */ out.writeInt(0x00); /* 12-15 */ out.writeByte(this.length); /...
java
public void setName(String name) { if (name == null) { throw new IllegalArgumentException("Field name cannot be null"); } if (name.length() == 0 || name.length() > 10) { throw new IllegalArgumentException("Field name should be of length 0-10"); } if (!DBFUtils.isPureAscii(name)) { throw new IllegalA...
java
public void setType(DBFDataType type) { if (!type.isWriteSupported()) { throw new IllegalArgumentException("No support for writting " + type); } this.type = type; if (type.getDefaultSize() > 0) { this.length = type.getDefaultSize(); } }
java
public static Charset getCharsetByByte(int b) { switch (b) { case 0x01: // U.S. MS-DOS return forName("IBM437"); case 0x02: // International MS-DOS return forName("IBM850"); case 0x03: // Windows ANSI return forName("windows-1252"); case 0x04: // Standard Macintosh return forName("Mac...
java
public static int getDBFCodeForCharset(Charset charset) { if (charset == null) { return 0; } String charsetName = charset.toString(); if ("ibm437".equalsIgnoreCase(charsetName)) { return 0x01; } if ("ibm850".equalsIgnoreCase(charsetName)) { return 0x02; } if ("windows-1252".equalsIgnoreCase(ch...
java
public Date getLastModificationDate() { if (this.year == 0 || this.month == 0 || this.day == 0){ return null; } try { Calendar calendar = Calendar.getInstance(); calendar.set(this.year, this.month, this.day, 0, 0, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTime(); } catch (Ex...
java
public static Number readNumericStoredAsText(DataInputStream dataInput, int length) throws IOException { try { byte t_float[] = new byte[length]; int readed = dataInput.read(t_float); if (readed != length) { throw new EOFException("failed to read:" + length + " bytes"); } t_float = DBFUtils.removeS...
java
public static int littleEndian(int value) { int num1 = value; int mask = 0xff; int num2 = 0x00; num2 |= num1 & mask; for (int i = 1; i < 4; i++) { num2 <<= 8; mask <<= 8; num2 |= (num1 & mask) >> (8 * i); } return num2; }
java
public static byte[] doubleFormating(Number num, Charset charset, int fieldLength, int sizeDecimalPart) { int sizeWholePart = fieldLength - (sizeDecimalPart > 0 ? (sizeDecimalPart + 1) : 0); StringBuilder format = new StringBuilder(fieldLength); for (int i = 0; i < sizeWholePart-1; i++) { format.append("#"); ...
java
public static boolean contains(byte[] array, byte value) { if (array != null) { for (byte data : array) { if (data == value) { return true; } } } return false; }
java
public static boolean isPureAscii(String stringToCheck) { if (stringToCheck == null || stringToCheck.length() == 0) { return true; } synchronized (ASCII_ENCODER) { return ASCII_ENCODER.canEncode(stringToCheck); } }
java
public static boolean isPureAscii(byte[] data) { if (data == null) { return false; } for (byte b : data) { if (b < 0x20) { return false; } } return true; }
java
public static byte[] trimRightSpaces(byte[] b_array) { if (b_array == null || b_array.length == 0) { return new byte[0]; } int pos = getRightPos(b_array); int length = pos + 1; byte[] newBytes = new byte[length]; System.arraycopy(b_array, 0, newBytes, 0, length); return newBytes; }
java
public void setFields(DBFField[] fields) { if (this.closed) { throw new IllegalStateException("You can not set fields to a closed DBFWriter"); } if (this.header.fieldArray != null) { throw new DBFException("Fields has already been set"); } if (fields == null || fields.length == 0) { throw new DBFExce...
java
public void addRecord(Object[] values) { if (this.closed) { throw new IllegalStateException("You can add records a closed DBFWriter"); } if (this.header.fieldArray == null) { throw new DBFException("Fields should be set before adding records"); } if (values == null) { throw new DBFException("Null ca...
java
@Override public void close() { if (this.closed) { return; } this.closed = true; if (this.raf != null) { /* * everything is written already. just update the header for * record count and the END_OF_DATA mark */ try { this.header.numberOfRecords = this.recordCount; this.raf.seek(0);...
java
public String getString(int columnIndex) { if (columnIndex < 0 || columnIndex >= data.length) { throw new IllegalArgumentException("Invalid index field: (" + columnIndex+"). Valid range is 0 to " + (data.length - 1)); } Object fieldValue = data[columnIndex]; if (fieldValue == null) { return null; } ...
java
public BigDecimal getBigDecimal(int columnIndex) { Object fieldValue = data[columnIndex]; if (fieldValue == null) { return null; } if (fieldValue instanceof BigDecimal) { return (BigDecimal) fieldValue; } throw new DBFException("Unsupported type for BigDecimal at column:" + columnIndex + " " + fie...
java
public boolean getBoolean(int columnIndex) { Object fieldValue = data[columnIndex]; if (fieldValue == null) { return Boolean.FALSE; } if (fieldValue instanceof Boolean) { return (Boolean) fieldValue; } throw new DBFException("Unsupported type for Boolean at column:" + columnIndex + " " + fieldValu...
java
public Date getDate(int columnIndex) { Object fieldValue = data[columnIndex]; if (fieldValue == null) { return null; } if (fieldValue instanceof Date) { return (Date) fieldValue; } throw new DBFException( "Unsupported type for Date at column:" + columnIndex + " " + fieldValue.getClass().getCanonic...
java
public double getDouble(int columnIndex) { Object fieldValue = data[columnIndex]; if (fieldValue == null) { return 0.0; } if (fieldValue instanceof Number) { return ((Number) fieldValue).doubleValue(); } throw new DBFException("Unsupported type for Number at column:" + columnIndex + " " + fieldVal...
java