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

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

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

origin: spring-projects/spring-framework

private boolean canConvertValue(TypeDescriptor sourceType, TypeDescriptor targetType) {
  return ConversionUtils.canConvertElements(sourceType.getMapValueTypeDescriptor(),
      targetType.getMapValueTypeDescriptor(), this.conversionService);
}
origin: spring-projects/spring-framework

@Nullable
private Object convertValue(Object sourceValue, TypeDescriptor sourceType, @Nullable TypeDescriptor targetType) {
  if (targetType == null) {
    return sourceValue;
  }
  return this.conversionService.convert(sourceValue, sourceType.getMapValueTypeDescriptor(sourceValue), targetType);
}
origin: spring-projects/spring-framework

@Override
public void setValue(@Nullable Object newValue) {
  if (this.mapEntryDescriptor.getMapValueTypeDescriptor() != null) {
    newValue = this.typeConverter.convertValue(newValue, TypeDescriptor.forObject(newValue),
        this.mapEntryDescriptor.getMapValueTypeDescriptor());
  }
  this.map.put(this.key, newValue);
}
origin: spring-projects/spring-framework

/**
 * If this type is a {@link Map}, creates a mapValue {@link TypeDescriptor}
 * from the provided map value.
 * <p>Narrows the {@link #getMapValueTypeDescriptor() mapValueType} property
 * to the class of the provided map value. For example, if this describes a
 * {@code java.util.Map&lt;java.lang.String, java.lang.Number&lt;} and the value
 * argument is a {@code java.lang.Integer}, the returned TypeDescriptor will be
 * {@code java.lang.Integer}. If this describes a {@code java.util.Map&lt;?, ?&gt;}
 * and the value argument is a {@code java.lang.Integer}, the returned
 * TypeDescriptor will be {@code java.lang.Integer} as well.
 * <p>Annotation and nested type context will be preserved in the narrowed
 * TypeDescriptor that is returned.
 * @param mapValue the map value
 * @return the map value type descriptor
 * @throws IllegalStateException if this type is not a {@code java.util.Map}
 * @see #narrow(Object)
 */
@Nullable
public TypeDescriptor getMapValueTypeDescriptor(Object mapValue) {
  return narrow(mapValue, getMapValueTypeDescriptor());
}
origin: spring-projects/spring-framework

@Override
public TypedValue getValue() {
  Object value = this.map.get(this.key);
  exitTypeDescriptor = CodeFlow.toDescriptor(Object.class);
  return new TypedValue(value, this.mapEntryDescriptor.getMapValueTypeDescriptor(value));
}
origin: spring-projects/spring-framework

@Override
public boolean equals(Object other) {
  if (this == other) {
    return true;
  }
  if (!(other instanceof TypeDescriptor)) {
    return false;
  }
  TypeDescriptor otherDesc = (TypeDescriptor) other;
  if (getType() != otherDesc.getType()) {
    return false;
  }
  if (!annotationsMatch(otherDesc)) {
    return false;
  }
  if (isCollection() || isArray()) {
    return ObjectUtils.nullSafeEquals(getElementTypeDescriptor(), otherDesc.getElementTypeDescriptor());
  }
  else if (isMap()) {
    return (ObjectUtils.nullSafeEquals(getMapKeyTypeDescriptor(), otherDesc.getMapKeyTypeDescriptor()) &&
        ObjectUtils.nullSafeEquals(getMapValueTypeDescriptor(), otherDesc.getMapValueTypeDescriptor()));
  }
  else {
    return true;
  }
}
origin: spring-projects/spring-framework

@Test
public void mapValueType() {
  TypeDescriptor desc = TypeDescriptor.valueOf(Map.class);
  Integer value = Integer.valueOf(3);
  desc = desc.getMapValueTypeDescriptor(value);
  assertEquals(Integer.class, desc.getType());
}
origin: spring-projects/spring-framework

@Test
public void createMapWithNullElements() throws Exception {
  TypeDescriptor typeDescriptor = TypeDescriptor.map(LinkedHashMap.class, null, null);
  assertThat(typeDescriptor.getMapKeyTypeDescriptor(), nullValue());
  assertThat(typeDescriptor.getMapValueTypeDescriptor(), nullValue());
}
origin: spring-projects/spring-framework

