public static <T> ListWrapperCallback<T> ofList(final List<T> items) { return ofList(items, Integer.MAX_VALUE); }
public List<T> getItems(Indexes indexes) { final int startIndex = indexes.getMinIndex(size); if (startIndex != -1) { setStartIndex(startIndex); } return getPagingCallback().getItems(indexes); } };
public ListWrapper<T> expand(ExpandContext<ListWrapper<T>> context, EntityExpanderResolver expanderResolver, EntityCrawler entityCrawler) { final ListWrapper<T> entity = context.getEntity(); final Set<Field> collectionFields = Sets.newHashSet(); for (Class cls = entity.getClass(); cls != null; cls = cls.getSuperclass()) { final Field[] fields = cls.getDeclaredFields(); for (Field field : fields) { if (Collection.class.isAssignableFrom(field.getType())) { collectionFields.add(field); } } } if (collectionFields.isEmpty()) { throw new RuntimeException("Entity " + entity.getClass() + " has no collection field, cannot expand."); } if (collectionFields.size() > 1) { throw new RuntimeException("Entity " + entity.getClass() + " has more than one collection field, cannot determine which collection to expand."); } setFieldValue(collectionFields.iterator().next(), entity, entity.getCallback().getItems(context.getEntityExpandParameter().getIndexes(context.getExpandable()))); entityCrawler.crawl(entity, context.getEntityExpandParameter().getExpandParameter(context.getExpandable()), expanderResolver); return entity; }
public List<T> getItems(Indexes indexes) { return getPagingCallback().getItems(indexes); } };
public ListWrapperCallback<OsgiBundleDetails> getCallback() { return callback != null ? callback : ListWrapperCallBacks.identity(bundles); }
private OsgiBundles getUnexpandedBundles(final UriBuilder uriBuilder, Bundle[] bundles) { final List<OsgiBundleDetails> bundleDetails = getBundleDetails(uriBuilder, bundles); return new OsgiBundles(bundleDetails.size(), ListWrapperCallBacks.ofList(bundleDetails)); }
public List<T> getItems(Indexes indexes) { return getPagingCallback().getItems(indexes); } };
private OsgiServices getOsgiServices(final UriBuilder bundleUriBuilder, ServiceReference... serviceReferences) { final List<OsgiService> services = getServices(bundleUriBuilder, serviceReferences); return new OsgiServices(services.size(), ListWrapperCallBacks.ofList(services)); }