use of java.util.AbstractList in project neo4j by neo4j.
the class DependenciesTest method givenSatisfiedTypeWhenResolveWithSuperTypeThenInstanceReturned.
@Test
public void givenSatisfiedTypeWhenResolveWithSuperTypeThenInstanceReturned() throws Exception {
// Given
Dependencies dependencies = new Dependencies();
AbstractList foo = new ArrayList();
dependencies.satisfyDependency(foo);
// When
AbstractList instance = dependencies.resolveDependency(AbstractList.class);
// Then
assertThat(instance, equalTo(foo));
}
use of java.util.AbstractList in project camel by apache.
the class CxfPayload method getBody.
/**
* Get the body as a List of DOM elements.
* This will cause the Body to be fully read and parsed.
* @return
*/
public List<Element> getBody() {
return new AbstractList<Element>() {
public boolean add(Element e) {
return body.add(new DOMSource(e));
}
public Element set(int index, Element element) {
Source s = body.set(index, new DOMSource(element));
try {
return StaxUtils.read(s).getDocumentElement();
} catch (XMLStreamException e) {
throw new RuntimeCamelException("Problem converting content to Element", e);
}
}
public void add(int index, Element element) {
body.add(index, new DOMSource(element));
}
public Element remove(int index) {
Source s = body.remove(index);
try {
return StaxUtils.read(s).getDocumentElement();
} catch (XMLStreamException e) {
throw new RuntimeCamelException("Problem converting content to Element", e);
}
}
public Element get(int index) {
Source s = body.get(index);
try {
Element el = StaxUtils.read(s).getDocumentElement();
addNamespace(el, nsMap);
body.set(index, new DOMSource(el));
return el;
} catch (Exception ex) {
throw new RuntimeCamelException("Problem converting content to Element", ex);
}
}
public int size() {
return body.size();
}
};
}
use of java.util.AbstractList in project GeoGig by boundlessgeo.
the class GeogigFeatureStore method addFeatures.
@Override
public final List<FeatureId> addFeatures(FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection) throws IOException {
if (Transaction.AUTO_COMMIT.equals(getTransaction())) {
throw new UnsupportedOperationException("GeoGIG does not support AUTO_COMMIT");
}
Preconditions.checkState(getDataStore().isAllowTransactions(), "Transactions not supported; head is not a local branch");
final WorkingTree workingTree = delegate.getWorkingTree();
final String path = delegate.getTypeTreePath();
ProgressListener listener = new DefaultProgressListener();
final List<FeatureId> insertedFids = Lists.newArrayList();
List<Node> deferringTarget = new AbstractList<Node>() {
@Override
public boolean add(Node node) {
String fid = node.getName();
String version = node.getObjectId().toString();
insertedFids.add(new FeatureIdVersionedImpl(fid, version));
return true;
}
@Override
public Node get(int index) {
throw new UnsupportedOperationException();
}
@Override
public int size() {
return 0;
}
};
Integer count = (Integer) null;
FeatureIterator<SimpleFeature> featureIterator = featureCollection.features();
try {
Iterator<SimpleFeature> features;
features = new FeatureIteratorIterator<SimpleFeature>(featureIterator);
/*
* Make sure to transform the incoming features to the native schema to avoid situations
* where geogig would change the metadataId of the RevFeature nodes due to small
* differences in the default and incoming schema such as namespace or missing
* properties
*/
final SimpleFeatureType nativeSchema = delegate.getNativeType();
features = Iterators.transform(features, new SchemaInforcer(nativeSchema));
workingTree.insert(path, features, listener, deferringTarget, count);
} catch (Exception e) {
throw new IOException(e);
} finally {
featureIterator.close();
}
return insertedFids;
}
use of java.util.AbstractList in project streamsupport by stefan-zobel.
the class MOAT method testList.
private static void testList(final List<Integer> l) {
// ----------------------------------------------------------------
try {
l.addAll(-1, Collections.<Integer>emptyList());
fail("Expected IndexOutOfBoundsException not thrown");
} catch (UnsupportedOperationException ignored) {
/* OK */
} catch (IndexOutOfBoundsException ignored) {
/* OK */
} catch (Throwable t) {
unexpected(t);
}
// l.subList(0,0) instanceof Serializable);
if (l.subList(0, 0) instanceof Serializable)
check(l instanceof Serializable);
equal(l instanceof RandomAccess, l.subList(0, 0) instanceof RandomAccess);
l.iterator();
l.listIterator();
l.listIterator(0);
l.listIterator(l.size());
THROWS(IndexOutOfBoundsException.class, () -> l.listIterator(-1), () -> l.listIterator(l.size() + 1));
if (l instanceof AbstractList) {
try {
int size = l.size();
AbstractList<Integer> abList = (AbstractList<Integer>) l;
Method m = AbstractList.class.getDeclaredMethod("removeRange", new Class[] { int.class, int.class });
m.setAccessible(true);
m.invoke(abList, new Object[] { 0, 0 });
m.invoke(abList, new Object[] { size, size });
equal(size, l.size());
} catch (UnsupportedOperationException ignored) {
/* OK */
} catch (Exception ex) {
// jdk9 module system may deny access
if (ex.getClass().getSimpleName().equals("InaccessibleObjectException")) {
return;
/* OK */
}
unexpected(ex);
} catch (Throwable t) {
unexpected(t);
}
}
}
use of java.util.AbstractList in project alfresco-remote-api by Alfresco.
the class GroupsImpl method getGroupMembers.
public CollectionWithPagingInfo<GroupMember> getGroupMembers(String groupId, final Parameters parameters) {
validateGroupId(groupId, false);
// Not allowed to list all members.
if (PermissionService.ALL_AUTHORITIES.equals(groupId)) {
throw new UnsupportedResourceOperationException();
}
Paging paging = parameters.getPaging();
// Retrieve sort column. This is limited for now to sort column due to
// v0 api implementation. Should be improved in the future.
Pair<String, Boolean> sortProp = getGroupsSortProp(parameters);
AuthorityType authorityType = null;
// Parse where clause properties.
Query q = parameters.getQuery();
if (q != null) {
MapBasedQueryWalkerOrSupported propertyWalker = new MapBasedQueryWalkerOrSupported(LIST_GROUP_MEMBERS_QUERY_PROPERTIES, null);
QueryHelper.walk(q, propertyWalker);
String memberTypeStr = propertyWalker.getProperty(PARAM_MEMBER_TYPE, WhereClauseParser.EQUALS, String.class);
authorityType = getAuthorityType(memberTypeStr);
}
PagingResults<AuthorityInfo> pagingResult = getAuthoritiesInfo(authorityType, groupId, sortProp, paging);
// Create response.
final List<AuthorityInfo> page = pagingResult.getPage();
int totalItems = pagingResult.getTotalResultCount().getFirst();
List<GroupMember> groupMembers = new AbstractList<GroupMember>() {
@Override
public GroupMember get(int index) {
AuthorityInfo authorityInfo = page.get(index);
return getGroupMember(authorityInfo);
}
@Override
public int size() {
return page.size();
}
};
return CollectionWithPagingInfo.asPaged(paging, groupMembers, pagingResult.hasMoreItems(), totalItems);
}
Aggregations