blocks.service.BlockTypeReference Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of service-block Show documentation
Show all versions of service-block Show documentation
Blocks Framework - service-block
package blocks.service;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
public abstract class BlockTypeReference implements Comparable>
{
protected final Type _type;
protected BlockTypeReference()
{
Type superClass = getClass().getGenericSuperclass();
if (superClass instanceof Class>) { // sanity check, should never happen
throw new IllegalArgumentException("Internal error: TypeReference constructed without actual type information");
}
_type = ((ParameterizedType) superClass).getActualTypeArguments()[0];
}
public Type getType() { return _type; }
/**
* The only reason we define this method (and require implementation
* of Comparable
) is to prevent constructing a
* reference without type information.
*/
@Override
public int compareTo(BlockTypeReference o) { return 0; }
// just need an implementation, not a good one... hence ^^^
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy