private static Collection<Artifact> getTargetListAttribute( RuleContext ruleContext, String attributeName) { return (ruleContext.attributes().has(attributeName, BuildType.LABEL_LIST) && ruleContext.getAttributeMode(attributeName) == Mode.TARGET) ? ruleContext.getPrerequisiteArtifacts(attributeName, Mode.TARGET).list() : ImmutableList.<Artifact>of(); }