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

org.nuiton.topia.replication.model.ReplicationOperationDef Maven / Gradle / Ivy

There is a newer version: 4.0
Show newest version
/*
 * #%L
 * ToPIA :: Service Replication
 * 
 * $Id: ReplicationOperationDef.java 2245 2011-04-14 12:47:09Z tchemit $
 * $HeadURL: http://svn.nuiton.org/svn/topia/tags/topia-2.6.6/topia-service-replication/src/main/java/org/nuiton/topia/replication/model/ReplicationOperationDef.java $
 * %%
 * Copyright (C) 2004 - 2010 CodeLutin
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public 
 * License along with this program.  If not, see
 * .
 * #L%
 */

package org.nuiton.topia.replication.model;

import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaEntityEnum;
import org.nuiton.topia.replication.TopiaReplicationOperation;

import java.util.Arrays;

/**
 * Definition of a concrete operation to execute.
 * 

* A such operation involves : *

    *
  • the replication node
  • *
  • the replication phase
  • *
  • the replication operation type
  • *
  • the replication operation arguments
  • *
*

* This definition is detected when building replication model. *

* Then when starting replication, based on this definition, we can instanciate * the operation to execute. *

* Note: Such objects can be comparable via their {@link #phase}. * * @author tchemit * @since 2.2.0 */ public class ReplicationOperationDef implements Comparable { protected final ReplicationOperationPhase phase; protected final Class operationClass; protected final ReplicationNode node; protected final Object[] parameters; public ReplicationOperationDef( ReplicationOperationPhase phase, Class operation, ReplicationNode node, Object... parameters) { operationClass = operation; this.phase = phase; this.node = node; this.parameters = parameters; } public ReplicationNode getNode() { return node; } public Object[] getParameters() { return parameters; } public Class getOperationClass() { return operationClass; } public ReplicationOperationPhase getPhase() { return phase; } public TopiaEntityEnum getContract() { return node.getContract(); } public Class getEntityType() { return node.getEntityType(); } @Override public String toString() { return " <" + operationClass.getSimpleName() + " on " + node + (parameters.length == 0 ? "" : ", params:" + Arrays.toString(parameters)) + ">"; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ReplicationOperationDef that = (ReplicationOperationDef) o; if (!node.equals(that.node)) return false; if (!operationClass.equals(that.operationClass)) return false; return phase == that.phase; } @Override public int hashCode() { int result = phase.hashCode(); result = 31 * result + operationClass.hashCode(); result = 31 * result + node.hashCode(); return result; } @Override public int compareTo(ReplicationOperationDef o) { int result = getPhase().compareTo(o.getPhase()); return result; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy