/** * {@inheritDoc} */ @Override public int hashCode() { return getName().hashCode(); }
@Override public int hashCode() { return getName().hashCode(); }
/** * Identify duplicate group names. * * @param groups a collection of group to validate. */ private void identifyDuplicateGroupNames(final Collection<Group> groups) { LOG.debug("identifyDuplicateGroupNames"); final List<String> groupNames = new ArrayList<String>(); for (final Group group : groups) { if (groupNames.contains(group.getName())) { throw new WroRuntimeException("Duplicate group name detected: " + group.getName()); } groupNames.add(group.getName()); } }
/** * Identify duplicate group names. * * @param groups a collection of group to validate. */ private void identifyDuplicateGroupNames(final Collection<Group> groups) { LOG.debug("identifyDuplicateGroupNames"); final List<String> groupNames = new ArrayList<String>(); for (final Group group : groups) { if (groupNames.contains(group.getName())) { throw new WroRuntimeException("Duplicate group name detected: " + group.getName()); } groupNames.add(group.getName()); } }
public WroModelInspector(final WroModel model) { Validate.notNull(model); for (final Group group : model.getGroups()) { map.put(group.getName(), group); } }
public WroModelInspector(final WroModel model) { Validate.notNull(model); for (final Group group : model.getGroups()) { map.put(group.getName(), group); } }
/** * Check if the provided group is a target group. */ private boolean isTargetGroup(final Group group) { notNull(group); final String targetGroups = getTargetGroups(); // null, means all groups are target groups return targetGroups == null || targetGroups.contains(group.getName()); }
/** * Check if the provided group is a target group. */ private boolean isTargetGroup(final Group group) { notNull(group); final String targetGroups = getTargetGroups(); // null, means all groups are target groups return targetGroups == null || targetGroups.contains(group.getName()); }
/** * @param resource * the {@link Resource} to search in all available groups. * @return t collection of group names containing provided resource. If the resource is not availalbe, an empty collection * will be returned. */ public Collection<String> getGroupNamesContainingResource(final String resourceUri) { Validate.notNull(resourceUri); final Set<String> groupNames = new TreeSet<String>(); for (final Group group : map.values()) { if (group.hasResource(resourceUri)) { groupNames.add(group.getName()); } } return groupNames; }
/** * @param resource * the {@link Resource} to search in all available groups. * @return t collection of group names containing provided resource. If the resource is not availalbe, an empty collection * will be returned. */ public Collection<String> getGroupNamesContainingResource(final String resourceUri) { Validate.notNull(resourceUri); final Set<String> groupNames = new TreeSet<String>(); for (final Group group : map.values()) { if (group.hasResource(resourceUri)) { groupNames.add(group.getName()); } } return groupNames; }
/** * Will check if a given resource was changed and will invoke the appropriate callback. */ private void checkResourceChange(final Resource resource, final Group group, final Callback callback, final AtomicBoolean isChanged) throws Exception { if (isChanged(resource, group.getName())) { isChanged.compareAndSet(false, true); callback.onResourceChanged(resource); lifecycleCallback.onResourceChanged(resource); } }
/** * Will check if a given resource was changed and will invoke the appropriate callback. */ private void checkResourceChange(final Resource resource, final Group group, final Callback callback, final AtomicBoolean isChanged) throws Exception { if (isChanged(resource, group.getName())) { isChanged.compareAndSet(false, true); callback.onResourceChanged(resource); lifecycleCallback.onResourceChanged(resource); } }
/** * @param type * of resources to collect. This value should not be null. * @return a new group with the same name as original containing filtered resources. The created group has the same * name. */ public final Group collectResourcesOfType(final ResourceType type) { notNull(type); final List<Resource> allResources = new ArrayList<Resource>(); allResources.addAll(getResources()); // retain only resources of needed type final List<Resource> filteredResources = new ArrayList<Resource>(); for (final Resource resource : getResources()) { if (type == resource.getType()) { if (filteredResources.contains(resource)) { LOG.warn("Duplicated resource detected: " + resource + ". This resource won't be included more than once!"); } else { filteredResources.add(resource); } } } final Group filteredGroup = new Group(getName()); filteredGroup.setResources(filteredResources); return filteredGroup; }
/** * @param type * of resources to collect. This value should not be null. * @return a new group with the same name as original containing filtered resources. The created group has the same * name. */ public final Group collectResourcesOfType(final ResourceType type) { Validate.notNull(type); final List<Resource> allResources = new ArrayList<Resource>(); allResources.addAll(getResources()); // retain only resources of needed type final List<Resource> filteredResources = new ArrayList<Resource>(); for (final Resource resource : getResources()) { if (type == resource.getType()) { if (filteredResources.contains(resource)) { LOG.warn("Duplicated resource detected: " + resource + ". This resource won't be included more than once!"); } else { filteredResources.add(resource); } } } final Group filteredGroup = new Group(getName()); filteredGroup.setResources(filteredResources); return filteredGroup; }
/** * @return a list of groups changed by incremental builds. */ private List<String> getIncrementalGroupNames() throws Exception { final List<String> changedGroupNames = new ArrayList<String>(); for (final Group group : getModel().getGroups()) { // skip processing non target groups if (isTargetGroup(group)) { for (final Resource resource : group.getResources()) { getLog().debug("checking delta for resource: " + resource); if (getResourceChangeHandler().isResourceChanged(resource)) { getLog().debug("detected change for resource: " + resource + " and group: " + group.getName()); changedGroupNames.add(group.getName()); // no need to check rest of resources from this group break; } } } } return changedGroupNames; }
/** * @return a list of groups changed by incremental builds. */ private List<String> getIncrementalGroupNames() throws Exception { final List<String> changedGroupNames = new ArrayList<String>(); for (final Group group : getModel().getGroups()) { // skip processing non target groups if (isTargetGroup(group)) { for (final Resource resource : group.getResources()) { getLog().debug("checking delta for resource: " + resource); if (getResourceChangeHandler().isResourceChanged(resource)) { getLog().debug("detected change for resource: " + resource + " and group: " + group.getName()); changedGroupNames.add(group.getName()); // no need to check rest of resources from this group break; } } } } return changedGroupNames; }
private Resource resourceForBundle(Group group, ResourceHtmlTag tag) throws Wro4jTagException { final String template = properties.getNameTemplate().forGroup(group.getName(), tag); String path = properties.getResourcePath(tag.getType()); for (String filename : lister.list(path)) { if (filename.matches(template)) { return Resource.create(ResourcePath.join(path, filename), tag.getType()); } } throw new Wro4jTagException("No file matching the template: '" + template + "' found in the path: " + properties.getResourcePath(tag.getType()) + " - have you built the compressed versions properly?"); }