Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2011 the original author or authors. 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.springframework.data.neo4j.support.path;
 
 

Author(s):
mh
Since:
26.02.11
 
 @SuppressWarnings("unchecked"// TODO DefaultNode/RelationshipBacked
 public class ConvertingEntityPath<S,E> implements EntityPath<S,E> {
 
     private final Neo4jTemplate template;
 
     @Override
     public <T> T startEntity(Class<T>... types) {
     }
 
     private <T> T projectEntityToFirstParameterOrCreateFromStoredType(Node nodeClass<T>... types) {
         if (node==nullreturn null;
         if (types==null || types.length==0) return .createEntityFromStoredType(node.);
         return .projectTo(nodetypes[0]);
     }
 
     @Override
     public <T> T endEntity(Class<T>... types) {
     }
     @Override
     public <T> T lastRelationshipEntity(Class<T>... types) {
         Relationship relationship = lastRelationship();
         if (relationship==nullreturn null;
         return .projectTo(relationshipgetFirstOrDefault((Class<T>) DefaultRelationshipBacked.classtypes));
     }
 
     private static <T> T getFirstOrDefault(final T defaultValue, T... values) {
         if (values == null || values.length == 0) return defaultValue;
         else return values[0];
     }
 
     @Override
     public <T> Iterable<T> nodeEntities() {
         return new IterableWrapper<T,Node>(nodes()) {
             @Override
             protected T underlyingObjectToObject(Node node) {
                 return .createEntityFromStoredType(nodenull);
             }
         };
     }
 
     @Override
     public <T> Iterable<T> relationshipEntities(final Class<T>... relationships) {
         return new IterableWrapper<T,Relationship>(relationships()) {
             @Override
             protected T underlyingObjectToObject(Relationship relationship) {
                 return .projectTo(relationshipgetFirstOrDefault((Class<T>) DefaultRelationshipBacked.classrelationships));
             }
         };
     }
 
     @Override
     public <T> Iterable<T> allPathEntities(final Class<T>... relationships) {
         return new IterableWrapper<T,PropertyContainer>() {
             @Override
             protected T underlyingObjectToObject(PropertyContainer element) {
                 return .projectTo(elementgetFirstOrDefault((Class<T>) DefaultRelationshipBacked.classrelationships));
             }
         };
     }
 
 
     public ConvertingEntityPath(Path delegateNeo4jTemplate template) {
         this. = delegate;
        this. = template;
    }
    private final Path delegate;
    @Override
    public Node startNode() {
        return .startNode();
    }
    @Override
    public Node endNode() {
        return .endNode();
    }
    @Override
    public Relationship lastRelationship() {
        return .lastRelationship();
    }
    @Override
    public Iterable<Relationshiprelationships() {
        return .relationships();
    }
    @Override
        return .reverseRelationships();
    }
    @Override
    public Iterable<NodereverseNodes() {
        return .reverseNodes();
    }
    @Override
    public Iterable<Nodenodes() {
        return .nodes();
    }
    @Override
    public int length() {
        return .length();
    }
    @Override
    public Iterator<PropertyContaineriterator() {
        return .iterator();
    }
New to GrepCode? Check out our FAQ X