Example #1
0
  /** {@inheritDoc} */
  @Override
  public List<Violation> getViolations(ViolationQuery violationQuery) {
    Resource resource = violationQuery.getResource();
    if (resource == null) {
      throw new IllegalArgumentException(
          "A resource must be set on the ViolationQuery in order to search for violations.");
    }

    if (!Scopes.isHigherThanOrEquals(resource, Scopes.FILE)) {
      return Collections.emptyList();
    }

    Bucket bucket = buckets.get(resource);
    if (bucket == null) {
      return Collections.emptyList();
    }

    List<Violation> violations = deprecatedViolations.get(bucket.getResource().getEffectiveKey());
    if (violationQuery.getSwitchMode() == ViolationQuery.SwitchMode.BOTH) {
      return violations;
    }

    List<Violation> filteredViolations = Lists.newArrayList();
    for (Violation violation : violations) {
      if (isFiltered(violation, violationQuery.getSwitchMode())) {
        filteredViolations.add(violation);
      }
    }
    return filteredViolations;
  }
Example #2
0
 public Collection<Dependency> getIncomingEdges(Resource to) {
   Map<Resource, Dependency> deps = incomingDependenciesByResource.get(to);
   if (deps != null) {
     return deps.values();
   }
   return Collections.emptyList();
 }
Example #3
0
 public Collection<Dependency> getOutgoingEdges(Resource from) {
   Map<Resource, Dependency> deps = outgoingDependenciesByResource.get(from);
   if (deps != null) {
     return deps.values();
   }
   return Collections.emptyList();
 }
Example #4
0
 @Override
 public List<Event> getEvents(Resource resource) {
   // currently events are not cached in memory
   Resource reload = getResource(resource);
   if (reload == null) {
     return Collections.emptyList();
   }
   if (eventPersister == null) {
     throw new UnsupportedOperationException("Event are not available in preview mode");
   }
   return eventPersister.getEvents(reload);
 }