public EntityReference(String name, EntityType type, EntityReference parent) { setName(name); setType(type); setParent(parent); }
/** * Create a new EntityReference. Note: Entity reference are immutable since 3.3M2. * * @param name name for the newly created entity reference, could not be null. * @param type type for the newly created entity reference, could not be null. * @param parent parent reference for the newly created entity reference, may be null. */ public EntityReference(String name, EntityType type, EntityReference parent) { setName(name); setType(type); setParent(parent); }
/** * Create a new EntityReference. Note: Entity reference are immutable since 3.3M2. * * @param name name for the newly created entity, could not be null. * @param type type for the newly created entity, could not be null. * @param parameters parameters for this reference, may be null * @since 10.6RC1 */ @Unstable public EntityReference(String name, EntityType type, Map<String, Serializable> parameters) { setName(name); setType(type); setParameters(parameters); }
/** * Create a new EntityReference. Note: Entity reference are immutable since 3.3M2. * * @param name name for the newly created entity, could not be null. * @param type type for the newly created entity, could not be null. * @param parent parent reference for the newly created entity reference, may be null. * @param parameters parameters for this reference, may be null * @since 3.3M2 */ public EntityReference(String name, EntityType type, EntityReference parent, Map<String, Serializable> parameters) { setName(name); setType(type); setParent(parent); setParameters(parameters); }
/** * {@inheritDoc} * * @see Object#clone() */ @Override public EntityReference clone() { EntityReference reference; try { reference = (EntityReference) super.clone(); } catch (CloneNotSupportedException e) { // Should never happen throw new RuntimeException("Failed to clone object", e); } reference.setName(getName()); reference.setType(getType()); if (getParent() != null) { reference.setParent(getParent().clone()); } return reference; }
/** * Clone an EntityReference, but replace one of the parent in the chain by an other one. * * @param reference the reference that is cloned * @param oldReference the old parent that will be replaced * @param newReference the new parent that will replace oldReference in the chain * @since 3.3M2 */ protected EntityReference(EntityReference reference, EntityReference oldReference, EntityReference newReference) { if (reference == null) { throw new IllegalArgumentException("Cloned reference must not be null"); } setName(reference.name); setType(reference.type); setParameters(reference.parameters); if (reference.parent == null) { if (oldReference == null) { setParent(newReference); } else { throw new IllegalArgumentException("The old reference [" + oldReference + "] does not belong to the parents chain of the reference [" + reference + "]"); } } else if (reference.parent.equals(oldReference)) { setParent(newReference); } else { setParent(new EntityReference(reference.parent, oldReference, newReference)); } }