code stringlengths 73 34.1k | label stringclasses 1 value |
|---|---|
public void updateBuildpackInstallations(String appName, List<String> buildpacks) {
connection.execute(new BuildpackInstallationUpdate(appName, buildpacks), apiKey);
} | java |
static Artifact resolveConstrained(MavenProject project, String gav, Pattern versionRegex,
ArtifactResolver resolver)
throws VersionRangeResolutionException, ArtifactResolutionException {
boolean latest = gav.endsWith(":LATEST");
if (latest || gav.endsWith(":RELEASE")) {
Artifact a = new DefaultArtifact(gav);
if (latest) {
versionRegex = versionRegex == null ? ANY : versionRegex;
} else {
versionRegex = versionRegex == null ? ANY_NON_SNAPSHOT : versionRegex;
}
String upTo = project.getGroupId().equals(a.getGroupId()) && project.getArtifactId().equals(a.getArtifactId())
? project.getVersion()
: null;
return resolver.resolveNewestMatching(gav, upTo, versionRegex, latest, latest);
} else {
String projectGav = getProjectArtifactCoordinates(project, null);
Artifact ret = null;
if (projectGav.equals(gav)) {
ret = findProjectArtifact(project);
}
return ret == null ? resolver.resolveArtifact(gav) : ret;
}
} | java |
public static <X> ServiceTypeLoader<X> load(Class<X> serviceType) {
return load(serviceType, Thread.currentThread().getContextClassLoader());
} | java |
public static String stringifyJavascriptObject(Object object) {
StringBuilder bld = new StringBuilder();
stringify(object, bld);
return bld.toString();
} | java |
@Nullable
@SuppressWarnings("unchecked")
protected <T extends JavaElement> ActiveElements<T> popIfActive() {
return (ActiveElements<T>) (!activations.isEmpty() && activations.peek().depth == depth ? activations.pop() :
null);
} | java |
@Nonnull
public static Builder builder(Revapi revapi) {
List<String> knownExtensionIds = new ArrayList<>();
addExtensionIds(revapi.getPipelineConfiguration().getApiAnalyzerTypes(), knownExtensionIds);
addExtensionIds(revapi.getPipelineConfiguration().getTransformTypes(), knownExtensionIds);
addExtensionIds(revapi.getPipelineConfiguration().getFilterTypes(), knownExtensionIds);
addExtensionIds(revapi.getPipelineConfiguration().getReporterTypes(), knownExtensionIds);
return new Builder(knownExtensionIds);
} | java |
public AnalysisContext copyWithConfiguration(ModelNode configuration) {
return new AnalysisContext(this.locale, configuration, this.oldApi, this.newApi, this.data);
} | java |
public static PipelineConfiguration.Builder parse(ModelNode json) {
ModelNode analyzerIncludeNode = json.get("analyzers").get("include");
ModelNode analyzerExcludeNode = json.get("analyzers").get("exclude");
ModelNode filterIncludeNode = json.get("filters").get("include");
ModelNode filterExcludeNode = json.get("filters").get("exclude");
ModelNode transformIncludeNode = json.get("transforms").get("include");
ModelNode transformExcludeNode = json.get("transforms").get("exclude");
ModelNode reporterIncludeNode = json.get("reporters").get("include");
ModelNode reporterExcludeNode = json.get("reporters").get("exclude");
return builder()
.withTransformationBlocks(json.get("transformBlocks"))
.withAnalyzerExtensionIdsInclude(asStringList(analyzerIncludeNode))
.withAnalyzerExtensionIdsExclude(asStringList(analyzerExcludeNode))
.withFilterExtensionIdsInclude(asStringList(filterIncludeNode))
.withFilterExtensionIdsExclude(asStringList(filterExcludeNode))
.withTransformExtensionIdsInclude(asStringList(transformIncludeNode))
.withTransformExtensionIdsExclude(asStringList(transformExcludeNode))
.withReporterExtensionIdsInclude(asStringList(reporterIncludeNode))
.withReporterExtensionIdsExclude(asStringList(reporterExcludeNode));
} | java |
private static void firstDotConstellation(int[] dollarPositions, int[] dotPositions, int nestingLevel) {
int i = 0;
int unassigned = dotPositions.length - nestingLevel;
for (; i < unassigned; ++i) {
dotPositions[i] = -1;
}
for (; i < dotPositions.length; ++i) {
dotPositions[i] = dollarPositions[i];
}
} | java |
public static AnalysisResult fakeSuccess() {
return new AnalysisResult(null, new Extensions(Collections.emptyMap(), Collections.emptyMap(),
Collections.emptyMap(), Collections.emptyMap()));
} | java |
static PlexusConfiguration convert(ModelNode configuration, ModelNode jsonSchema, String extensionId, String id) {
ConversionContext ctx = new ConversionContext();
ctx.currentSchema = jsonSchema;
ctx.rootSchema = jsonSchema;
ctx.pushTag(extensionId);
ctx.id = id;
return convert(configuration, ctx);
} | java |
@SuppressWarnings("unchecked")
public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
for (Annotation annotation : this.annotations) {
if (annotation.annotationType().equals(annotationType)) {
return (T) annotation;
}
}
for (Annotation metaAnn : this.annotations) {
T ann = metaAnn.annotationType().getAnnotation(annotationType);
if (ann != null) {
return ann;
}
}
return null;
} | java |
public static String encodeScheme(String scheme, String encoding) throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(scheme, encoding, HierarchicalUriComponents.Type.SCHEME);
} | java |
public static String encodeAuthority(String authority, String encoding) throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(authority, encoding, HierarchicalUriComponents.Type.AUTHORITY);
} | java |
public static String encodeUserInfo(String userInfo, String encoding) throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(userInfo, encoding, HierarchicalUriComponents.Type.USER_INFO);
} | java |
public static String encodeHost(String host, String encoding) throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(host, encoding, HierarchicalUriComponents.Type.HOST_IPV4);
} | java |
public static String encodePort(String port, String encoding) throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(port, encoding, HierarchicalUriComponents.Type.PORT);
} | java |
public static String encodePath(String path, String encoding) throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(path, encoding, HierarchicalUriComponents.Type.PATH);
} | java |
public static String encodePathSegment(String segment, String encoding) throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(segment, encoding, HierarchicalUriComponents.Type.PATH_SEGMENT);
} | java |
public static String encodeQuery(String query, String encoding) throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(query, encoding, HierarchicalUriComponents.Type.QUERY);
} | java |
public static String encodeQueryParam(String queryParam, String encoding) throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(queryParam, encoding, HierarchicalUriComponents.Type.QUERY_PARAM);
} | java |
public static String encodeFragment(String fragment, String encoding) throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(fragment, encoding, HierarchicalUriComponents.Type.FRAGMENT);
} | java |
public void setReadTimeout(int readTimeout) {
this.client = this.client.newBuilder()
.readTimeout(readTimeout, TimeUnit.MILLISECONDS)
.build();
} | java |
public void setWriteTimeout(int writeTimeout) {
this.client = this.client.newBuilder()
.writeTimeout(writeTimeout, TimeUnit.MILLISECONDS)
.build();
} | java |
public void setConnectTimeout(int connectTimeout) {
this.client = this.client.newBuilder()
.connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
.build();
} | java |
public void addComparator(Comparator<T> comparator, boolean ascending) {
this.comparators.add(new InvertibleComparator<T>(comparator, ascending));
} | java |
public static void copy(String in, Writer out) throws IOException {
Assert.notNull(in, "No input String specified");
Assert.notNull(out, "No Writer specified");
try {
out.write(in);
}
finally {
try {
out.close();
}
catch (IOException ex) {
}
}
} | java |
public boolean matches(String uri) {
if (uri == null) {
return false;
}
Matcher matcher = this.matchPattern.matcher(uri);
return matcher.matches();
} | java |
public boolean exists() {
// Try file existence: can we find the file in the file system?
try {
return getFile().exists();
}
catch (IOException ex) {
// Fall back to stream existence: can we open the stream?
try {
InputStream is = getInputStream();
is.close();
return true;
}
catch (Throwable isEx) {
return false;
}
}
} | java |
static String expandUriComponent(String source, UriTemplateVariables uriVariables) {
if (source == null) {
return null;
}
if (source.indexOf('{') == -1) {
return source;
}
Matcher matcher = NAMES_PATTERN.matcher(source);
StringBuffer sb = new StringBuffer();
while (matcher.find()) {
String match = matcher.group(1);
String variableName = getVariableName(match);
Object variableValue = uriVariables.getValue(variableName);
if (UriTemplateVariables.SKIP_VALUE.equals(variableValue)) {
continue;
}
String variableValueString = getVariableValueAsString(variableValue);
String replacement = Matcher.quoteReplacement(variableValueString);
matcher.appendReplacement(sb, replacement);
}
matcher.appendTail(sb);
return sb.toString();
} | java |
public static boolean isAssignable(Type lhsType, Type rhsType) {
Assert.notNull(lhsType, "Left-hand side type must not be null");
Assert.notNull(rhsType, "Right-hand side type must not be null");
// all types are assignable to themselves and to class Object
if (lhsType.equals(rhsType) || lhsType.equals(Object.class)) {
return true;
}
if (lhsType instanceof Class<?>) {
Class<?> lhsClass = (Class<?>) lhsType;
// just comparing two classes
if (rhsType instanceof Class<?>) {
return ClassUtils.isAssignable(lhsClass, (Class<?>) rhsType);
}
if (rhsType instanceof ParameterizedType) {
Type rhsRaw = ((ParameterizedType) rhsType).getRawType();
// a parameterized type is always assignable to its raw class type
if (rhsRaw instanceof Class<?>) {
return ClassUtils.isAssignable(lhsClass, (Class<?>) rhsRaw);
}
}
else if (lhsClass.isArray() && rhsType instanceof GenericArrayType) {
Type rhsComponent = ((GenericArrayType) rhsType).getGenericComponentType();
return isAssignable(lhsClass.getComponentType(), rhsComponent);
}
}
// parameterized types are only assignable to other parameterized types and class types
if (lhsType instanceof ParameterizedType) {
if (rhsType instanceof Class<?>) {
Type lhsRaw = ((ParameterizedType) lhsType).getRawType();
if (lhsRaw instanceof Class<?>) {
return ClassUtils.isAssignable((Class<?>) lhsRaw, (Class<?>) rhsType);
}
}
else if (rhsType instanceof ParameterizedType) {
return isAssignable((ParameterizedType) lhsType, (ParameterizedType) rhsType);
}
}
if (lhsType instanceof GenericArrayType) {
Type lhsComponent = ((GenericArrayType) lhsType).getGenericComponentType();
if (rhsType instanceof Class<?>) {
Class<?> rhsClass = (Class<?>) rhsType;
if (rhsClass.isArray()) {
return isAssignable(lhsComponent, rhsClass.getComponentType());
}
}
else if (rhsType instanceof GenericArrayType) {
Type rhsComponent = ((GenericArrayType) rhsType).getGenericComponentType();
return isAssignable(lhsComponent, rhsComponent);
}
}
if (lhsType instanceof WildcardType) {
return isAssignable((WildcardType) lhsType, rhsType);
}
return false;
} | java |
static String encodeUriComponent(String source, String encoding, Type type) throws UnsupportedEncodingException {
if (source == null) {
return null;
}
Assert.hasLength(encoding, "Encoding must not be empty");
byte[] bytes = encodeBytes(source.getBytes(encoding), type);
return new String(bytes, "US-ASCII");
} | java |
protected HttpUriRequest createHttpRequest(HttpMethod httpMethod, URI uri) {
switch (httpMethod) {
case GET:
return new HttpGet(uri);
case DELETE:
return new HttpDelete(uri);
case HEAD:
return new HttpHead(uri);
case OPTIONS:
return new HttpOptions(uri);
case POST:
return new HttpPost(uri);
case PUT:
return new HttpPut(uri);
case TRACE:
return new HttpTrace(uri);
default:
throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod);
}
} | java |
public static void registerConverters(Set<?> converters, ConverterRegistry registry) {
if (converters != null) {
for (Object converter : converters) {
if (converter instanceof GenericConverter) {
registry.addConverter((GenericConverter) converter);
}
else if (converter instanceof Converter<?, ?>) {
registry.addConverter((Converter<?, ?>) converter);
}
else if (converter instanceof ConverterFactory<?, ?>) {
registry.addConverterFactory((ConverterFactory<?, ?>) converter);
}
else {
throw new IllegalArgumentException("Each converter object must implement one of the " +
"Converter, ConverterFactory, or GenericConverter interfaces");
}
}
}
} | java |
public static <K,V> MultiValueMap<K,V> unmodifiableMultiValueMap(MultiValueMap<? extends K, ? extends V> map) {
Assert.notNull(map, "'map' must not be null");
Map<K, List<V>> result = new LinkedHashMap<K, List<V>>(map.size());
for (Map.Entry<? extends K, ? extends List<? extends V>> entry : map.entrySet()) {
List<V> values = Collections.unmodifiableList(entry.getValue());
result.put(entry.getKey(), values);
}
Map<K, List<V>> unmodifiableMap = Collections.unmodifiableMap(result);
return toMultiValueMap(unmodifiableMap);
} | java |
public static String copyToString(InputStream in, Charset charset) throws IOException {
Assert.notNull(in, "No InputStream specified");
StringBuilder out = new StringBuilder();
InputStreamReader reader = new InputStreamReader(in, charset);
char[] buffer = new char[BUFFER_SIZE];
int bytesRead = -1;
while ((bytesRead = reader.read(buffer)) != -1) {
out.append(buffer, 0, bytesRead);
}
return out.toString();
} | java |
public static void copy(byte[] in, OutputStream out) throws IOException {
Assert.notNull(in, "No input byte array specified");
Assert.notNull(out, "No OutputStream specified");
out.write(in);
} | java |
private int handleIOException(IOException ex) throws IOException {
if (AUTH_ERROR.equals(ex.getMessage()) || AUTH_ERROR_JELLY_BEAN.equals(ex.getMessage())) {
return HttpStatus.UNAUTHORIZED.value();
} else if (PROXY_AUTH_ERROR.equals(ex.getMessage())) {
return HttpStatus.PROXY_AUTHENTICATION_REQUIRED.value();
} else {
throw ex;
}
} | java |
public static TextEncryptor queryableText(CharSequence password, CharSequence salt) {
return new HexEncodingTextEncryptor(new AndroidAesBytesEncryptor(password.toString(), salt, AndroidKeyGenerators.shared(16)));
} | java |
public static UriComponentsBuilder fromPath(String path) {
UriComponentsBuilder builder = new UriComponentsBuilder();
builder.path(path);
return builder;
} | java |
public UriComponentsBuilder uri(URI uri) {
Assert.notNull(uri, "'uri' must not be null");
this.scheme = uri.getScheme();
if (uri.isOpaque()) {
this.ssp = uri.getRawSchemeSpecificPart();
resetHierarchicalComponents();
}
else {
if (uri.getRawUserInfo() != null) {
this.userInfo = uri.getRawUserInfo();
}
if (uri.getHost() != null) {
this.host = uri.getHost();
}
if (uri.getPort() != -1) {
this.port = String.valueOf(uri.getPort());
}
if (StringUtils.hasLength(uri.getRawPath())) {
this.pathBuilder = new CompositePathComponentBuilder(uri.getRawPath());
}
if (StringUtils.hasLength(uri.getRawQuery())) {
this.queryParams.clear();
query(uri.getRawQuery());
}
resetSchemeSpecificPart();
}
if (uri.getRawFragment() != null) {
this.fragment = uri.getRawFragment();
}
return this;
} | java |
public UriComponentsBuilder pathSegment(String... pathSegments) throws IllegalArgumentException {
Assert.notNull(pathSegments, "'segments' must not be null");
this.pathBuilder.addPathSegments(pathSegments);
resetSchemeSpecificPart();
return this;
} | java |
public UriComponentsBuilder queryParams(MultiValueMap<String, String> params) {
Assert.notNull(params, "'params' must not be null");
this.queryParams.putAll(params);
return this;
} | java |
public UriComponentsBuilder replaceQueryParam(String name, Object... values) {
Assert.notNull(name, "'name' must not be null");
this.queryParams.remove(name);
if (!ObjectUtils.isEmpty(values)) {
queryParam(name, values);
}
resetSchemeSpecificPart();
return this;
} | java |
private static void registerCommonClasses(Class<?>... commonClasses) {
for (Class<?> clazz : commonClasses) {
commonClassCache.put(clazz.getName(), clazz);
}
} | java |
public static ClassLoader overrideThreadContextClassLoader(ClassLoader classLoaderToUse) {
Thread currentThread = Thread.currentThread();
ClassLoader threadContextClassLoader = currentThread.getContextClassLoader();
if (classLoaderToUse != null && !classLoaderToUse.equals(threadContextClassLoader)) {
currentThread.setContextClassLoader(classLoaderToUse);
return threadContextClassLoader;
}
else {
return null;
}
} | java |
public static boolean isCacheSafe(Class<?> clazz, ClassLoader classLoader) {
Assert.notNull(clazz, "Class must not be null");
try {
ClassLoader target = clazz.getClassLoader();
if (target == null) {
return true;
}
ClassLoader cur = classLoader;
if (cur == target) {
return true;
}
while (cur != null) {
cur = cur.getParent();
if (cur == target) {
return true;
}
}
return false;
}
catch (SecurityException ex) {
// Probably from the system ClassLoader - let's consider it safe.
return true;
}
} | java |
public static String getShortName(String className) {
Assert.hasLength(className, "Class name must not be empty");
int lastDotIndex = className.lastIndexOf(PACKAGE_SEPARATOR);
int nameEndIndex = className.indexOf(CGLIB_CLASS_SEPARATOR);
if (nameEndIndex == -1) {
nameEndIndex = className.length();
}
String shortName = className.substring(lastDotIndex + 1, nameEndIndex);
shortName = shortName.replace(INNER_CLASS_SEPARATOR, PACKAGE_SEPARATOR);
return shortName;
} | java |
public static Method getStaticMethod(Class<?> clazz, String methodName, Class<?>... args) {
Assert.notNull(clazz, "Class must not be null");
Assert.notNull(methodName, "Method name must not be null");
try {
Method method = clazz.getMethod(methodName, args);
return Modifier.isStatic(method.getModifiers()) ? method : null;
}
catch (NoSuchMethodException ex) {
return null;
}
} | java |
public static boolean isPrimitiveArray(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
return (clazz.isArray() && clazz.getComponentType().isPrimitive());
} | java |
public static boolean isPrimitiveWrapperArray(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
return (clazz.isArray() && isPrimitiveWrapper(clazz.getComponentType()));
} | java |
public static Class<?> resolvePrimitiveIfNecessary(Class<?> clazz) {
Assert.notNull(clazz, "Class must not be null");
return (clazz.isPrimitive() && clazz != void.class? primitiveTypeToWrapperMap.get(clazz) : clazz);
} | java |
public static Class<?>[] toClassArray(Collection<Class<?>> collection) {
if (collection == null) {
return null;
}
return collection.toArray(new Class<?>[collection.size()]);
} | java |
public static Class<?> determineCommonAncestor(Class<?> clazz1, Class<?> clazz2) {
if (clazz1 == null) {
return clazz2;
}
if (clazz2 == null) {
return clazz1;
}
if (clazz1.isAssignableFrom(clazz2)) {
return clazz1;
}
if (clazz2.isAssignableFrom(clazz1)) {
return clazz2;
}
Class<?> ancestor = clazz1;
do {
ancestor = ancestor.getSuperclass();
if (ancestor == null || Object.class.equals(ancestor)) {
return null;
}
}
while (!ancestor.isAssignableFrom(clazz2));
return ancestor;
} | java |
public static Class<?> resolveReturnType(Method method, Class<?> clazz) {
Assert.notNull(method, "Method must not be null");
Type genericType = method.getGenericReturnType();
Assert.notNull(clazz, "Class must not be null");
Map<TypeVariable, Type> typeVariableMap = getTypeVariableMap(clazz);
Type rawType = getRawType(genericType, typeVariableMap);
return (rawType instanceof Class ? (Class<?>) rawType : method.getReturnType());
} | java |
public static Class<?> resolveReturnTypeArgument(Method method, Class<?> genericIfc) {
Assert.notNull(method, "method must not be null");
Type returnType = method.getReturnType();
Type genericReturnType = method.getGenericReturnType();
if (returnType.equals(genericIfc)) {
if (genericReturnType instanceof ParameterizedType) {
ParameterizedType targetType = (ParameterizedType) genericReturnType;
Type[] actualTypeArguments = targetType.getActualTypeArguments();
Type typeArg = actualTypeArguments[0];
if (!(typeArg instanceof WildcardType)) {
return (Class<?>) typeArg;
}
}
else {
return null;
}
}
return resolveTypeArgument((Class<?>) returnType, genericIfc);
} | java |
public static Class<?> resolveTypeArgument(Class<?> clazz, Class<?> genericIfc) {
Class<?>[] typeArgs = resolveTypeArguments(clazz, genericIfc);
if (typeArgs == null) {
return null;
}
if (typeArgs.length != 1) {
throw new IllegalArgumentException("Expected 1 type argument on generic interface [" +
genericIfc.getName() + "] but found " + typeArgs.length);
}
return typeArgs[0];
} | java |
private static Class<?> extractClass(Class<?> ownerClass, Type arg) {
if (arg instanceof ParameterizedType) {
return extractClass(ownerClass, ((ParameterizedType) arg).getRawType());
}
else if (arg instanceof GenericArrayType) {
GenericArrayType gat = (GenericArrayType) arg;
Type gt = gat.getGenericComponentType();
Class<?> componentClass = extractClass(ownerClass, gt);
return Array.newInstance(componentClass, 0).getClass();
}
else if (arg instanceof TypeVariable) {
TypeVariable tv = (TypeVariable) arg;
arg = getTypeVariableMap(ownerClass).get(tv);
if (arg == null) {
arg = extractBoundForTypeVariable(tv);
if (arg instanceof ParameterizedType) {
return extractClass(ownerClass, ((ParameterizedType) arg).getRawType());
}
}
else {
return extractClass(ownerClass, arg);
}
}
return (arg instanceof Class ? (Class) arg : Object.class);
} | java |
static Type getRawType(Type genericType, Map<TypeVariable, Type> typeVariableMap) {
Type resolvedType = genericType;
if (genericType instanceof TypeVariable) {
TypeVariable tv = (TypeVariable) genericType;
resolvedType = typeVariableMap.get(tv);
if (resolvedType == null) {
resolvedType = extractBoundForTypeVariable(tv);
}
}
if (resolvedType instanceof ParameterizedType) {
return ((ParameterizedType) resolvedType).getRawType();
}
else {
return resolvedType;
}
} | java |
public static Class<?> getMapValueFieldType(Field mapField, int nestingLevel) {
return getGenericFieldType(mapField, Map.class, 1, null, nestingLevel);
} | java |
private static Class<?> getGenericReturnType(Method method, Class<?> source, int typeIndex, int nestingLevel) {
return extractType(method.getGenericReturnType(), source, typeIndex, null, null, nestingLevel, 1);
} | java |
private static Class<?> extractTypeFromClass(Class<?> clazz, Class<?> source, int typeIndex,
Map<TypeVariable, Type> typeVariableMap, Map<Integer, Integer> typeIndexesPerLevel,
int nestingLevel, int currentLevel) {
if (clazz.getName().startsWith("java.util.")) {
return null;
}
if (clazz.getSuperclass() != null && isIntrospectionCandidate(clazz.getSuperclass())) {
try {
return extractType(clazz.getGenericSuperclass(), source, typeIndex, typeVariableMap,
typeIndexesPerLevel, nestingLevel, currentLevel);
}
catch (MalformedParameterizedTypeException ex) {
// from getGenericSuperclass() - ignore and continue with interface introspection
}
}
Type[] ifcs = clazz.getGenericInterfaces();
if (ifcs != null) {
for (Type ifc : ifcs) {
Type rawType = ifc;
if (ifc instanceof ParameterizedType) {
rawType = ((ParameterizedType) ifc).getRawType();
}
if (rawType instanceof Class && isIntrospectionCandidate((Class) rawType)) {
return extractType(ifc, source, typeIndex, typeVariableMap, typeIndexesPerLevel, nestingLevel, currentLevel);
}
}
}
return null;
} | java |
@Override
public boolean exists() {
try {
InputStream inputStream = this.assetManager.open(this.fileName);
if (inputStream != null) {
return true;
} else {
return false;
}
} catch (IOException e) {
return false;
}
} | java |
static void addHeaders(HttpUriRequest httpRequest, HttpHeaders headers) {
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
String headerName = entry.getKey();
if (HttpHeaders.COOKIE.equalsIgnoreCase(headerName)) { // RFC 6265
String headerValue = StringUtils.collectionToDelimitedString(entry.getValue(), "; ");
httpRequest.addHeader(headerName, headerValue);
}
else if (!HTTP.CONTENT_LEN.equalsIgnoreCase(headerName) &&
!HTTP.TRANSFER_ENCODING.equalsIgnoreCase(headerName)) {
for (String headerValue : entry.getValue()) {
httpRequest.addHeader(headerName, headerValue);
}
}
}
} | java |
public boolean canBypassConvert(TypeDescriptor sourceType, TypeDescriptor targetType) {
Assert.notNull(targetType, "The targetType to convert to cannot be null");
if (sourceType == null) {
return true;
}
GenericConverter converter = getConverter(sourceType, targetType);
return (converter == NO_OP_CONVERTER);
} | java |
protected static int calculateShift(int minimumValue, int maximumValue) {
int shift = 0;
int value = 1;
while (value < minimumValue && value < maximumValue) {
value <<= 1;
shift++;
}
return shift;
} | java |
public MediaType copyQualityValue(MediaType mediaType) {
if (!mediaType.parameters.containsKey(PARAM_QUALITY_FACTOR)) {
return this;
}
Map<String, String> params = new LinkedHashMap<String, String>(this.parameters);
params.put(PARAM_QUALITY_FACTOR, mediaType.parameters.get(PARAM_QUALITY_FACTOR));
return new MediaType(this, params);
} | java |
public MediaType removeQualityValue() {
if (!this.parameters.containsKey(PARAM_QUALITY_FACTOR)) {
return this;
}
Map<String, String> params = new LinkedHashMap<String, String>(this.parameters);
params.remove(PARAM_QUALITY_FACTOR);
return new MediaType(this, params);
} | java |
@Override
public String getFirst(String headerName) {
List<String> headerValues = headers.get(headerName);
return headerValues != null ? headerValues.get(0) : null;
} | java |
@Override
public void add(String headerName, String headerValue) {
List<String> headerValues = headers.get(headerName);
if (headerValues == null) {
headerValues = new LinkedList<String>();
this.headers.put(headerName, headerValues);
}
headerValues.add(headerValue);
} | java |
@Override
public void set(String headerName, String headerValue) {
List<String> headerValues = new LinkedList<String>();
headerValues.add(headerValue);
headers.put(headerName, headerValues);
} | java |
private void setViewPagerScroller() {
try {
Field scrollerField = ViewPager.class.getDeclaredField("mScroller");
scrollerField.setAccessible(true);
Field interpolatorField = ViewPager.class.getDeclaredField("sInterpolator");
interpolatorField.setAccessible(true);
scroller = new CustomDurationScroller(getContext(), (Interpolator)interpolatorField.get(null));
scrollerField.set(this, scroller);
} catch (Exception e) {
e.printStackTrace();
}
} | java |
public void scrollOnce() {
PagerAdapter adapter = getAdapter();
int currentItem = getCurrentItem();
int totalCount;
if (adapter == null || (totalCount = adapter.getCount()) <= 1) {
return;
}
int nextItem = (direction == LEFT) ? --currentItem : ++currentItem;
if (nextItem < 0) {
if (isCycle) {
setCurrentItem(totalCount - 1, isBorderAnimation);
}
} else if (nextItem == totalCount) {
if (isCycle) {
setCurrentItem(0, isBorderAnimation);
}
} else {
setCurrentItem(nextItem, true);
}
} | java |
public void setHomeAsUpIndicator(Drawable indicator) {
if(!deviceSupportMultiPane()) {
pulsante.setHomeAsUpIndicator(indicator);
}
else {
actionBar.setHomeAsUpIndicator(indicator);
}
} | java |
public MaterialSection getSectionByTitle(String title) {
for(MaterialSection section : sectionList) {
if(section.getTitle().equals(title)) {
return section;
}
}
for(MaterialSection section : bottomSectionList) {
if(section.getTitle().equals(title))
return section;
}
return null;
} | java |
public List<MaterialSection> getSectionList() {
List<MaterialSection> list = new LinkedList<>();
for(MaterialSection section : sectionList)
list.add(section);
for(MaterialSection section : bottomSectionList)
list.add(section);
return list;
} | java |
public MaterialAccount getAccountAtCurrentPosition(int position) {
if (position < 0 || position >= accountManager.size())
throw new RuntimeException("Account Index Overflow");
return findAccountNumber(position);
} | java |
public MaterialAccount getAccountByTitle(String title) {
for(MaterialAccount account : accountManager)
if(currentAccount.getTitle().equals(title))
return account;
return null;
} | java |
@Override
@SuppressLint("NewApi")
public boolean onTouch(View v, MotionEvent event) {
if(touchable) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
view.setBackgroundColor(colorPressed);
return true;
}
if (event.getAction() == MotionEvent.ACTION_CANCEL) {
if (isSelected)
view.setBackgroundColor(colorSelected);
else
view.setBackgroundColor(colorUnpressed);
return true;
}
if (event.getAction() == MotionEvent.ACTION_UP) {
view.setBackgroundColor(colorSelected);
afterClick();
return true;
}
}
return false;
} | java |
public void setBackgroundColor(int color) {
colorUnpressed = color;
if(!isSelected()) {
if (rippleAnimationSupport()) {
ripple.setRippleBackground(colorUnpressed);
}
else {
view.setBackgroundColor(colorUnpressed);
}
}
} | java |
public List<NodeInfo> getNodes() {
final URI uri = uriWithPath("./nodes/");
return Arrays.asList(this.rt.getForObject(uri, NodeInfo[].class));
} | java |
public NodeInfo getNode(String name) {
final URI uri = uriWithPath("./nodes/" + encodePathSegment(name));
return this.rt.getForObject(uri, NodeInfo.class);
} | java |
public List<ConnectionInfo> getConnections() {
final URI uri = uriWithPath("./connections/");
return Arrays.asList(this.rt.getForObject(uri, ConnectionInfo[].class));
} | java |
public ConnectionInfo getConnection(String name) {
final URI uri = uriWithPath("./connections/" + encodePathSegment(name));
return this.rt.getForObject(uri, ConnectionInfo.class);
} | java |
public List<ChannelInfo> getChannels() {
final URI uri = uriWithPath("./channels/");
return Arrays.asList(this.rt.getForObject(uri, ChannelInfo[].class));
} | java |
public List<ChannelInfo> getChannels(String connectionName) {
final URI uri = uriWithPath("./connections/" + encodePathSegment(connectionName) + "/channels/");
return Arrays.asList(this.rt.getForObject(uri, ChannelInfo[].class));
} | java |
public ChannelInfo getChannel(String name) {
final URI uri = uriWithPath("./channels/" + encodePathSegment(name));
return this.rt.getForObject(uri, ChannelInfo.class);
} | java |
public List<BindingInfo> getQueueBindings(String vhost, String queue) {
final URI uri = uriWithPath("./queues/" + encodePathSegment(vhost) +
"/" + encodePathSegment(queue) + "/bindings");
final BindingInfo[] result = this.rt.getForObject(uri, BindingInfo[].class);
return asListOrNull(result);
} | java |
public void declareShovel(String vhost, ShovelInfo info) {
Map<String, Object> props = info.getDetails().getPublishProperties();
if(props != null && props.isEmpty()) {
throw new IllegalArgumentException("Shovel publish properties must be a non-empty map or null");
}
final URI uri = uriWithPath("./parameters/shovel/" + encodePathSegment(vhost) + "/" + encodePathSegment(info.getName()));
this.rt.put(uri, info);
} | java |
public void deleteShovel(String vhost, String shovelname) {
this.deleteIgnoring404(uriWithPath("./parameters/shovel/" + encodePathSegment(vhost) + "/" + encodePathSegment(shovelname)));
} | java |
public void setCharTranslator(CharacterTranslator charTranslator) {
if(charTranslator!=null){
this.charTranslator = charTranslator;
this.htmlElementTranslator = null;
this.targetTranslator = null;
}
} | java |
public void setHtmlElementTranslator(HtmlElementTranslator htmlElementTranslator) {
if(htmlElementTranslator!=null){
this.htmlElementTranslator = htmlElementTranslator;
this.charTranslator = null;
this.targetTranslator = null;
}
} | java |
public AT_CellContext setPadding(int padding){
if(padding>-1){
this.paddingTop = padding;
this.paddingBottom = padding;
this.paddingLeft = padding;
this.paddingRight = padding;
}
return this;
} | java |
public void setTargetTranslator(TargetTranslator targetTranslator) {
if(targetTranslator!=null){
this.targetTranslator = targetTranslator;
this.charTranslator = null;
this.htmlElementTranslator = null;
}
} | java |
public static int[] longestWord(LinkedList<AT_Row> rows, int colNumbers){
if(rows==null){
return null;
}
if(rows.size()==0){
return new int[0];
}
int[] ret = new int[colNumbers];
for(AT_Row row : rows){
if(row.getType()==TableRowType.CONTENT) {
LinkedList<AT_Cell> cells = row.getCells();
for(int i=0; i<cells.size(); i++) {
if(cells.get(i).getContent()!=null){
String[] ar = StringUtils.split(Object_To_StrBuilder.convert(cells.get(i).getContent()).toString());
for(int k=0; k<ar.length; k++){
int count = ar[k].length() + cells.get(i).getContext().getPaddingLeft() + cells.get(i).getContext().getPaddingRight();
if(count>ret[i]){
ret[i] = count;
}
}
}
}
}
}
return ret;
} | java |
public static AT_Row createRule(TableRowType type, TableRowStyle style){
Validate.notNull(type);
Validate.validState(type!=TableRowType.UNKNOWN);
Validate.validState(type!=TableRowType.CONTENT);
Validate.notNull(style);
Validate.validState(style!=TableRowStyle.UNKNOWN);
return new AT_Row(){
@Override
public TableRowType getType(){
return type;
}
@Override
public TableRowStyle getStyle(){
return style;
}
};
} | java |
public static AT_Row createContentRow(Object[] content, TableRowStyle style){
Validate.notNull(content);
Validate.notNull(style);
Validate.validState(style!=TableRowStyle.UNKNOWN);
LinkedList<AT_Cell> cells = new LinkedList<AT_Cell>();
for(Object o : content){
cells.add(new AT_Cell(o));
}
return new AT_Row(){
@Override
public TableRowType getType(){
return TableRowType.CONTENT;
}
@Override
public TableRowStyle getStyle(){
return style;
}
@Override
public LinkedList<AT_Cell> getCells(){
return cells;
}
};
} | java |
public AT_Row setPadding(int padding){
if(this.hasCells()){
for(AT_Cell cell : this.getCells()){
cell.getContext().setPadding(padding);
}
}
return this;
} | java |
public AT_Row setPaddingBottom(int paddingBottom) {
if(this.hasCells()){
for(AT_Cell cell : this.getCells()){
cell.getContext().setPaddingBottom(paddingBottom);
}
}
return this;
} | java |
public AT_Row setPaddingBottomChar(Character paddingBottomChar) {
if(this.hasCells()){
for(AT_Cell cell : this.getCells()){
cell.getContext().setPaddingBottomChar(paddingBottomChar);
}
}
return this;
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.