LinkedList<SystemDescriptor<?>> retVal;
rLock.lock();
try {
Collection<SystemDescriptor<?>> sortMeOut;
if (filter instanceof IndexedFilter) {
IndexedFilter df = (IndexedFilter) filter;
if (df.getName() != null) {
Collection<SystemDescriptor<?>> scopedByName;
String name = df.getName();
IndexedListData ild = descriptorsByName.get(name);
scopedByName = (ild == null) ? null : ild.getSortedList();
if (scopedByName == null) {
scopedByName = Collections.emptyList();
}
if (df.getAdvertisedContract() != null) {
sortMeOut = new LinkedList<SystemDescriptor<?>>();
for (SystemDescriptor<?> candidate : scopedByName) {
if (candidate.getAdvertisedContracts().contains(df.getAdvertisedContract())) {
sortMeOut.add(candidate);
}
}
}
else {
sortMeOut = scopedByName;
}
}
else if (df.getAdvertisedContract() != null) {
String advertisedContract = df.getAdvertisedContract();
IndexedListData ild = descriptorsByAdvertisedContract.get(advertisedContract);
sortMeOut = (ild == null) ? null : ild.getSortedList();
if (sortMeOut == null) {
sortMeOut = Collections.emptyList();