<commit_before>/*
 * $Id$
 * $Revision$
 * $Date$
 * 
 * ==============================================================================
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package wicket.spring.common.web;

import wicket.model.AbstractDetachableModel;
import wicket.model.IModel;
import wicket.spring.common.Contact;
import wicket.spring.common.ContactDao;

/**
 * Base class for contact detachable models. This class implements all necessary
 * logic except retrieval of the dao object, this way we can isolate that logic
 * in our example implementations.
 * 
 * @author <NAME> (ivaynberg)
 * 
 */
public abstract class ContactDetachableModel extends AbstractDetachableModel {

	private long id;

	private transient Contact contact;

	public ContactDetachableModel(Contact contact) {
		this.id = contact.getId();
		this.contact = contact;
	}

	public IModel getNestedModel() {
		return null;
	}

	protected final void onAttach() {
		contact = getContactDao().get(id);
	}

	protected void onDetach() {
		contact = null;
	}

	protected Object onGetObject() {
		return contact;
	}

	protected void onSetObject(Object object) {
		throw new UnsupportedOperationException();
	}

	protected abstract ContactDao getContactDao();

}<commit_msg>model fix<commit_after>/*
 * $Id$
 * $Revision$
 * $Date$
 * 
 * ==============================================================================
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package wicket.spring.common.web;

import wicket.model.LoadableDetachableModel;
import wicket.spring.common.Contact;
import wicket.spring.common.ContactDao;

/**
 * Base class for contact detachable models. This class implements all necessary
 * logic except retrieval of the dao object, this way we can isolate that logic
 * in our example implementations.
 * 
 * @author <NAME> (ivaynberg)
 * 
 */
public abstract class ContactDetachableModel extends
		LoadableDetachableModel<Contact> {

	private long id;

	public ContactDetachableModel(Contact contact) {
		super(contact);
		this.id = contact.getId();
	}

	protected abstract ContactDao getContactDao();

	@Override
	protected Contact load() {
		return getContactDao().get(id);
	}
}
{'fraction_non_alphanumeric': 0.13110137672090114, 'fraction_numerical': 0.0025031289111389237, 'mean_word_length': 4.4463373083475295, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '684292', 'n_tokens_mistral': 886, 'n_tokens_neox': 837, 'n_words': 324}