/** * 2 Actions are considered equals if they share the same Entity, no matter the action identity or state. This is because 1 Entity can only have one action at a time. * * @param o Object to test for equality. * @return <code>true</code> if the test object is an action with the same Entity as this object. */ @Override public final boolean equals(final Object o) { return o instanceof Action && this.id.equals(((Action) o).id); }
/** * @return The used Entity hashCode. */ @Override public final int hashCode() { return this.id.hashCode(); }
/** * Retrieve an Id from a value. * * @param value Id value to get, positive and negative values are allowed, -1 is WORLD. * @return The Id with the internal value correspond to the parameter. */ public static ActionId valueOf(final int value) { if (!ActionId.LIST.containsKey(value)) { ActionId.LIST.put(value, new ActionId(value)); } return ActionId.LIST.get(value); }
@Override public ActionId from(String s) throws MappingException { assert s != null; try { return ActionId.valueOf(Integer.parseInt(s)); } catch (final NumberFormatException nfe) { throw new MappingException(nfe); } }
/** * Check if 2 Actions are the same type and coming from the same module. * * @param a Other action to test. * @return <code>true</code> if the 2 actions have the same type. */ public final boolean isSameType(final Action a) { return this.id.equals(a.id); }
@Override public int hashCode() { int result = id.hashCode(); result = 31 * result + entity.hashCode(); return result; } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ActionDto actionDto = (ActionDto) o; return id.equals(actionDto.id) && entity.equals(actionDto.entity); }