Minor optimization: avoid creating a new unmodifiable wrapper if the object is already unmodifiable.
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | public static final Attribute unmodifiableAttribute(final Attribute attribute) |
| | | throws NullPointerException |
| | | { |
| | | if (attribute instanceof UnmodifiableAttribute) |
| | | { |
| | | return attribute; |
| | | } |
| | | else |
| | | { |
| | | return new UnmodifiableAttribute(attribute); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | public static Entry unmodifiableEntry(final Entry entry) |
| | | throws NullPointerException |
| | | { |
| | | if (entry instanceof UnmodifiableEntry) |
| | | { |
| | | return entry; |
| | | } |
| | | else |
| | | { |
| | | return new UnmodifiableEntry(entry); |
| | | } |
| | | } |
| | | |
| | | |
| | | |