]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/handler/Relationship.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / diagram / handler / Relationship.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.g2d.diagram.handler;
13
14
15 /**
16  * Defines the meaning of the relationship which must either remain internal
17  * to a specific implementation or be published as API of an implementation
18  * of this handler.
19  * 
20  * <p>
21  * A relationship <em>can</em> also have an inverse relationship but doesn't
22  * have to.
23  * </p>
24  * 
25  * <p>
26  * Implementations are strongly encouraged to have a <code>toString</code>
27  * that states the name of the relationship.
28  * </p>
29  * 
30  * @author Tuukka Lehtonen
31  */
32 public interface Relationship {
33
34     /**
35      * @return null if there is no inverse relationship to this
36      */
37     Relationship getInverse();
38
39     // Some standard relationships between elements
40
41     /**
42      * A compositional relationship between two elements. 
43      */
44     Relationship CHILD_OF = new Relationship() {
45         public Relationship getInverse() { return PARENT_OF; }
46         @Override
47         public String toString() { return "CHILD OF"; }
48     };
49     Relationship PARENT_OF = new Relationship() {
50         public Relationship getInverse() { return CHILD_OF; }
51         @Override
52         public String toString() { return "PARENT OF"; }
53     };
54
55     /**
56      * A relationship between two elements without any further semantics.
57      */
58     Relationship RELATED_TO = new Relationship() {
59         public Relationship getInverse() { return RELATED_TO; }
60         @Override
61         public String toString() { return "RELATED_TO"; }
62     };
63
64 }