congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
TypeDescriptor.getElementTypeDescriptor
Code IndexAdd Tabnine to your IDE (free)

How to use
getElementTypeDescriptor
method
in
org.springframework.core.convert.TypeDescriptor

Best Java code snippets using org.springframework.core.convert.TypeDescriptor.getElementTypeDescriptor (Showing top 20 results out of 315)

origin: spring-projects/spring-framework

@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
  return ConversionUtils.canConvertElements(
      sourceType.getElementTypeDescriptor(), targetType.getElementTypeDescriptor(), this.conversionService);
}
origin: spring-projects/spring-framework

@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
  return ConversionUtils.canConvertElements(sourceType.getElementTypeDescriptor(),
      targetType.getElementTypeDescriptor(), this.conversionService);
}
origin: spring-projects/spring-framework

@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
  return (targetType.getElementTypeDescriptor() == null ||
      this.conversionService.canConvert(sourceType, targetType.getElementTypeDescriptor()));
}
origin: spring-projects/spring-framework

@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
  return ConversionUtils.canConvertElements(sourceType, targetType.getElementTypeDescriptor(),
      this.conversionService);
}
origin: spring-projects/spring-framework

@Override
public void setValue(@Nullable Object newValue) {
  TypeDescriptor elementType = this.typeDescriptor.getElementTypeDescriptor();
  Assert.state(elementType != null, "No element type");
  setArrayElement(this.typeConverter, this.array, this.index, newValue, elementType.getType());
}
origin: spring-projects/spring-framework

@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
  return ConversionUtils.canConvertElements(sourceType, targetType.getElementTypeDescriptor(),
      this.conversionService);
}
origin: spring-projects/spring-framework

@Nullable
private Object convertFromStream(@Nullable Stream<?> source, TypeDescriptor streamType, TypeDescriptor targetType) {
  List<Object> content = (source != null ? source.collect(Collectors.<Object>toList()) : Collections.emptyList());
  TypeDescriptor listType = TypeDescriptor.collection(List.class, streamType.getElementTypeDescriptor());
  return this.conversionService.convert(content, listType, targetType);
}
origin: spring-projects/spring-framework

private Object convertToStream(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor streamType) {
  TypeDescriptor targetCollection = TypeDescriptor.collection(List.class, streamType.getElementTypeDescriptor());
  List<?> target = (List<?>) this.conversionService.convert(source, sourceType, targetCollection);
  if (target == null) {
    target = Collections.emptyList();
  }
  return target.stream();
}
origin: spring-projects/spring-framework

@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
  if (sourceType.isAssignableTo(STREAM_TYPE)) {
    return matchesFromStream(sourceType.getElementTypeDescriptor(), targetType);
  }
  if (targetType.isAssignableTo(STREAM_TYPE)) {
    return matchesToStream(targetType.getElementTypeDescriptor(), sourceType);
  }
  return false;
}
origin: spring-projects/spring-framework

@Test
public void passDownGeneric() throws Exception {
  TypeDescriptor td = new TypeDescriptor(getClass().getField("passDownGeneric"));
  assertEquals(List.class, td.getElementTypeDescriptor().getType());
  assertEquals(Set.class, td.getElementTypeDescriptor().getElementTypeDescriptor().getType());
  assertEquals(Integer.class, td.getElementTypeDescriptor().getElementTypeDescriptor().getElementTypeDescriptor().getType());
}
origin: spring-projects/spring-framework

@Test
public void createCollectionWithNullElement() throws Exception {
  TypeDescriptor typeDescriptor = TypeDescriptor.collection(List.class, null);
  assertThat(typeDescriptor.getElementTypeDescriptor(), nullValue());
}
origin: spring-projects/spring-framework

@Test
public void elementTypePreserveContext() throws Exception {
  TypeDescriptor desc = new TypeDescriptor(getClass().getField("listPreserveContext"));
  assertEquals(Integer.class, desc.getElementTypeDescriptor().getElementTypeDescriptor().getType());
  List<Integer> value = new ArrayList<>(3);
  desc = desc.elementTypeDescriptor(value);
  assertEquals(Integer.class, desc.getElementTypeDescriptor().getType());
  assertNotNull(desc.getAnnotation(FieldAnnotation.class));
}
origin: spring-projects/spring-framework

@Test
public void propertyComplex() throws Exception {
  Property property = new Property(getClass(), getClass().getMethod("getComplexProperty"),
      getClass().getMethod("setComplexProperty", Map.class));
  TypeDescriptor desc = new TypeDescriptor(property);
  assertEquals(String.class, desc.getMapKeyTypeDescriptor().getType());
  assertEquals(Integer.class, desc.getMapValueTypeDescriptor().getElementTypeDescriptor().getElementTypeDescriptor().getType());
}
origin: spring-projects/spring-framework

@Test
public void fieldComplexTypeDescriptor() throws Exception {
  TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("arrayOfListOfString"));
  assertTrue(typeDescriptor.isArray());
  assertEquals(List.class,typeDescriptor.getElementTypeDescriptor().getType());
  assertEquals(String.class, typeDescriptor.getElementTypeDescriptor().getElementTypeDescriptor().getType());
  assertEquals("java.util.List<java.lang.String>[]",typeDescriptor.toString());
}
origin: spring-projects/spring-framework

