view core/src/luan/AbstractLuanTable.java @ 224:05eb2837ddbf

change LuanTable.put() to not return old value git-svn-id: https://luan-java.googlecode.com/svn/trunk@225 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Mon, 21 Jul 2014 09:27:06 +0000
parents b76fcb72d97d
children ef39bc4d3f70
line wrap: on
line source

package luan;

import java.util.Iterator;
import java.util.ListIterator;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Set;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.regex.Pattern;


public abstract class AbstractLuanTable implements LuanTable {

	@Override public List<Object> asList() {
		return Collections.emptyList();
	}

	@Override public Map<Object,Object> asMap() {
		return Collections.emptyMap();
	}

	protected abstract String type();

	@Override public final String toString() {
		return type() + ": " + Integer.toHexString(hashCode());
	}

	@Override public void put(Object key,Object val) {
		throw new UnsupportedOperationException("can't put into a "+type());
	}

	@Override public void insert(int pos,Object value) {
		throw new UnsupportedOperationException("can't insert into a "+type());
	}

	@Override public void add(Object value) {
		throw new UnsupportedOperationException("can't add to a "+type());
	}

	@Override public Object remove(int pos) {
		throw new UnsupportedOperationException("can't remove from a "+type());
	}

	@Override public void sort(Comparator<Object> cmp) {
	}

	@Override public int length() {
		return 0;
	}

	@Override public LuanTable subList(int from,int to) {
		throw new UnsupportedOperationException("can't get a sub-list of a "+type());
	}

	@Override public LuanTable getMetatable() {
		return null;
	}

	@Override public void setMetatable(LuanTable metatable) {
		throw new UnsupportedOperationException("can't set a metatable on a "+type());
	}
}