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

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

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

origin: spring-projects/spring-framework

/**
 * Validate that the specified {@code sourceType} can be converted to a {@link Collection} of
 * the type of the stream elements.
 * @param elementType the type of the stream elements
 * @param sourceType the type to convert from
 */
public boolean matchesToStream(@Nullable TypeDescriptor elementType, TypeDescriptor sourceType) {
  TypeDescriptor collectionOfElement = TypeDescriptor.collection(Collection.class, elementType);
  return this.conversionService.canConvert(sourceType, collectionOfElement);
}
origin: spring-projects/spring-framework

/**
 * Validate that a {@link Collection} of the elements held within the stream can be
 * converted to the specified {@code targetType}.
 * @param elementType the type of the stream elements
 * @param targetType the type to convert to
 */
public boolean matchesFromStream(@Nullable TypeDescriptor elementType, TypeDescriptor targetType) {
  TypeDescriptor collectionOfElement = TypeDescriptor.collection(Collection.class, elementType);
  return this.conversionService.canConvert(collectionOfElement, targetType);
}
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: org.springframework/spring-core

/**
 * Validate that the specified {@code sourceType} can be converted to a {@link Collection} of
 * the type of the stream elements.
 * @param elementType the type of the stream elements
 * @param sourceType the type to convert from
 */
public boolean matchesToStream(@Nullable TypeDescriptor elementType, TypeDescriptor sourceType) {
  TypeDescriptor collectionOfElement = TypeDescriptor.collection(Collection.class, elementType);
  return this.conversionService.canConvert(sourceType, collectionOfElement);
}
origin: org.springframework/spring-core

/**
 * Validate that a {@link Collection} of the elements held within the stream can be
 * converted to the specified {@code targetType}.
 * @param elementType the type of the stream elements
 * @param targetType the type to convert to
 */
public boolean matchesFromStream(@Nullable TypeDescriptor elementType, TypeDescriptor targetType) {
  TypeDescriptor collectionOfElement = TypeDescriptor.collection(Collection.class, elementType);
  return this.conversionService.canConvert(collectionOfElement, targetType);
}
origin: org.springframework/spring-core

@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: org.springframework/spring-core

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

@Test
public void collection() {
  List<String> strings = new ArrayList<>();
  strings.add("3");
  strings.add("9");
  @SuppressWarnings("unchecked")
  List<Integer> integers = (List<Integer>) conversionService.convert(strings,
      TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(Integer.class)));
  assertEquals(Integer.valueOf(3), integers.get(0));
  assertEquals(Integer.valueOf(9), integers.get(1));
}
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 collectionNested() {
  TypeDescriptor desc = TypeDescriptor.collection(List.class, TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(Integer.class)));
  assertEquals(List.class, desc.getType());
  assertEquals(List.class, desc.getObjectType());
  assertEquals("java.util.List", desc.getName());
  assertEquals("java.util.List<java.util.List<java.lang.Integer>>", desc.toString());
  assertTrue(!desc.isPrimitive());
  assertEquals(0, desc.getAnnotations().length);
  assertTrue(desc.isCollection());
  assertFalse(desc.isArray());
  assertEquals(List.class, desc.getElementTypeDescriptor().getType());
  assertEquals(TypeDescriptor.valueOf(Integer.class), desc.getElementTypeDescriptor().getElementTypeDescriptor());
  assertFalse(desc.isMap());
}
origin: spring-projects/spring-framework

@Test
public void collection() {
  TypeDescriptor desc = TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(Integer.class));
  assertEquals(List.class, desc.getType());
  assertEquals(List.class, desc.getObjectType());
  assertEquals("java.util.List", desc.getName());
  assertEquals("java.util.List<java.lang.Integer>", desc.toString());
  assertTrue(!desc.isPrimitive());
  assertEquals(0, desc.getAnnotations().length);
  assertTrue(desc.isCollection());
  assertFalse(desc.isArray());
  assertEquals(Integer.class, desc.getElementTypeDescriptor().getType());
  assertEquals(TypeDescriptor.valueOf(Integer.class), desc.getElementTypeDescriptor());
  assertFalse(desc.isMap());
}
origin: spring-projects/spring-integration

TypeDescriptor targetType = TypeDescriptor.map(Map.class, TypeDescriptor.valueOf(String.class),
    TypeDescriptor.map(Map.class, TypeDescriptor.valueOf(String.class),
        TypeDescriptor.collection(Set.class, TypeDescriptor.valueOf(Bar.class))));
origin: apache/servicemix-bundles

/**
 * Validate that a {@link Collection} of the elements held within the stream can be
 * converted to the specified {@code targetType}.
 * @param elementType the type of the stream elements
 * @param targetType the type to convert to
 */
public boolean matchesFromStream(@Nullable TypeDescriptor elementType, TypeDescriptor targetType) {
  TypeDescriptor collectionOfElement = TypeDescriptor.collection(Collection.class, elementType);
  return this.conversionService.canConvert(collectionOfElement, targetType);
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core

/**
 * Validate that a {@link Collection} of the elements held within the stream can be
 * converted to the specified {@code targetType}.
 * @param elementType the type of the stream elements
 * @param targetType the type to convert to
 */
public boolean matchesFromStream(@Nullable TypeDescriptor elementType, TypeDescriptor targetType) {
  TypeDescriptor collectionOfElement = TypeDescriptor.collection(Collection.class, elementType);
  return this.conversionService.canConvert(collectionOfElement, targetType);
}
origin: apache/servicemix-bundles

/**
 * Validate that the specified {@code sourceType} can be converted to a {@link Collection} of
 * the type of the stream elements.
 * @param elementType the type of the stream elements
 * @param sourceType the type to convert from
 */
public boolean matchesToStream(@Nullable TypeDescriptor elementType, TypeDescriptor sourceType) {
  TypeDescriptor collectionOfElement = TypeDescriptor.collection(Collection.class, elementType);
  return this.conversionService.canConvert(sourceType, collectionOfElement);
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core

/**
 * Validate that the specified {@code sourceType} can be converted to a {@link Collection} of
 * the type of the stream elements.
 * @param elementType the type of the stream elements
 * @param sourceType the type to convert from
 */
public boolean matchesToStream(@Nullable TypeDescriptor elementType, TypeDescriptor sourceType) {
  TypeDescriptor collectionOfElement = TypeDescriptor.collection(Collection.class, elementType);
  return this.conversionService.canConvert(sourceType, collectionOfElement);
}
origin: apache/servicemix-bundles

@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: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core

@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: apache/servicemix-bundles

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();
}
org.springframework.core.convertTypeDescriptorcollection

Javadoc

Create a new type descriptor from a java.util.Collection type.

Useful for converting to typed Collections.

For example, a List could be converted to a List by converting to a targetType built with this method. The method call to construct such a TypeDescriptor would look something like: collection(List.class, TypeDescriptor.valueOf(EmailAddress.class));

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
  • getElementTypeDescriptor
    If this type is an array, returns the array's component type. If this type is a Stream, returns the
  • 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
  • getMapValueTypeDescriptor,
  • getMapKeyTypeDescriptor,
  • elementTypeDescriptor,
  • getAnnotations,
  • isMap,
  • equals,
  • getAnnotation,
  • isPrimitive,
  • narrow,
  • toString

Popular in Java

  • Reading from database using SQL prepared statement
  • getSupportFragmentManager (FragmentActivity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • startActivity (Activity)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Runner (org.openjdk.jmh.runner)
  • 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