Ciao,
Probabilmente sarà una domanda banale, ma per novizio della programmazione ad oggetti è uno scoglio particolarmente ripido.

La mia situazione è questo, ho un oggetto "Hop" che ha una serie di attribuiti, tra cui due istanze di una Classe "Port" (porta di ingresso e porta di uscita).

Quando vado a settare i gli attributi di Hop debbo anche poter settare gli attributi di portIn che di portOut.

Come mi conviene fare?
io avevo pensato ad una cosa del genere
codice:
public class Hop {
public class Hop {
public class Hop {
public class Hop {

	private int id = 0;
	private int labelIn = -1;
	private int labelOut = -1;
	private String channelType = "";
	private int inRegeneratorPort = -1;
	private int outRegeneratorPort = -1;
	private String operationaState = "";

	private Port portIn = new Port();
	private Port portOut = new Port();
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getLabelIn() {
		return labelIn;
	}
	public void setLabelIn(int labelIn) {
		this.labelIn = labelIn;
	}
	public int getLabelOut() {
		return labelOut;
	}
	public void setLabelOut(int labelOut) {
		this.labelOut = labelOut;
	}
	public String getChannelType() {
		return channelType;
	}
	public void setChannelType(String channelType) {
		this.channelType = channelType;
	}
	public int getInRegeneratorPort() {
		return inRegeneratorPort;
	}
	public void setInRegeneratorPort(int inRegeneratorPort) {
		this.inRegeneratorPort = inRegeneratorPort;
	}
	public int getOutRegeneratorPort() {
		return outRegeneratorPort;
	}
	public void setOutRegeneratorPort(int outRegeneratorPort) {
		this.outRegeneratorPort = outRegeneratorPort;
	}
	public String getOperationaState() {
		return operationaState;
	}
	public void setOperationaState(String operationaState) {
		this.operationaState = operationaState;
	}
	public Port getPortIn() {
		return portIn;
	}
	public void setPortIn(Port portIn) {
		this.portIn = portIn;
	}
	public Port getPortOut() {
		return portOut;
	}
	public void setPortOut(Port portOut) {
		this.portOut = portOut;
	}

	public String toString(){
		String buffer = "";
		buffer += " Hop: " + " id = " + id + "\n" ;
		buffer += " Port In: ";
		buffer += portIn.toString();
		buffer += " Port Out: ";
		buffer += portOut.toString();
		return buffer;
	}
}