Skip to content

Commit

Permalink
Slightly cleaner reading code for same functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Dec 15, 2013
1 parent 1f9ebe5 commit 6b697b0
Showing 1 changed file with 12 additions and 13 deletions.
Expand Up @@ -40,11 +40,12 @@
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static com.google.common.collect.Collections2.transform;
import static com.google.common.collect.ImmutableSortedSet.orderedBy;
import static com.google.common.collect.Maps.transformValues;
import static com.hp.hpl.jena.rdf.model.ResourceFactory.createResource;
import static java.util.Arrays.asList;
import static java.util.Collections.sort;
import static org.apache.http.HttpStatus.SC_BAD_REQUEST;
import static org.fcrepo.kernel.rdf.SerializationUtils.getDatasetSubject;
import static org.fcrepo.kernel.rdf.SerializationUtils.unifyDatasetModel;
Expand Down Expand Up @@ -97,25 +98,23 @@ public static LDPathTransform getNodeTypeTransform(final Node node,

LOGGER.debug("Found program node: {}", programNode.getPath());



final NodeType primaryNodeType = node.getPrimaryNodeType();

final List<NodeType> supertypes =
asList(primaryNodeType.getSupertypes());
sort(supertypes, nodeTypeComp);

final List<NodeType> mixinTypes = asList(node.getMixinNodeTypes());
sort(mixinTypes, nodeTypeComp);
final Set<NodeType> supertypes =
orderedBy(nodeTypeComp).add(primaryNodeType.getSupertypes())
.build();
final Set<NodeType> mixinTypes =
orderedBy(nodeTypeComp).add(node.getMixinNodeTypes()).build();

// start with mixins, primary type, and supertypes of primary type
final ImmutableList.Builder<NodeType> nodeTypesB =
new ImmutableList.Builder<NodeType>().addAll(mixinTypes).add(
primaryNodeType).addAll(supertypes);

// add supertypes of mixins
for (final NodeType mixin : mixinTypes) {
final List<NodeType> mixinSupers = asList(mixin.getDeclaredSupertypes());
sort(mixinSupers, nodeTypeComp);
nodeTypesB.addAll(mixinSupers);
nodeTypesB.addAll(orderedBy(nodeTypeComp).add(
mixin.getDeclaredSupertypes()).build());
}

final List<NodeType> nodeTypes = nodeTypesB.build();
Expand Down

0 comments on commit 6b697b0

Please sign in to comment.