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

org.springframework.ldap.core.support.AbstractContextMapper Maven / Gradle / Ivy

/*
 * Copyright 2005-2013 the original author or authors.
 *
 * 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
 *
 *      https://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 org.springframework.ldap.core.support;

import org.springframework.ldap.core.ContextMapper;
import org.springframework.ldap.core.DirContextOperations;

/**
 * Abstract superclass that may be used instead of implementing {@link ContextMapper}
 * directly. Subclassing from this superclass, the supplied context will be automatically
 * cast to DirContextOperations. Note that if you use your own
 * DirObjectFactory, this implementation will fail with a
 * ClassCastException.
 *
 * @author Mattias Hellborg Arthursson
 *
 */
public abstract class AbstractContextMapper implements ContextMapper {

	/**
	 * {@inheritDoc}
	 * @throws ClassCastException if a custom DirObjectFactory implementation
	 * is used, causing the objects passed in be anything else than
	 * {@link DirContextOperations} instances.
	 */
	@Override
	public final T mapFromContext(Object ctx) {
		return doMapFromContext((DirContextOperations) ctx);
	}

	/**
	 * Map a single DirContextOperation to an object. The supplied instance
	 * is the object supplied to {@link #mapFromContext(Object)} cast to a
	 * DirContextOperations.
	 * @param ctx the context to map to an object.
	 * @return an object built from the data in the context.
	 */
	protected abstract T doMapFromContext(DirContextOperations ctx);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy