package data;

import com.sun.istack.internal.Nullable;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Robert on 23. 5. 2015.
 */
public class Device {

	private final List<Module> mModules = new ArrayList<>();

	private final int mTypeId;

	private final String mTypeName;

	private Translation mName;

	private Translation mManufacturer;

	private Features mFeatures;

	public Device(int typeId, String typeName) {
		mTypeId = typeId;
		mTypeName = typeName;
	}

	public List<Module> getModules() {
		return mModules;
	}

	public void setModules(List<Module> modules) {
		mModules.clear();
		mModules.addAll(modules);
	}

	public int getTypeId() {
		return mTypeId;
	}

	public String getTypeName() {
		return mTypeName;
	}

	public Translation getName() {
		return mName;
	}

	public void setName(Translation name) {
		mName = name;
	}

	public Translation getManufacturer() {
		return mManufacturer;
	}

	public void setManufacturer(Translation manufacturer) {
		mManufacturer = manufacturer;
	}

	public Features getFeatures() {
		return mFeatures;
	}

	public void setFeatures(Features features) {
		mFeatures = features;
	}

	public static class Features {
		private Integer mRefresh;
		private Boolean mBattery;
		private Boolean mLed;

		public boolean hasRefresh() {
			return mRefresh != null && mRefresh > 0;
		}

		@Nullable
		public Integer getDefaultRefresh() {
			return mRefresh;
		}

		public void setRefresh(Integer refresh) {
			mRefresh = refresh;
		}

		public boolean hasBattery() {
			return mBattery != null && mBattery;
		}

		public void setBattery(Boolean battery) {
			mBattery = battery;
		}

		public boolean hasLed() {
			return mLed != null && mLed;
		}

		public void setLed(Boolean led) {
			mLed = led;
		}

		@Override
		public String toString() {
			String res = "";
			if (hasRefresh())
				res += ", refresh(" + getDefaultRefresh() + ")";
			if (hasBattery())
				res += ", battery";
			if (hasLed())
				res += ", led";
			return res.isEmpty() ? "-none-" : res.substring(2);
		}
	}
}

@@ -1763,285 +1763,8 @@
 %0A%09%09%7D
-%0A%0A%09%09@Override%0A%09%09public String toString() %7B%0A%09%09%09String res = %22%22;%0A%09%09%09if (hasRefresh())%0A%09%09%09%09res += %22, refresh(%22 + getDefaultRefresh() + %22)%22;%0A%09%09%09if (hasBattery())%0A%09%09%09%09res += %22, battery%22;%0A%09%09%09if (hasLed())%0A%09%09%09%09res += %22, led%22;%0A%09%09%09return res.isEmpty() ? %22-none-%22 : res.substring(2);%0A%09%09%7D
 %0A%09%7D%0A

Remove unused method