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/04 11:54:33 UTC
[jira] [Created] (JOHNZON-19) rework readCollection() generics
Romain Manni-Bucau created JOHNZON-19:
-----------------------------------------
Summary: rework readCollection() generics
Key: JOHNZON-19
URL: https://issues.apache.org/jira/browse/JOHNZON-19
Project: Johnzon
Issue Type: Bug
Reporter: Romain Manni-Bucau
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)