Tabnine Logo
Class.isAssignableFrom
Code IndexAdd Tabnine to your IDE (free)

How to use
isAssignableFrom
method
in
java.lang.Class

Best Java code snippets using java.lang.Class.isAssignableFrom (Showing top 20 results out of 106,290)

origin: spring-projects/spring-framework

private boolean isSupportedType(@Nullable Class<?> clazz) {
  return (clazz != null && ((HttpEntity.class.isAssignableFrom(clazz) &&
      !RequestEntity.class.isAssignableFrom(clazz)) ||
      HttpHeaders.class.isAssignableFrom(clazz)));
}
origin: spring-projects/spring-framework

@Override
public boolean matches(Method method, Class<?> targetClass) {
  if (TransactionalProxy.class.isAssignableFrom(targetClass) ||
      PlatformTransactionManager.class.isAssignableFrom(targetClass) ||
      PersistenceExceptionTranslator.class.isAssignableFrom(targetClass)) {
    return false;
  }
  TransactionAttributeSource tas = getTransactionAttributeSource();
  return (tas == null || tas.getTransactionAttribute(method, targetClass) != null);
}
origin: square/retrofit

 @Override public @Nullable Converter<?, RequestBody> requestBodyConverter(Type type,
   Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
  if (!(type instanceof Class<?>)) {
   return null;
  }
  if (!MessageLite.class.isAssignableFrom((Class<?>) type)) {
   return null;
  }
  return new ProtoRequestBodyConverter<>();
 }
}
origin: square/retrofit

@Override public @Nullable Converter<?, RequestBody> requestBodyConverter(Type type,
  Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
 if (RequestBody.class.isAssignableFrom(Utils.getRawType(type))) {
  return RequestBodyConverter.INSTANCE;
 }
 return null;
}
origin: google/guava

private boolean someRawTypeIsSubclassOf(Class<?> superclass) {
 for (Class<?> rawType : getRawTypes()) {
  if (superclass.isAssignableFrom(rawType)) {
   return true;
  }
 }
 return false;
}
origin: spring-projects/spring-framework

@Override
public boolean isTypeMatch(String name, @Nullable Class<?> typeToMatch) throws NoSuchBeanDefinitionException {
  Class<?> type = getType(name);
  return (typeToMatch == null || (type != null && typeToMatch.isAssignableFrom(type)));
}
origin: spring-projects/spring-framework

/**
 * Is this type a {@link Collection} type?
 */
public boolean isCollection() {
  return Collection.class.isAssignableFrom(getType());
}
origin: spring-projects/spring-framework

@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
  Class<?> sourceClass = sourceType.getObjectType();
  if (String.class == sourceClass) {
    // no conversion required
    return false;
  }
  return (CharSequence.class.isAssignableFrom(sourceClass) ||
      StringWriter.class.isAssignableFrom(sourceClass) ||
      ObjectToObjectConverter.hasConversionMethodOrConstructor(sourceClass, String.class));
}
origin: spring-projects/spring-framework

@Override
public boolean isTypeMatch(String name, @Nullable Class<?> typeToMatch) throws NoSuchBeanDefinitionException {
  Class<?> type = getType(name);
  return (typeToMatch == null || (type != null && typeToMatch.isAssignableFrom(type)));
}
origin: square/retrofit

/**
 * Returns the generic form of {@code supertype}. For example, if this is {@code
 * ArrayList<String>}, this returns {@code Iterable<String>} given the input {@code
 * Iterable.class}.
 *
 * @param supertype a superclass of, or interface implemented by, this.
 */
static Type getSupertype(Type context, Class<?> contextRawType, Class<?> supertype) {
 if (!supertype.isAssignableFrom(contextRawType)) throw new IllegalArgumentException();
 return resolve(context, contextRawType,
   getGenericSupertype(context, contextRawType, supertype));
}
origin: spring-projects/spring-framework

@Override
public boolean supportsParameter(MethodParameter parameter) {
  return checkAnnotatedParamNoReactiveWrapper(parameter, MatrixVariable.class,
      (ann, type) -> !Map.class.isAssignableFrom(type) || StringUtils.hasText(ann.name()));
}
origin: spring-projects/spring-framework

@Override
public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType) {
  return (Resource.class.isAssignableFrom(elementType.toClass()) &&
      super.canDecode(elementType, mimeType));
}
origin: spring-projects/spring-framework

