ResetGroupRegistry.java

codebase/src/net/sourceforge/pain/data/ResetGroupRegistry.java · 1.1 KB

From the archive pain_0_44.tgz

Download the archive   « Back to the archive contents

package net.sourceforge.pain.data;

import net.sourceforge.pain.data.type.*;
import net.sourceforge.pain.db.*;

import java.util.*;

public final class ResetGroupRegistry extends DbObject {
	private static final int RESET_GROUPS = 0;
	private static final int NFIELDS = 1;

	public ResetGroupRegistry() {
	}

	public ResetGroupRegistry(PainDB db)  {
		super(db);
	}

	protected DbClassSchema provideSchema() {
		byte types[] = new byte[NFIELDS];
		String names[] = new String[NFIELDS];

		types[RESET_GROUPS] = DbType.STRING_KEY_MAP;
		names[RESET_GROUPS] = "resets_groups";

		return new DbClassSchema(types, names);

	}

	public ResetGroup getResetGroup(String id) {
		return (ResetGroup) groups().get(id);
	}

	public Collection getResetGroups() {
		return groups().values();
	}

	public void registerResetGroup(ResetGroup rg) {
		Map groups = groups();
		String groupId = rg.getGroupId();
		if (groups.containsKey(groupId)) {
			throw new IllegalStateException("Group is already registered!, id="+groupId);
		}
		groups.put(groupId, rg);
	}

	private DbStringKeyMap groups() {
		return getStringKeyMap(RESET_GROUPS);
	}

}

Site Stats

Snippets: 1791
Codebases: 571