65 lines
1.4 KiB
Java
65 lines
1.4 KiB
Java
package de.ctdo.bunti.model;
|
|
|
|
|
|
import org.hibernate.annotations.GenericGenerator;
|
|
|
|
import javax.persistence.Entity;
|
|
import javax.persistence.GeneratedValue;
|
|
import javax.persistence.Id;
|
|
import javax.persistence.Table;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
|
|
@Entity
|
|
@Table( name = "rooms" )
|
|
public final class Room {
|
|
|
|
private int id;
|
|
private String name;
|
|
private List<BuntiDevice> devices = new ArrayList<BuntiDevice>();
|
|
|
|
@Id
|
|
@GeneratedValue(generator="increment")
|
|
@GenericGenerator(name="increment", strategy = "increment")
|
|
public int getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(int id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public boolean addDevice(BuntiDevice device) {
|
|
return devices.add(device);
|
|
}
|
|
|
|
public boolean removeDevice(BuntiDevice device) {
|
|
return devices.remove(device);
|
|
}
|
|
|
|
public BuntiDevice getDevice(int id) {
|
|
for (BuntiDevice device: devices) {
|
|
if( device.getId() == id) {
|
|
return device;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public Collection<BuntiDevice> getDeviceList() {
|
|
return Collections.unmodifiableList(devices);
|
|
}
|
|
|
|
|
|
}
|