All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opendaylight.persistence.common.query.UpdateQuery Maven / Gradle / Ivy

Go to download

Abstractions of the persistence API that are common to any database or datastore implementation

There is a newer version: 1.0.4-Lithium-SR4
Show newest version
/**
 * Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.persistence.common.query;

import javax.annotation.Nonnull;

import org.opendaylight.persistence.DataStore;
import org.opendaylight.persistence.PersistenceException;
import org.opendaylight.persistence.Query;
import org.opendaylight.persistence.dao.BaseDao;
import org.opendaylight.yangtools.concepts.Identifiable;

/**
 * Query to update the given object in the data store.
 * 
 * @param  type of the identifiable object (object to store in the data store)
 * @param  type of the query's execution context; the context managed by the {@link DataStore}
 * @author Fabiel Zuniga
 * @author Nachiket Abhyankar
 */
public final class UpdateQuery, C> implements Query {

    private T identifiable;
    private BaseDao dao;

    private UpdateQuery(@Nonnull T identifiable, @Nonnull BaseDao dao) {
        this.identifiable = identifiable;
        this.dao = dao;
    }

    /**
     * Creates a query.
     * 

* This method is a convenience to infer the generic types. * * @param identifiable object to update * @param dao DAO to assist the query * @return the query */ public static , C> Query createQuery(@Nonnull T identifiable, @Nonnull BaseDao dao) { return new UpdateQuery(identifiable, dao); } @Override public T execute(C context) throws PersistenceException { return this.dao.update(this.identifiable, context); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy