001/*
002 * Copyright (c) 2014 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Florent Guillaume
011 */
012package org.nuxeo.ecm.core.storage.lock;
013
014import org.nuxeo.common.xmap.annotation.XNode;
015import org.nuxeo.common.xmap.annotation.XObject;
016import org.nuxeo.ecm.core.model.LockManager;
017
018/**
019 * Descriptor of a {@link LockManager} for the {@link LockManagerService}.
020 */
021@XObject(value = "lockmanager")
022public class LockManagerDescriptor {
023
024    public LockManagerDescriptor() {
025    }
026
027    @XNode("@name")
028    public String name;
029
030    @XNode("@class")
031    public Class<? extends LockManager> klass;
032
033    /** Copy constructor. */
034    public LockManagerDescriptor(LockManagerDescriptor other) {
035        name = other.name;
036        klass = other.klass;
037    }
038
039    public void merge(LockManagerDescriptor other) {
040        if (other.name != null) {
041            name = other.name;
042        }
043        if (other.klass != null) {
044            klass = other.klass;
045        }
046    }
047
048    @Override
049    public String toString() {
050        return getClass().getSimpleName() + '(' + name + ',' + klass.getName() + ')';
051    }
052
053}