Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
A few more examples, RdfStream now impls the new Java 8 type Stream, …
…Checkstyles has been temporarily turned off
  • Loading branch information
ajs6f committed Jan 30, 2015
1 parent 6823b27 commit dce9e42
Show file tree
Hide file tree
Showing 6 changed files with 403 additions and 51 deletions.
Expand Up @@ -27,8 +27,6 @@
import static org.fcrepo.kernel.RdfLexicon.VOAF_VOCABULARY;
import static org.fcrepo.kernel.impl.rdf.JcrRdfTools.getRDFNamespaceForJcrNamespace;
import static org.fcrepo.kernel.impl.utils.Uncheck.uncheck;
import java.util.Map;

import javax.jcr.NamespaceRegistry;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
Expand Down Expand Up @@ -59,12 +57,12 @@ public NamespaceRdfContext(final Session session) throws RepositoryException {
namespaces(stream(namespaceRegistry.getPrefixes()).filter(p -> !p.isEmpty() && !p.equals("jcr")).collect(
toMap(p -> p, uncheck(p -> getRDFNamespaceForJcrNamespace(namespaceRegistry.getURI(p))))));

concat(namespaces().entrySet().stream().flatMap(
concat(namespaces().entrySet().stream().<Triple>flatMap(
e -> {
final Node nsSubject = createURI(e.getValue());
return asList(create(nsSubject, type.asNode(), VOAF_VOCABULARY.asNode()),
create(nsSubject, HAS_NAMESPACE_PREFIX.asNode(), createLiteral(e.getKey())),
create(nsSubject, HAS_NAMESPACE_URI.asNode(), createLiteral(e.getValue()))).stream();
}));
}).iterator());
}
}
Expand Up @@ -96,7 +96,7 @@ public RootRdfContext(final FedoraResource resource,
key -> repository.getDescriptor(key)));

concat(descriptors.entrySet().stream().map(entry -> create(subject(), createURI(entry.getKey()),
createLiteral(entry.getValue()))));
createLiteral(entry.getValue()))).iterator());

final NodeTypeManager nodeTypeManager =
resource().getNode().getSession().getWorkspace().getNodeTypeManager();
Expand Down
@@ -0,0 +1,47 @@
/**
* Copyright 2014 DuraSpace, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.fcrepo.kernel.utils;

import com.google.common.base.Function;
import com.google.common.base.Predicate;


/**
* Conversions to Guava types from Java 8 types.
*
* @author ajs6f
*
*/
@Deprecated
public class GuavaConversions {
public static <T> Predicate<T> guavaPredicate(final java.util.function.Predicate<? super T> p) {
return new Predicate<T>(){

@Override
public boolean apply(final T t) {
return p.test(t);
}};
}

public static <T,R> Function<T, R> guavaFunction(final java.util.function.Function<? super T, ? extends R> f) {
return new Function<T, R>(){

@Override
public R apply(final T t) {
return f.apply(t);
}};
}
}

0 comments on commit dce9e42

Please sign in to comment.