@Test
public void propertyGenericTypeList() throws Exception {
  GenericType<Integer> genericBean = new IntegerType();
  Property property = new Property(getClass(), genericBean.getClass().getMethod("getListProperty"),
      genericBean.getClass().getMethod("setListProperty", List.class));
  TypeDescriptor desc = new TypeDescriptor(property);
  assertEquals(List.class, desc.getType());
  assertEquals(Integer.class, desc.getElementTypeDescriptor().getType());
}
origin: spring-projects/spring-framework

@Test
public void elementTypeForCollectionSubclass() throws Exception {
  @SuppressWarnings("serial")
  class CustomSet extends HashSet<String> {
  }
  assertEquals(TypeDescriptor.valueOf(CustomSet.class).getElementTypeDescriptor(), TypeDescriptor.valueOf(String.class));
  assertEquals(TypeDescriptor.forObject(new CustomSet()).getElementTypeDescriptor(), TypeDescriptor.valueOf(String.class));
}
origin: spring-projects/spring-framework

@Test
public void fieldMap() throws Exception {
  TypeDescriptor desc = new TypeDescriptor(TypeDescriptorTests.class.getField("fieldMap"));
  assertTrue(desc.isMap());
  assertEquals(Integer.class, desc.getMapKeyTypeDescriptor().getElementTypeDescriptor().getType());
  assertEquals(Long.class, desc.getMapValueTypeDescriptor().getElementTypeDescriptor().getType());
}
origin: spring-projects/spring-framework

@Test
public void property() throws Exception {
  Property property = new Property(
      getClass(), getClass().getMethod("getProperty"), getClass().getMethod("setProperty", Map.class));
  TypeDescriptor desc = new TypeDescriptor(property);
  assertEquals(Map.class, desc.getType());
  assertEquals(Integer.class, desc.getMapKeyTypeDescriptor().getElementTypeDescriptor().getType());
  assertEquals(Long.class, desc.getMapValueTypeDescriptor().getElementTypeDescriptor().getType());
  assertNotNull(desc.getAnnotation(MethodAnnotation1.class));
  assertNotNull(desc.getAnnotation(MethodAnnotation2.class));
  assertNotNull(desc.getAnnotation(MethodAnnotation3.class));
}
origin: spring-projects/spring-framework

@Test
public void projectionTypeDescriptors_2() {
  StandardEvaluationContext context = new StandardEvaluationContext(new C());
  SpelExpressionParser parser = new SpelExpressionParser();
  String el1 = "as.![#this.equals('abc')]";
  SpelExpression exp = parser.parseRaw(el1);
  Object[] value = (Object[]) exp.getValue(context);
  // value is array containing [true,false]
  assertEquals(Boolean.class, value[0].getClass());
  TypeDescriptor evaluated = exp.getValueTypeDescriptor(context);
  assertEquals(Boolean.class, evaluated.getElementTypeDescriptor().getType());
}
origin: spring-projects/spring-framework

@Test
public void valueOfArray() throws Exception {
  TypeDescriptor typeDescriptor = TypeDescriptor.valueOf(int[].class);
  assertTrue(typeDescriptor.isArray());
  assertFalse(typeDescriptor.isCollection());
  assertFalse(typeDescriptor.isMap());
  assertEquals(Integer.TYPE, typeDescriptor.getElementTypeDescriptor().getType());
}
org.springframework.core.convertTypeDescriptorgetElementTypeDescriptor

Javadoc

If this type is an array, returns the array's component type. If this type is a Stream, returns the stream's component type. If this type is a Collection and it is parameterized, returns the Collection's element type. If the Collection is not parameterized, returns null indicating the element type is not declared.

Popular methods of TypeDescriptor

  • valueOf
    Create a new type descriptor from the given type.Use this to instruct the conversion system to conve
  • getType
    The type of the backing class, method parameter, field, or property described by this TypeDescriptor
  • <init>
    Create a new type descriptor from a Property.Use this constructor when a source or target conversion
  • forObject
    Create a new type descriptor for an object.Use this factory method to introspect a source object bef
  • getObjectType
    Variation of #getType() that accounts for a primitive type by returning its object wrapper type.This
  • isAssignableTo
    Returns true if an object of this type descriptor can be assigned to the location described by the g
  • isArray
    Is this type an array type?
  • isCollection
    Is this type a Collection type?
  • nested
  • getMapValueTypeDescriptor
    If this type is a Map, creates a mapValue TypeDescriptorfrom the provided map value.Narrows the #get
  • getMapKeyTypeDescriptor
    If this type is a Map, creates a mapKey TypeDescriptorfrom the provided map key. Narrows the #getMap
  • elementTypeDescriptor
    If this type is a Collection or an array, creates a element TypeDescriptor from the provided collect
  • getMapKeyTypeDescriptor,
  • elementTypeDescriptor,
  • getAnnotations,
  • isMap,
  • equals,
  • getAnnotation,
  • isPrimitive,
  • narrow,
  • toString

Popular in Java

  • Updating database using SQL prepared statement
  • runOnUiThread (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • ImageIO (javax.imageio)
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • CodeWhisperer alternatives
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