]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/ResourceArrayProperty.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.graph.impl / src / org / simantics / browsing / ui / graph / impl / ResourceArrayProperty.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.browsing.ui.graph.impl;
13
14 import org.simantics.browsing.ui.common.property.IArrayProperty;
15 import org.simantics.db.Resource;
16 import org.simantics.db.common.ResourceArray;
17 import org.simantics.utils.datastructures.slice.ValueRange;
18
19 /**
20  * @author Tuukka Lehtonen
21  */
22 public class ResourceArrayProperty extends ResourceProperty implements IArrayProperty {
23
24     protected final ValueRange range;
25
26     public ResourceArrayProperty(Type type, ValueRange range, Resource subject, Resource predicate, Resource value,
27             ResourceArray path) {
28         super(type, subject, predicate, value, path);
29         if (range == null)
30             throw new IllegalArgumentException("null value range");
31         this.range = range;
32     }
33
34     @Override
35     public ValueRange getRange() {
36         return range;
37     }
38
39     @Override
40     public String toString() {
41         return super.toString() + "[range=" + range + "]";
42     }
43
44     @Override
45     public int propertyHashCode() {
46         return super.propertyHashCode() * 31 + range.hashCode();
47     }
48
49     @Override
50     public boolean propertyEquals(Object obj) {
51         if (this == obj)
52             return true;
53         if (!super.propertyEquals(obj))
54             return false;
55         ResourceArrayProperty other = (ResourceArrayProperty) obj;
56         return range.equals(other.range);
57     }
58
59     @Override
60     public int hashCode() {
61         return range.hashCode() + 31 * super.hashCode();
62     }
63
64     @Override
65     public boolean equals(Object obj) {
66         if (this == obj)
67             return true;
68         if (!super.equals(obj))
69             return false;
70         ResourceArrayProperty other = (ResourceArrayProperty) obj;
71         return range.equals(other.range);
72     }
73
74     @Override
75     public IArrayProperty slice(ValueRange range) {
76         return new SlicedResourceArrayProperty(type, range, subject, predicate, value, path);
77     }
78
79     @Override
80     public boolean isSlice() {
81         return false;
82     }
83
84     private static class SlicedResourceArrayProperty extends ResourceArrayProperty {
85         public SlicedResourceArrayProperty(Type type, ValueRange range, Resource subject, Resource predicate,
86                 Resource value, ResourceArray path) {
87             super(type, range, subject, predicate, value, path);
88         }
89         @Override
90         public boolean isSlice() {
91             return true;
92         }
93     }
94
95 }