| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
package org.dishevelled.iconbundle.impl; |
| 25 | |
|
| 26 | |
import org.dishevelled.iconbundle.IconSize; |
| 27 | |
import org.dishevelled.iconbundle.IconState; |
| 28 | |
import org.dishevelled.iconbundle.IconTextDirection; |
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
final class IconBundleKey |
| 37 | |
{ |
| 38 | |
|
| 39 | |
private static final int HASH_START = 17; |
| 40 | |
|
| 41 | |
|
| 42 | |
private static final int HASH_FACTOR = 37; |
| 43 | |
|
| 44 | |
|
| 45 | |
private final IconTextDirection direction; |
| 46 | |
|
| 47 | |
|
| 48 | |
private final IconState state; |
| 49 | |
|
| 50 | |
|
| 51 | |
private final IconSize size; |
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
public IconBundleKey(final IconTextDirection direction, |
| 63 | |
final IconState state, |
| 64 | |
final IconSize size) |
| 65 | 2657 | { |
| 66 | 2657 | if (direction == null) |
| 67 | |
{ |
| 68 | 2 | throw new IllegalArgumentException("direction must not be null"); |
| 69 | |
} |
| 70 | 2655 | if (state == null) |
| 71 | |
{ |
| 72 | 2 | throw new IllegalArgumentException("state must not be null"); |
| 73 | |
} |
| 74 | 2653 | if (size == null) |
| 75 | |
{ |
| 76 | 2 | throw new IllegalArgumentException("size must not be null"); |
| 77 | |
} |
| 78 | |
|
| 79 | 2651 | this.direction = direction; |
| 80 | 2651 | this.state = state; |
| 81 | 2651 | this.size = size; |
| 82 | 2651 | } |
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
public IconTextDirection getDirection() |
| 91 | |
{ |
| 92 | 2776 | return direction; |
| 93 | |
} |
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
public IconSize getSize() |
| 101 | |
{ |
| 102 | 2762 | return size; |
| 103 | |
} |
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
public IconState getState() |
| 111 | |
{ |
| 112 | 2768 | return state; |
| 113 | |
} |
| 114 | |
|
| 115 | |
|
| 116 | |
public int hashCode() |
| 117 | |
{ |
| 118 | 5165 | int result = HASH_START; |
| 119 | 5165 | result = HASH_FACTOR * result + direction.hashCode(); |
| 120 | 5165 | result = HASH_FACTOR * result + state.hashCode(); |
| 121 | 5165 | result = HASH_FACTOR * result + size.hashCode(); |
| 122 | 5165 | return result; |
| 123 | |
} |
| 124 | |
|
| 125 | |
|
| 126 | |
public boolean equals(final Object o) |
| 127 | |
{ |
| 128 | 2571 | if (this == o) |
| 129 | |
{ |
| 130 | 1 | return true; |
| 131 | |
} |
| 132 | 2570 | if (!(o instanceof IconBundleKey)) |
| 133 | |
{ |
| 134 | 2 | return false; |
| 135 | |
} |
| 136 | |
|
| 137 | 2568 | IconBundleKey key = (IconBundleKey) o; |
| 138 | |
|
| 139 | 2568 | return (direction.equals(key.getDirection())) |
| 140 | |
&& (state.equals(key.getState())) |
| 141 | |
&& (size.equals(key.getSize())); |
| 142 | |
} |
| 143 | |
|
| 144 | |
|
| 145 | |
public String toString() |
| 146 | |
{ |
| 147 | 42 | StringBuffer sb = new StringBuffer(); |
| 148 | 42 | sb.append("key("); |
| 149 | 42 | sb.append(direction); |
| 150 | 42 | sb.append(", "); |
| 151 | 42 | sb.append(state); |
| 152 | 42 | sb.append(", "); |
| 153 | 42 | sb.append(size); |
| 154 | 42 | sb.append(")"); |
| 155 | 42 | return sb.toString(); |
| 156 | |
} |
| 157 | |
} |