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

org.opendaylight.persistence.common.query.DeleteQuery 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 java.io.Serializable;

import javax.annotation.Nonnull;

import org.opendaylight.persistence.DataStore;
import org.opendaylight.persistence.PersistenceException;
import org.opendaylight.persistence.Query;
import org.opendaylight.persistence.dao.Dao;

import com.google.common.base.Preconditions;

/**
 * Query to delete all objects from the data store that match the given filter.
 * 
 * @param  type of the associated filter
 * @param  type of the query's execution context; the context managed by the {@link DataStore}
 * @author Fabiel Zuniga
 * @author Nachiket Abhyankar
 */
public final class DeleteQuery implements Query {

    private F filter;
    private Dao dao;

    private DeleteQuery(@Nonnull F filter, @Nonnull Dao dao) {
        Preconditions.checkNotNull(dao, "dao");
        this.filter = filter;
        this.dao = dao;
    }

    /**
     * Creates a query.
     * 

* This method is a convenience to infer the generic types. * * @param filter filter * @param dao DAO to assist the query * @return the query */ public static Query createQuery(@Nonnull F filter, @Nonnull Dao dao) { return new DeleteQuery(filter, dao); } @Override public Void execute(C context) throws PersistenceException { this.dao.delete(this.filter, context); return null; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy