| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012 ForgeRock AS. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | * Add request implementation. |
| | | */ |
| | | final class AddRequestImpl extends AbstractRequestImpl<AddRequest> implements AddRequest { |
| | | |
| | | private final Entry entry; |
| | | |
| | | /** |
| | | * Creates a new add request backed by the provided entry. Modifications |
| | | * made to {@code entry} will be reflected in the returned add request. The |
| | | * returned add request supports updates to its list of controls, as well as |
| | | * updates to the name and attributes if the underlying entry allows. |
| | | * |
| | | * @param entry |
| | | * The entry to be added. |
| | | * @throws NullPointerException |
| | | * If {@code entry} was {@code null} . |
| | | */ |
| | | AddRequestImpl(final Entry entry) { |
| | | this.entry = entry; |
| | | } |
| | | |
| | | /** |
| | | * Creates a new add request that is an exact copy of the provided request. |
| | | * |
| | | * @param addRequest |
| | | * The add request to be copied. |
| | | * @throws NullPointerException |
| | | * If {@code addRequest} was {@code null} . |
| | | */ |
| | | AddRequestImpl(final AddRequest addRequest) { |
| | | super(addRequest); |
| | | this.entry = LinkedHashMapEntry.deepCopyOfEntry(addRequest); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | AddRequestImpl(final Entry entry) { |
| | | this.entry = entry; |
| | | } |
| | | |
| | | @Override |
| | | public <R, P> R accept(final ChangeRecordVisitor<R, P> v, final P p) { |
| | | return v.visitChangeRecord(p, this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean addAttribute(final Attribute attribute) { |
| | | return entry.addAttribute(attribute); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean addAttribute(final Attribute attribute, |
| | | final Collection<? super ByteString> duplicateValues) { |
| | | return entry.addAttribute(attribute, duplicateValues); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public AddRequest addAttribute(final String attributeDescription, final Object... values) { |
| | | entry.addAttribute(attributeDescription, values); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public AddRequest clearAttributes() { |
| | | entry.clearAttributes(); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean containsAttribute(final Attribute attribute, |
| | | final Collection<? super ByteString> missingValues) { |
| | | return entry.containsAttribute(attribute, missingValues); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean containsAttribute(final String attributeDescription, final Object... values) { |
| | | return entry.containsAttribute(attributeDescription, values); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean equals(final Object object) { |
| | | return entry.equals(object); |
| | | } |
| | | |
| | | @Override |
| | | public Iterable<Attribute> getAllAttributes() { |
| | | return entry.getAllAttributes(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Iterable<Attribute> getAllAttributes(final AttributeDescription attributeDescription) { |
| | | return entry.getAllAttributes(attributeDescription); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Iterable<Attribute> getAllAttributes(final String attributeDescription) { |
| | | return entry.getAllAttributes(attributeDescription); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Attribute getAttribute(final AttributeDescription attributeDescription) { |
| | | return entry.getAttribute(attributeDescription); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Attribute getAttribute(final String attributeDescription) { |
| | | return entry.getAttribute(attributeDescription); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public int getAttributeCount() { |
| | | return entry.getAttributeCount(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public DN getName() { |
| | | return entry.getName(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public int hashCode() { |
| | | return entry.hashCode(); |
| | | } |
| | | |
| | | @Override |
| | | public AttributeParser parseAttribute(final AttributeDescription attributeDescription) { |
| | | return entry.parseAttribute(attributeDescription); |
| | | } |
| | | |
| | | @Override |
| | | public AttributeParser parseAttribute(final String attributeDescription) { |
| | | return entry.parseAttribute(attributeDescription); |
| | | } |
| | | |
| | | @Override |
| | | public boolean removeAttribute(final Attribute attribute, |
| | | final Collection<? super ByteString> missingValues) { |
| | | return entry.removeAttribute(attribute, missingValues); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean removeAttribute(final AttributeDescription attributeDescription) { |
| | | return entry.removeAttribute(attributeDescription); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public AddRequest removeAttribute(final String attributeDescription, final Object... values) { |
| | | entry.removeAttribute(attributeDescription, values); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean replaceAttribute(final Attribute attribute) { |
| | | return entry.replaceAttribute(attribute); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public AddRequest replaceAttribute(final String attributeDescription, final Object... values) { |
| | | entry.replaceAttribute(attributeDescription, values); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public AddRequest setName(final DN dn) { |
| | | entry.setName(dn); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public AddRequest setName(final String dn) { |
| | | entry.setName(dn); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | AddRequest getThis() { |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public int hashCode() { |
| | | return entry.hashCode(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public AttributeParser parseAttribute(AttributeDescription attributeDescription) { |
| | | return entry.parseAttribute(attributeDescription); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public AttributeParser parseAttribute(String attributeDescription) { |
| | | return entry.parseAttribute(attributeDescription); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean equals(final Object object) { |
| | | return entry.equals(object); |
| | | } |
| | | |
| | | } |