All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nitorcreations.wicket.model.MapEntryModel Maven / Gradle / Ivy

There is a newer version: 1.7
Show newest version
package com.nitorcreations.wicket.model;

import java.util.Map;

import org.apache.wicket.model.IModel;
import org.apache.wicket.util.lang.Args;

public class MapEntryModel implements IModel {
    private static final long serialVersionUID = -5278952770811642093L;

    private final IModel> map;
    private final IModel key;

    public MapEntryModel(IModel> map, IModel key) {
        this.map = Args.notNull(map, "map");
        this.key = Args.notNull(key, "key");
        Args.notNull(map.getObject(), "map.getObject()");
    }

    private Map getMap() {
        return Args.notNull(map.getObject(), "map.getObject()");
    }

    @Override
    public V getObject() {
        return getMap().get(key.getObject());
    }

    @Override
    public void setObject(V object) {
        getMap().put(key.getObject(), object);
    }

    @Override
    public void detach() {
        map.detach();
        key.detach();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy