Uploaded image for project: 'Johnzon'
  1. Johnzon
  2. JOHNZON-19

rework readCollection() generics

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.2-incubating
    • Mapper
    • None

    Description

      seems that for List<A> List and A are mixed in generics.

      PS: would be also great to provide a JohnzonParameteriedType. Can be:

      public class JohnzonParameteriedType implements ParameterizedType
      {    
          private final Type rawType;
          private final Type[] types;
      
          public OwbParametrizedTypeImpl(Type raw, Type... types)
          {
              rawType = raw;
              this.types = types;
          }
          
          @Override
          public Type[] getActualTypeArguments()
          {
              return types.clone();
          }
          
          @Override
          public Type getOwnerType()
          {
              return null;
          }
      
          @Override
          public Type getRawType()
          {
              return rawType;
          }
      
          
          
          /* (non-Javadoc)
           * @see java.lang.Object#hashCode()
           */
          @Override
          public int hashCode()
          {
             return Arrays.hashCode(types) ^ (rawType == null ? 0 : rawType.hashCode());
          }
      
          /* (non-Javadoc)
           * @see java.lang.Object#equals(java.lang.Object)
           */
          @Override
          public boolean equals(Object obj)
          {
             if (this == obj)
             {
                return true;
             }
             else if (obj instanceof ParameterizedType)
             {
                ParameterizedType that = (ParameterizedType) obj;
                Type thatOwnerType = that.getOwnerType();
                Type thatRawType = that.getRawType();
                return (owner == null ? thatOwnerType == null : owner.equals(thatOwnerType))
                        && (rawType == null ? thatRawType == null : rawType.equals(thatRawType))
                        && Arrays.equals(types, that.getActualTypeArguments());
             }
             else
             {
                return false;
             }
             
          }
      
          public String toString()
          {
              StringBuilder buffer = new StringBuilder();
              buffer.append(((Class<?>) rawType).getSimpleName());
              Type[] actualTypes = getActualTypeArguments();
              if(actualTypes.length > 0)
              {
                  buffer.append("<");
                  int length = actualTypes.length;
                  for(int i=0;i<length;i++)
                  {
                      buffer.append(actualTypes[i].toString());
                      if(i != actualTypes.length-1)
                      {
                          buffer.append(",");
                      }
                  }
                  
                  buffer.append(">");
              }
              
              return buffer.toString();
          }
      }
      
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            romain.manni-bucau Romain Manni-Bucau
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: