]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/StaticSymbolImpl.java
Sync git svn branch with SVN repository r33324.
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / impl / StaticSymbolImpl.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.g2d.element.handler.impl;\r
13 \r
14 import org.simantics.g2d.element.handler.StaticSymbol;\r
15 import org.simantics.g2d.image.Image;\r
16 \r
17 /**\r
18  * A {@link StaticSymbol} implementation that provides a single static image\r
19  * provided to it during construction.\r
20  */\r
21 public class StaticSymbolImpl implements StaticSymbol {\r
22 \r
23     private static final long serialVersionUID = 9062542343545213793L;\r
24 \r
25     private final Image i;\r
26 \r
27     public StaticSymbolImpl(Image i) {\r
28         if (i == null)\r
29             throw new IllegalArgumentException("null arg");\r
30         this.i = i;\r
31     }\r
32 \r
33     @Override\r
34     public Image getImage() {\r
35         return i;\r
36     }\r
37 \r
38     @Override\r
39     public int hashCode() {\r
40         return i.hashCode();\r
41     }\r
42 \r
43     @Override\r
44     public boolean equals(Object obj) {\r
45         if (this == obj)\r
46             return true;\r
47         if (obj == null)\r
48             return false;\r
49         if (getClass() != obj.getClass())\r
50             return false;\r
51         StaticSymbolImpl other = (StaticSymbolImpl) obj;\r
52         return i.equals(other.i);\r
53     }\r
54 \r
55 }\r