class RestCollection {

    public Set<Entry<RestModelMetadata, T>> entrySet() {
        if (metadata.size() != models.size()) {
            throw new IllegalStateException("InternalError: keys and values out of sync");
        }
        ArrayList al = new ArrayList();
        for (int i = 0; i < metadata.size(); i++) {
            al.add(new RestCollectionEntry(metadata.get(i), models.get(i)));
        }
        return new TreeSet<Entry<RestModelMetadata, T>>(al);
    }

}