Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/core/range/ObjectRange.java @ 13514:0fbee3eb71f0
Ruby: import project.
author | Chris Seaton <chris.seaton@oracle.com> |
---|---|
date | Mon, 06 Jan 2014 17:12:09 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
13513:64a23ce736a0 | 13514:0fbee3eb71f0 |
---|---|
1 /* | |
2 * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. This | |
3 * code is released under a tri EPL/GPL/LGPL license. You can use it, | |
4 * redistribute it and/or modify it under the terms of the: | |
5 * | |
6 * Eclipse Public License version 1.0 | |
7 * GNU General Public License version 2 | |
8 * GNU Lesser General Public License version 2.1 | |
9 */ | |
10 package com.oracle.truffle.ruby.runtime.core.range; | |
11 | |
12 import com.oracle.truffle.ruby.runtime.core.*; | |
13 import com.oracle.truffle.ruby.runtime.core.array.*; | |
14 | |
15 public class ObjectRange extends RubyRange { | |
16 | |
17 private final Object begin; | |
18 private final Object end; | |
19 private final boolean excludeEnd; | |
20 | |
21 public ObjectRange(RubyClass rangeClass, Object begin, Object end, boolean excludeEnd) { | |
22 super(rangeClass); | |
23 this.begin = begin; | |
24 this.end = end; | |
25 this.excludeEnd = excludeEnd; | |
26 } | |
27 | |
28 @Override | |
29 public RubyArray toArray() { | |
30 throw new UnsupportedOperationException(); | |
31 } | |
32 | |
33 public Object getBegin() { | |
34 return begin; | |
35 } | |
36 | |
37 public Object getEnd() { | |
38 return end; | |
39 } | |
40 | |
41 @Override | |
42 public int hashCode() { | |
43 final int prime = 31; | |
44 int result = 1; | |
45 result = prime * result + ((begin == null) ? 0 : begin.hashCode()); | |
46 result = prime * result + ((end == null) ? 0 : end.hashCode()); | |
47 result = prime * result + (excludeEnd ? 1231 : 1237); | |
48 return result; | |
49 } | |
50 | |
51 @Override | |
52 public boolean equals(Object obj) { | |
53 if (this == obj) { | |
54 return true; | |
55 } | |
56 if (obj == null) { | |
57 return false; | |
58 } | |
59 if (!(obj instanceof ObjectRange)) { | |
60 return false; | |
61 } | |
62 ObjectRange other = (ObjectRange) obj; | |
63 if (begin == null) { | |
64 if (other.begin != null) { | |
65 return false; | |
66 } | |
67 } else if (!begin.equals(other.begin)) { | |
68 return false; | |
69 } | |
70 if (end == null) { | |
71 if (other.end != null) { | |
72 return false; | |
73 } | |
74 } else if (!end.equals(other.end)) { | |
75 return false; | |
76 } | |
77 if (excludeEnd != other.excludeEnd) { | |
78 return false; | |
79 } | |
80 return true; | |
81 } | |
82 | |
83 @Override | |
84 public boolean doesExcludeEnd() { | |
85 // TODO Auto-generated method stub | |
86 return false; | |
87 } | |
88 | |
89 } |