/* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (this == obj) { return true; // Compare pointers } if (obj == null) { return false; // False if obj is null } if (!(obj instanceof DiamondImpl)) { return false; // False is obj is not of same instance } DiamondImpl other = (DiamondImpl) obj; if (directionStr != other.getDirectionStr()) { return false; // False if direction does not match } if (policy == null) { if (other.policy != null) { return false; // False if contained policy is null, and obj's policy is not null } } else if (!policy.equals(other.getPolicy())) { return false; // False if contained policy does not match } if (getRelationIdentifier() == null) { if (other.getRelationIdentifier() != null) { return false; // False if contained relation identifier is null, and obj's relation // identifier is not null } } else if (!getRelationIdentifier().equals(other.getRelationIdentifier())) { return false; // False if relationIdentifier does not match } return true; // If reached here, true }
public PolicyImpl copy() { PolicyImpl temp = policy.copy(); if (implicitRelId != null) { return new DiamondImpl(temp, new String(implicitRelId), getDirection()); } else if (explicitRelId != null) { return new DiamondImpl(temp, explicitRelId, getDirection()); } else { return new DiamondImpl(temp, patientRecordRelId, getDirection()); } }
/* (non-Javadoc) * @see java.lang.Object#hashCode() */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + "Diamond".hashCode(); result = prime * result + ((directionStr == null) ? 0 : directionStr.hashCode()); result = prime * result + ((policy == null) ? 0 : policy.hashCode()); result = prime * result + ((getRelationIdentifier() == null) ? 0 : getRelationIdentifier().hashCode()); return result; }
@Override public StoredObject createPolicy( String name, String policyText, Map<String, PropertyData<?>> propMap, String user, Acl addACEs, Acl removeACEs) { PolicyImpl policy = new PolicyImpl(); policy.createSystemBasePropertiesWhenCreated(propMap, user); policy.setCustomProperties(propMap); policy.setRepositoryId(fRepositoryId); policy.setName(name); policy.setPolicyText(policyText); String id = storeObject(policy); policy.setId(id); applyAcl(policy, addACEs, removeACEs); return policy; }