class EC2RaiderImpl implements EC2Raider {

    @Override
    public List<EC2InstanceTO> getEc2InstanceIdsWithCompulsoryTagsForAvailabilityZone(String availabilityZone, List<Tag> ignoreTags, List<Tag> compulsoryTags) {
        if (ignoreTags == null) {
            ignoreTags = new ArrayList<>();
        }
        if (compulsoryTags == null) {
            compulsoryTags = new ArrayList<>();
        }

        List<EC2InstanceTO> instances = new ArrayList<>();

        for (Reservation reservation : getReservationsByAvailabilityZone(availabilityZone)) {
            for (Instance instance : reservation.getInstances()) {
                if (Ec2Utils.isAwsInfrastructure(instance)) {
                    continue;
                }
                if(instance.getState().getName().equalsIgnoreCase("terminated")) {
                    continue;
                }

                // OR condition with ignoreTags and AND condition with compulsoryTags
                // 1. If any one of the ignore tags is present then instance will be ignored
                // 2. For instance to be considered all compulsory tags should be present.

                boolean flag = true;

                for (Tag instanceTag : instance.getTags()) {
                    boolean instanceContainsTag = false;
                    for (Tag ignoreTag : ignoreTags) {
                        if (ignoreTag.equals(instanceTag)) {
                            instanceContainsTag = true;
                            break;
                        }
                    }
                    if(instanceContainsTag) {
                        flag = false;
                        break;
                    }
                }

                if (!flag) {
                    continue;
                }

                flag = CucumberHelperFunctions.containsAllCompulsoryTags(compulsoryTags, instance.getTags());

                if (flag) {
                    EC2InstanceTO ec2InstanceTO = createEc2Instance(instance);
                    instances.add(ec2InstanceTO);
                }
            }
        }
        return instances;
    }

    public  EC2RaiderImpl();

}