Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2011-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
   *
   *      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 org.springframework.data.mongodb.core.convert;
 
 
 import  org.springframework.beans.factory.InitializingBean;
 import  org.springframework.core.convert.ConversionService;
 import  org.springframework.core.convert.support.ConversionServiceFactory;
 import  org.springframework.core.convert.support.GenericConversionService;
Base class for MongoConverter implementations. Sets up a GenericConversionService and populates basic converters. Allows registering CustomConversions.

Author(s):
Jon Brisbin
Oliver Gierke
 
 public abstract class AbstractMongoConverter implements MongoConverter, InitializingBean {
 
 	protected final GenericConversionService conversionService;
Creates a new AbstractMongoConverter using the given GenericConversionService.

Parameters:
conversionService
 
 	@SuppressWarnings("deprecation")
 	public AbstractMongoConverter(GenericConversionService conversionService) {
 		this. = conversionService == null ? ConversionServiceFactory.createDefaultConversionService()
 				: conversionService;
 	}

Registers the given custom conversions with the converter.

Parameters:
conversions
 
 	public void setCustomConversions(CustomConversions conversions) {
 		this. = conversions;
 	}

Registers EntityInstantiators to customize entity instantiation.

Parameters:
instantiators
 
 	public void setInstantiators(EntityInstantiators instantiators) {
 		this. = instantiators == null ? new EntityInstantiators() : instantiators;
 	}

Registers additional converters that will be available when using the ConversionService directly (e.g. for id conversion). These converters are not custom conversions as they'd introduce unwanted conversions (e.g. ObjectId-to-String).
 
 	private void initializeConverters() {
 
 		if (!.canConvert(ObjectId.classString.class)) {
 		}
 		if (!.canConvert(String.classObjectId.class)) {
 		}
 		if (!.canConvert(ObjectId.classBigInteger.class)) {
 		}
 		if (!.canConvert(BigInteger.classObjectId.class)) {
 		}
 
 	}
 
 	/* 
 	 * (non-Javadoc)
 	 * @see org.springframework.data.mongodb.core.convert.MongoWriter#convertToMongoType(java.lang.Object)
 	 */
		return convertToMongoType(objnull);
	}
	/*
	 * (non-Javadoc)
	 * @see org.springframework.data.mongodb.core.core.convert.MongoConverter#getConversionService()
	 */
	public ConversionService getConversionService() {
	}
	/* (non-Javadoc)
	 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
	 */
	public void afterPropertiesSet() {
	}
New to GrepCode? Check out our FAQ X