in.workarounds.bundler.compiler.helper.PrimitiveArrayHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bundler-compiler Show documentation
Show all versions of bundler-compiler Show documentation
Compiler for bundler library
The newest version!
package in.workarounds.bundler.compiler.helper;
import com.squareup.javapoet.ArrayTypeName;
import com.squareup.javapoet.TypeName;
import in.workarounds.bundler.compiler.util.StringUtils;
/**
* Created by madki on 21/10/15.
*/
public class PrimitiveArrayHelper extends TypeHelper {
public PrimitiveArrayHelper(TypeName typeName) {
super(typeName);
if(!isPrimitiveArray(type)) {
throw new IllegalStateException("PrimitiveArrayHelper used for a non PrimitiveArray");
}
}
@Override
public String getBundleMethodSuffix() {
return StringUtils.getClassName(((ArrayTypeName) type).componentType.toString()) + "Array";
}
@Override
public boolean requiresCasting() {
return false;
}
public static boolean isPrimitiveArray(TypeName typeName) {
if(typeName instanceof ArrayTypeName) {
return ((ArrayTypeName) typeName).componentType.isPrimitive();
}
return false;
}
}