Permalink
Browse files

add @to and @from annotations with similar semantics as @incoming and @…

  • Loading branch information...
DirkMahler committed May 16, 2017
1 parent 695f3c9 commit 85191b4c2dd4b12be1e46c4b8626b8e773896490
@@ -33,21 +33,40 @@
*/
String value() default DEFAULT_VALUE;
/**
* Marks a property as outgoing relationship.
*/
@FromDefinition
@Retention(RUNTIME)
@Target({METHOD})
@interface Outgoing {
}
/**
* Marks a property as incoming relationship.
*/
@ToDefinition
@Retention(RUNTIME)
@Target({METHOD})
public @interface Incoming {
@interface Incoming {
}
/**
* Marks a property as outgoing relationship.
* Marks a property as from relationship.
*/
@FromDefinition
@Retention(RUNTIME)
@Target({METHOD})
public @interface Outgoing {
@interface From {
}
/**
* Marks a property as to relationship.
*/
@ToDefinition
@Retention(RUNTIME)
@Target({METHOD})
@interface To {
}
}
@@ -251,7 +251,7 @@ include::{srcBaseDir}/relation/qualified/Movie.java[tags=Class,indent=0]
==== Typed Relations With Properties
If a relation between two nodes shall have properties a dedicated type must be declared and registered in the XOUnit.
It must contain two properties returning the types of referenced types which are annotated with @Incoming and @Outgoing:
It must contain two properties returning the types of referenced types which are annotated with @From and @To:
[source,java]
.Directed.java
@@ -280,7 +280,7 @@ include::{srcBaseDir}/relation/typed/TypedRelationTest.java[tags=Create,indent=0
Note: If the typed relation references the same labeled type at both ends then the according properties of the latter
must also be annotated with @Outgoing and @Incoming:
must be annotated with @Outgoing and @Incoming:
[source,java]
.References.java
@@ -1,17 +1,17 @@
package com.buschmais.xo.neo4j.doc.relation.self;
import com.buschmais.xo.neo4j.api.annotation.Relation;
import com.buschmais.xo.neo4j.api.annotation.Relation.Incoming;
import com.buschmais.xo.neo4j.api.annotation.Relation.Outgoing;
import com.buschmais.xo.neo4j.api.annotation.Relation.From;
import com.buschmais.xo.neo4j.api.annotation.Relation.To;
// tag::Class[]
@Relation
public interface References {
@Outgoing
@From
Movie getReferencing();
@Incoming
@To
Movie getReferenced();
int getMinute();
@@ -1,17 +1,17 @@
package com.buschmais.xo.neo4j.doc.relation.typed;
import com.buschmais.xo.neo4j.api.annotation.Relation;
import com.buschmais.xo.neo4j.api.annotation.Relation.Incoming;
import com.buschmais.xo.neo4j.api.annotation.Relation.Outgoing;
import com.buschmais.xo.neo4j.api.annotation.Relation.From;
import com.buschmais.xo.neo4j.api.annotation.Relation.To;
// tag::Class[]
@Relation
public interface Directed {
@Outgoing
@From
Director getDirector();
@Incoming
@To
Movie getMovie();
int getYear();
@@ -1,9 +1,8 @@
package com.buschmais.xo.neo4j.test.relation.typed.composite;
import static com.buschmais.xo.neo4j.api.annotation.Relation.Incoming;
import static com.buschmais.xo.neo4j.api.annotation.Relation.Outgoing;
import com.buschmais.xo.neo4j.api.annotation.Relation;
import com.buschmais.xo.neo4j.api.annotation.Relation.From;
import com.buschmais.xo.neo4j.api.annotation.Relation.To;
@Relation
public interface TreeNodeRelation {
@@ -12,9 +11,9 @@
void setVersion(int version);
@Incoming
@To
TreeNode getChild();
@Outgoing
@From
TreeNode getParent();
}
@@ -1,17 +1,16 @@
package com.buschmais.xo.neo4j.test.relation.typed.composite;
import static com.buschmais.xo.neo4j.api.annotation.Relation.Incoming;
import static com.buschmais.xo.neo4j.api.annotation.Relation.Outgoing;
import com.buschmais.xo.neo4j.api.annotation.Relation;
import com.buschmais.xo.neo4j.api.annotation.Relation.From;
import com.buschmais.xo.neo4j.api.annotation.Relation.To;
@Relation("OneToOne")
public interface TypedOneToOneRelation extends TypedRelation {
@Outgoing
@From
A getA();
@Incoming
@To
B getB();
}
@@ -1,13 +1,13 @@
package com.buschmais.xo.spi.annotation;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Marks an annotation as relation definition, i.e. a type represents a relation if it is annotated with an annotation which itself is annotated by{@link RelationDefinition}.
*/
@@ -19,12 +19,12 @@
@Documented
@Retention(RUNTIME)
@Target(ANNOTATION_TYPE)
public @interface FromDefinition {
@interface FromDefinition {
}
@Documented
@Retention(RUNTIME)
@Target(ANNOTATION_TYPE)
public @interface ToDefinition {
@interface ToDefinition {
}
}

0 comments on commit 85191b4

Please sign in to comment.