Componente.java 2.95 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package LOGIC;

import java.io.Serializable;

/**
*
* @author Dalay
*/
public class Componente extends Instance implements Serializable {
private Instance instance1;
private Instance instance2;
public Componente(){
instance1 = new Instance();
instance2 = new Instance();
}

public Instance getInstance1() {
return instance1;
}

public void setInstance1(Instance instance1) {
this.instance1 = instance1;
}

public Instance getInstance2() {
return instance2;
}

public void setInstance2(Instance instance2) {
this.instance2 = instance2;
}
public Componente criaComponent(Instance i1, Instance i2){
Componente comp = new Componente();
// lista de canais
comp.setChannel(i1.getChannel());
for(int i =0; i< i2.getChannel().size(); i++){
if(!comp.getChannel().contains(i2.getChannel().get(i))){
comp.getChannel().add(i2.getChannel().get(i));
}
}
//lista de IN
comp.setIn(i1.getIn());
for(int i =0; i< i2.getIn().size(); i++){
if(!comp.getIn().contains(i2.getIn().get(i))){
comp.getIn().add(i2.getIn().get(i));
}
}
//lista OUT
comp.setIn(i1.getOut());
for(int i =0; i< i2.getOut().size(); i++){
if(!comp.getOut().contains(i2.getOut().get(i))){
comp.getOut().add(i2.getOut().get(i));
}
}
//lista de protocolos
comp.setProtocolos(i1.getProtocolos());
for(int i =0; i< i2.getProtocolos().size(); i++){
if(!comp.getProtocolos().contains(i2.getProtocolos().get(i))){
comp.getProtocolos().add(i2.getProtocolos().get(i));
}
}
//nome contrato
Contract c = new Contract();
c.setName(i1.getContrato().getName() + i2.getContrato().getName());
//canais
c.setChannel(i1.getContrato().getChannel());
for(int i =0; i< i2.getContrato().getChannel().size(); i++){
if(!comp.getContrato().getChannel().contains(i2.getContrato().getChannel().get(i))){
c.getChannel().add(i2.getContrato().getChannel().get(i));
}
}
//behavior
if(i1.getContrato().getBehavior().equals(i2.getContrato().getBehavior())){
c.setBehavior(i1.getContrato().getBehavior());
}
else{
c.setBehavior(i1.getContrato().getBehavior() + "\n"+ i2.getContrato().getBehavior());
}
c.setBehavior(c.getBehavior() + i1.getName() +"_" + i2.getName()
+ " = ");
comp.setContrato(c);
return comp;
}
}