package models.relationships;

import play.libs.F.Function;
import play.libs.F.Promise;

import constants.RelationshipType;
import models.nodes.CombinationGroup;
import models.nodes.OutputString;
import managers.relationships.HasStringRelationshipManager;


public class HasStringRelationship extends TypedRelationship {

    public HasStringRelationship(CombinationGroup startNode,
                                 OutputString endNode) {
        super(RelationshipType.HAS, startNode, endNode);
    }
    public Promise<Boolean> create() {
        return this.exists().flatMap(new CreateFunction());
    }

    public static Promise<Boolean> delete(CombinationGroup startNode,
                                          OutputString endNode) {
        return HasStringRelationshipManager.delete(startNode, endNode);
    }

    private class CreateFunction implements
                                     Function<Boolean, Promise<Boolean>> {
        public Promise<Boolean> apply(Boolean exists) {
            if (exists) {
                return Promise.pure(false);
            }
            return HasStringRelationshipManager
                .create(HasStringRelationship.this);
        }
    }

}

@@ -492,24 +492,25 @@
 ode);%0A    %7D%0A
+%0A
     public P

Clean up: Fix formatting.