@Override
public boolean canEncode(ResolvableType elementType, @Nullable MimeType mimeType) {
  return super.canEncode(elementType, mimeType)
      && ResourceRegion.class.isAssignableFrom(elementType.toClass());
}
origin: spring-projects/spring-framework

@Override
public boolean matches(Method method, Class<?> targetClass) {
  if (CacheManager.class.isAssignableFrom(targetClass)) {
    return false;
  }
  CacheOperationSource cas = getCacheOperationSource();
  return (cas != null && !CollectionUtils.isEmpty(cas.getCacheOperations(method, targetClass)));
}
origin: spring-projects/spring-framework

@Override
public Object resolveArgumentValue(
    MethodParameter methodParameter, BindingContext context, ServerWebExchange exchange) {
  boolean isMultiValueMap = MultiValueMap.class.isAssignableFrom(methodParameter.getParameterType());
  HttpHeaders headers = exchange.getRequest().getHeaders();
  return (isMultiValueMap ? headers : headers.toSingleValueMap());
}
origin: spring-projects/spring-framework

private boolean hasErrorsArgument(MethodParameter parameter) {
  int i = parameter.getParameterIndex();
  Class<?>[] paramTypes = parameter.getExecutable().getParameterTypes();
  return (paramTypes.length > i + 1 && Errors.class.isAssignableFrom(paramTypes[i + 1]));
}
origin: spring-projects/spring-framework

@Override
public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType) {
  JavaType javaType = getObjectMapper().getTypeFactory().constructType(elementType.getType());
  // Skip String: CharSequenceDecoder + "*/*" comes after
  return (!CharSequence.class.isAssignableFrom(elementType.toClass()) &&
      getObjectMapper().canDeserialize(javaType) && supportsMimeType(mimeType));
}
origin: spring-projects/spring-framework

  @Override
  protected void assertions(MethodInvocation invocation) {
    assertSame(this, invocation.getThis());
    assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(),
      ITestBean.class.isAssignableFrom(invocation.getMethod().getDeclaringClass()));
  }
}
origin: spring-projects/spring-framework

@SuppressWarnings("unchecked")
private <T> T resolveValue(ServerWebExchange exchange, ResolvableType type) {
  MethodParameter param = this.testMethod.arg(type);
  Mono<Object> result = this.resolver.resolveArgument(param, new BindingContext(), exchange);
  Object value = result.block(Duration.ofSeconds(5));
  assertNotNull(value);
  assertTrue("Unexpected return value type: " + value.getClass(),
      param.getParameterType().isAssignableFrom(value.getClass()));
  return (T) value;
}
origin: spring-projects/spring-framework

@Test
public void createXmlMapper() {
  Jackson2ObjectMapperBuilder builder = Jackson2ObjectMapperBuilder.json().indentOutput(true);
  ObjectMapper jsonObjectMapper = builder.build();
  ObjectMapper xmlObjectMapper = builder.createXmlMapper(true).build();
  assertTrue(jsonObjectMapper.isEnabled(SerializationFeature.INDENT_OUTPUT));
  assertTrue(xmlObjectMapper.isEnabled(SerializationFeature.INDENT_OUTPUT));
  assertTrue(xmlObjectMapper.getClass().isAssignableFrom(XmlMapper.class));
}
java.langClassisAssignableFrom

Javadoc

Tests whether the given class type can be converted to the class represented by this Class. Conversion may be done via an identity conversion or a widening reference conversion (if either the receiver or the argument represent primitive types, only the identity conversion applies).

Popular methods of Class

  • getName
    Returns the name of the class represented by this Class. For a description of the format which is us
  • getSimpleName
  • getClassLoader
  • forName
    Returns the Class object associated with the class or interface with the given string name, using th
  • newInstance
    Returns a new instance of the class represented by this Class, created by invoking the default (that
  • getMethod
    Returns a Method object that reflects the specified public member method of the class or interface r
  • getResourceAsStream
  • getSuperclass
    Returns the Class representing the superclass of the entity (class, interface, primitive type or voi
  • getConstructor
  • cast
    Casts an object to the class or interface represented by this Class object.
  • isInstance
  • getCanonicalName
    Returns the canonical name of the underlying class as defined by the Java Language Specification. Re
  • isInstance,
  • getCanonicalName,
  • getDeclaredField,
  • isArray,
  • getAnnotation,
  • getDeclaredFields,
  • getResource,
  • getDeclaredMethod,
  • getMethods

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • notifyDataSetChanged (ArrayAdapter)
  • getSharedPreferences (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • JFileChooser (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now