All Downloads are FREE. Search and download functionalities are using the official Maven repository.

in.workarounds.bundler.compiler.helper.ParcelableArrayHelper Maven / Gradle / Ivy

The newest version!
package in.workarounds.bundler.compiler.helper;

import com.squareup.javapoet.ArrayTypeName;
import com.squareup.javapoet.TypeName;

import javax.lang.model.util.Elements;

/**
 * Created by madki on 22/10/15.
 */
public class ParcelableArrayHelper extends TypeHelper {

    public ParcelableArrayHelper(TypeName typeName, Elements elementUtils) {
        super(typeName);
        if (!isParcelableArray(type, elementUtils)) {
            throw new IllegalStateException("ParcelableArrayHelper used for a non ParcelableArray type");
        }
    }

    @Override
    public String getBundleMethodSuffix() {
        return "ParcelableArray";
    }

    @Override
    public boolean requiresCasting() {
        return true;
    }

    public static boolean isParcelableArray(TypeName typeName, Elements elementUtils) {
        return (typeName instanceof ArrayTypeName)
                &&
                TypeHelperFactory.isParcelable(
                        ((ArrayTypeName) typeName).componentType,
                        elementUtils
                );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy