public static Map<Integer, List<TagWrapper>> getCategoryMappingFromTagList(final Collection<TagWrapper> tags) {
        final HashMap<Integer, List<TagWrapper>> mapping = new HashMap<Integer, List<TagWrapper>>();
        for (final TagWrapper tag : tags) {
            final List<CategoryInTagWrapper> catList = tag.getCategories().getItems();
            if (catList != null) {
                for (final CategoryInTagWrapper cat : catList) {
                    if (!mapping.containsKey(cat.getId())) {
                        mapping.put(cat.getId(), new ArrayList<TagWrapper>());
                    }
                    mapping.get(cat.getId()).add(tag);
                }
            }
        }
        return mapping;
    }
public static Map < Integer , List < TagWrapper > > getCategoryMappingFromTagList ( final Collection < TagWrapper > tags ) { final HashMap < Integer , List < TagWrapper > > mapping = new HashMap < Integer , List < TagWrapper > > ( ) ; for ( final TagWrapper tag : tags ) { final List < CategoryInTagWrapper > catList = tag . getCategories ( ) . getItems ( ) ; if ( catList != null ) { for ( final CategoryInTagWrapper cat : catList ) { if ( ! mapping . containsKey ( cat . getId ( ) ) ) { mapping . put ( cat . getId ( ) , new ArrayList < TagWrapper > ( ) ) ; } mapping . get ( cat . getId ( ) ) . add ( tag ) ; } } } return mapping ; }
Converts a list of tags into a mapping of categories to tags. The key is the Category and the value is a List
of Tags for that category.

@param tags The List of tags to be converted.
@return The mapping of Categories to Tags.