@Test
public void mapValueTypePreserveContext() throws Exception {
  TypeDescriptor desc = new TypeDescriptor(getClass().getField("mapPreserveContext"));
  assertEquals(Integer.class, desc.getMapValueTypeDescriptor().getElementTypeDescriptor().getType());
  List<Integer> value = new ArrayList<>(3);
  desc = desc.getMapValueTypeDescriptor(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 multiValueMap() throws Exception {
  TypeDescriptor td = new TypeDescriptor(getClass().getField("multiValueMap"));
  assertTrue(td.isMap());
  assertEquals(String.class, td.getMapKeyTypeDescriptor().getType());
  assertEquals(List.class, td.getMapValueTypeDescriptor().getType());
  assertEquals(Integer.class,
      td.getMapValueTypeDescriptor().getElementTypeDescriptor().getType());
}
origin: spring-projects/spring-framework

isNestedAssignable(getMapValueTypeDescriptor(), typeDescriptor.getMapValueTypeDescriptor());
origin: spring-projects/spring-framework

@Test
public void fieldComplexTypeDescriptor2() throws Exception {
  TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("nestedMapField"));
  assertTrue(typeDescriptor.isMap());
  assertEquals(String.class,typeDescriptor.getMapKeyTypeDescriptor().getType());
  assertEquals(List.class, typeDescriptor.getMapValueTypeDescriptor().getType());
  assertEquals(Integer.class, typeDescriptor.getMapValueTypeDescriptor().getElementTypeDescriptor().getType());
  assertEquals("java.util.Map<java.lang.String, java.util.List<java.lang.Integer>>", typeDescriptor.toString());
}
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 elementTypeForMapSubclass() throws Exception {
  @SuppressWarnings("serial")
  class CustomMap extends HashMap<String, Integer> {
  }
  assertEquals(TypeDescriptor.valueOf(CustomMap.class).getMapKeyTypeDescriptor(), TypeDescriptor.valueOf(String.class));
  assertEquals(TypeDescriptor.valueOf(CustomMap.class).getMapValueTypeDescriptor(), TypeDescriptor.valueOf(Integer.class));
  assertEquals(TypeDescriptor.forObject(new CustomMap()).getMapKeyTypeDescriptor(), TypeDescriptor.valueOf(String.class));
  assertEquals(TypeDescriptor.forObject(new CustomMap()).getMapValueTypeDescriptor(), TypeDescriptor.valueOf(Integer.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 parameterMap() throws Exception {
  MethodParameter methodParameter = new MethodParameter(getClass().getMethod("testParameterMap", Map.class), 0);
  TypeDescriptor desc = new TypeDescriptor(methodParameter);
  assertEquals(Map.class, desc.getType());
  assertEquals(Map.class, desc.getObjectType());
  assertEquals("java.util.Map", desc.getName());
  assertEquals("java.util.Map<java.lang.Integer, java.util.List<java.lang.String>>", desc.toString());
  assertTrue(!desc.isPrimitive());
  assertEquals(0, desc.getAnnotations().length);
  assertFalse(desc.isCollection());
  assertFalse(desc.isArray());
  assertTrue(desc.isMap());
  assertEquals(TypeDescriptor.nested(methodParameter, 1), desc.getMapValueTypeDescriptor());
  assertEquals(TypeDescriptor.nested(methodParameter, 2), desc.getMapValueTypeDescriptor().getElementTypeDescriptor());
  assertEquals(Integer.class, desc.getMapKeyTypeDescriptor().getType());
  assertEquals(List.class, desc.getMapValueTypeDescriptor().getType());
  assertEquals(String.class, desc.getMapValueTypeDescriptor().getElementTypeDescriptor().getType());
}
origin: spring-projects/spring-framework

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

@Test
public void parameterList() throws Exception {
  MethodParameter methodParameter = new MethodParameter(getClass().getMethod("testParameterList", List.class), 0);
  TypeDescriptor desc = new TypeDescriptor(methodParameter);
  assertEquals(List.class, desc.getType());
  assertEquals(List.class, desc.getObjectType());
  assertEquals("java.util.List", desc.getName());
  assertEquals("java.util.List<java.util.List<java.util.Map<java.lang.Integer, java.lang.Enum<?>>>>", desc.toString());
  assertTrue(!desc.isPrimitive());
  assertEquals(0, desc.getAnnotations().length);
  assertTrue(desc.isCollection());
  assertFalse(desc.isArray());
  assertEquals(List.class, desc.getElementTypeDescriptor().getType());
  assertEquals(TypeDescriptor.nested(methodParameter, 1), desc.getElementTypeDescriptor());
  assertEquals(TypeDescriptor.nested(methodParameter, 2), desc.getElementTypeDescriptor().getElementTypeDescriptor());
  assertEquals(TypeDescriptor.nested(methodParameter, 3), desc.getElementTypeDescriptor().getElementTypeDescriptor().getMapValueTypeDescriptor());
  assertEquals(Integer.class, desc.getElementTypeDescriptor().getElementTypeDescriptor().getMapKeyTypeDescriptor().getType());
  assertEquals(Enum.class, desc.getElementTypeDescriptor().getElementTypeDescriptor().getMapValueTypeDescriptor().getType());
  assertFalse(desc.isMap());
}
origin: spring-projects/spring-framework

@Test
public void map() {
  TypeDescriptor desc = TypeDescriptor.map(Map.class, TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class));
  assertEquals(Map.class, desc.getType());
  assertEquals(Map.class, desc.getObjectType());
  assertEquals("java.util.Map", desc.getName());
  assertEquals("java.util.Map<java.lang.String, java.lang.Integer>", desc.toString());
  assertTrue(!desc.isPrimitive());
  assertEquals(0, desc.getAnnotations().length);
  assertFalse(desc.isCollection());
  assertFalse(desc.isArray());
  assertTrue(desc.isMap());
  assertEquals(String.class, desc.getMapKeyTypeDescriptor().getType());
  assertEquals(Integer.class, desc.getMapValueTypeDescriptor().getType());
}
org.springframework.core.convertTypeDescriptorgetMapValueTypeDescriptor

Javadoc

If this type is a Map and its value type is parameterized, returns the map's value type.

If the Map's value type is not parameterized, returns nullindicating the value 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
  • 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
  • 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

  • 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)
  • From CI to AI: The AI layer in your organization
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