Package org.modelmapper.spi

Examples of org.modelmapper.spi.PropertyInfo


  @Override
  protected Class<?> getElementType(MappingContext<Object, Collection<Object>> context) {
    Mapping mapping = context.getMapping();
    if (mapping instanceof PropertyMapping) {
      PropertyInfo destInfo = ((PropertyMapping) mapping).getLastDestinationProperty();
      Class<?> elementType = TypeResolver.resolveArgument(destInfo.getGenericType(),
          destInfo.getInitialType());
      return elementType == Unknown.class ? Object.class : elementType;
    } else if (context.getGenericDestinationType() instanceof ParameterizedType)
      return Types.rawTypeFor(((ParameterizedType) context.getGenericDestinationType()).getActualTypeArguments()[0]);

    return Object.class;
View Full Code Here


    Mapping mapping = context.getMapping();

    Class<?> keyElementType = Object.class;
    Class<?> valueElementType = Object.class;
    if (mapping != null && mapping instanceof PropertyMapping) {
      PropertyInfo destInfo = ((PropertyMapping) mapping).getLastDestinationProperty();
      Class<?>[] elementTypes = TypeResolver.resolveArguments(destInfo.getGenericType(),
          destInfo.getMember().getDeclaringClass());
      if (elementTypes != null) {
        keyElementType = elementTypes[0] == Unknown.class ? Object.class : elementTypes[0];
        valueElementType = elementTypes[1] == Unknown.class ? Object.class : elementTypes[1];
      }
    }
View Full Code Here

      // Tracks whether a source token has been matched
      boolean[][] sourceMatches = new boolean[allSourceTokens.length][];

      // Build source tokens
      for (int i = 0; i < mapping.getSourceProperties().size(); i++) {
        PropertyInfo source = mapping.getSourceProperties().get(i);
        NameableType nameableType = NameableType.forPropertyType(source.getPropertyType());
        allSourceTokens[i] = configuration.getSourceNameTokenizer().tokenize(source.getName(),
            nameableType);
        sourceMatches[i] = new boolean[allSourceTokens[i].length];
        totalSourceTokens += allSourceTokens[i].length;
      }

      for (int destIndex = 0; destIndex < mapping.getDestinationProperties().size(); destIndex++) {
        PropertyInfo dest = mapping.getDestinationProperties().get(destIndex);
        NameableType nameableType = NameableType.forPropertyType(dest.getPropertyType());
        String[] destTokens = configuration.getDestinationNameTokenizer().tokenize(dest.getName(),
            nameableType);
        totalDestTokens += destTokens.length;

        for (int destTokenIndex = 0; destTokenIndex < destTokens.length
            && matches < totalSourceTokens; destTokenIndex++) {
View Full Code Here

   * delimiter.
   */
  public static String joinMembers(List<? extends PropertyInfo> properties) {
    StringBuilder builder = new StringBuilder();
    for (int i = 0; i < properties.size(); i++) {
      PropertyInfo info = properties.get(i);
      if (i > 0)
        builder.append("/");
      builder.append(Types.toString(info.getMember()));
    }

    return builder.toString();
  }
View Full Code Here

  public void shouldGetUnmappedMembers() {
    TypeMap<Person, PersonDTO> personMap = modelMapper.createTypeMap(Person.class, PersonDTO.class);
    List<PropertyInfo> memberInfo = personMap.getUnmappedProperties();
    assertEquals(memberInfo.size(), 2);

    PropertyInfo surName = memberInfo.get(0);
    assertEquals(surName.getMember().getName(), "setSurName");

    PropertyInfo employerName = memberInfo.get(1);
    assertEquals(employerName.getMember().getName(), "setEmployerName");
  }
View Full Code Here

TOP

Related Classes of org.modelmapper.spi.PropertyInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.