package com.baselet.element.express.instances;

import com.baselet.control.enums.ElementId;
import com.baselet.element.express.datatype.ExpressBag;
import com.baselet.element.express.datatype.ExpressGeneralizedDataType;

public class BagInstance extends NoIndexedCollectionInstance {

	@SuppressWarnings("unchecked")
	private final ExpressBag dataType = (ExpressBag) super.dataType;

	public BagInstance(Integer id, String name, ExpressBag dataType) {
		super(id, name, dataType);
	}

	public BagInstance(com.type.instance.BagInstance instance) {
		super(instance);

		// TODO dataType is unfinished
	}

	@Override
	public Boolean isFull() {

		if (size >= dataType.getBound2()) {
			return true;
		}

		return false;
	}

	@Override
	public String getElementName() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ElementId getElementId() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getPanelAttributes() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String toString() {
		String result = this.getClass().getSimpleName() + " " + getName() + ":\n";

		return result.endsWith(",\n") ? result.substring(0, result.length() - 2) + "\n" : result;
	}

	@Override
	protected ExpressGeneralizedDataType getElementDataType() {
		return dataType.getDataType();
	}

	@Override
	public ExpressBag getDataType() {
		return dataType;
	}
}
