2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.sal.dom.store.impl;
10 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction;
12 import com.google.common.base.Objects;
13 import com.google.common.base.Objects.ToStringHelper;
14 import com.google.common.base.Preconditions;
17 * Abstract DOM Store Transaction
19 * Convenience super implementation of DOM Store transaction which provides
20 * common implementation of {@link #toString()} and {@link #getIdentifier()}.
24 abstract class AbstractDOMStoreTransaction implements DOMStoreTransaction {
25 private final Object identifier;
27 protected AbstractDOMStoreTransaction(final Object identifier) {
28 this.identifier = Preconditions.checkNotNull(identifier,"Identifier must not be null.");
32 public final Object getIdentifier() {
37 public final String toString() {
38 return addToStringAttributes(Objects.toStringHelper(this)).toString();
42 * Add class-specific toString attributes.
44 * @param toStringHelper
45 * ToStringHelper instance
46 * @return ToStringHelper instance which was passed in
48 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
49 return toStringHelper.add("id", identifier);