You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@johnzon.apache.org by "Romain Manni-Bucau (JIRA)" <ji...@apache.org> on 2014/11/09 22:12:33 UTC

[jira] [Resolved] (JOHNZON-19) rework readCollection() generics

     [ https://issues.apache.org/jira/browse/JOHNZON-19?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Romain Manni-Bucau resolved JOHNZON-19.
---------------------------------------
    Resolution: Fixed

> rework readCollection() generics
> --------------------------------
>
>                 Key: JOHNZON-19
>                 URL: https://issues.apache.org/jira/browse/JOHNZON-19
>             Project: Johnzon
>          Issue Type: Bug
>          Components: Mapper
>            Reporter: Romain Manni-Bucau
>             Fix For: 0.2-incubating
>
>
> seems that for List<A> List and A are mixed in generics.
> PS: would be also great to provide a JohnzonParameteriedType. Can be:
> {code}
> 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();
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)