apache-geode-extensions/src/main/java/org/springframework/geode/pdx/PdxInstanceBuilder.java
/**
	 * Constructs a new {@link PdxInstance} from the given, required source {@link Object}.
	 *
	 * @param source {@link Object} being serialized to PDX; must not be {@literal null}.
	 * @return a {@link Factory} used to create the {@link PdxInstance} from the given,
	 * required source {@link Object}, which was serialized to PDX.
	 * @throws IllegalArgumentException if {@link Object source} is {@literal null}.
	 * @see Factory
	 */
Constructs a new  PdxInstance from the given, required source  Object.
@param source  Object being serialized to PDX; must not be  null.
@return a  Factory used to create the  PdxInstance from the given,
required source  Object, which was serialized to PDX.
@throws IllegalArgumentException if  Object source is  null.
@see Factory
Constructs a new PdxInstance from the given required source Object . @param source Object being serialized to PDX ; must not be null . @return a Factory used to create the PdxInstance from the given required source Object which was serialized to PDX . @throws IllegalArgumentException if Object source is null . @see Factory
public Factory from(Object source) {
		assertNotNull(source, "Source object to serialize to PDX must not be null");
		RegionService regionService = getRegionService();
		Optional.of(regionService)
			.filter(GemFireCache.class::isInstance)
			.map(GemFireCache.class::cast)
			.map(GemFireCache::getPdxReadSerialized)
			.filter(Boolean.TRUE::equals)
			.orElseThrow(() -> new IllegalStateException("PDX read-serialized must be set to true"));
		PdxInstanceFactory factory = regionService.createPdxInstanceFactory(source.getClass().getName());
		factory.writeObject("source", source);
		AtomicReference<Object> resolvedSource = new AtomicReference<>(null);
		return () -> Optional.of(factory)
			.map(PdxInstanceFactory::create)
			.map(pdxInstance -> resolvedSource.updateAndGet(it -> pdxInstance.getField("source")))
			.filter(PdxInstance.class::isInstance)
			.map(PdxInstance.class::cast)
			.orElseThrow(() -> {
				String message = String.format("Expected an instance of PDX but was an instance of type [%s];"
						+ " Was PDX read-serialized set to true", nullSafeClassName(resolvedSource.get()));
				return new IllegalArgumentException(message);
			});
	}
public Factory from ( Object source ) { assertNotNull ( source , "Source object to serialize to PDX must not be null" ) ; RegionService regionService = getRegionService ( ) ; Optional . of ( regionService ) . filter ( GemFireCache . class :: isInstance ) . map ( GemFireCache . class :: cast ) . map ( GemFireCache :: getPdxReadSerialized ) . filter ( Boolean . TRUE :: equals ) . orElseThrow ( ( ) -> new IllegalStateException ( "PDX read-serialized must be set to true" ) ) ; PdxInstanceFactory factory = regionService . createPdxInstanceFactory ( source . getClass ( ) . getName ( ) ) ; factory . writeObject ( "source" , source ) ; AtomicReference < Object > resolvedSource = new AtomicReference < > ( null ) ; return ( ) -> Optional . of ( factory ) . map ( PdxInstanceFactory :: create ) . map ( pdxInstance -> resolvedSource . updateAndGet ( it -> pdxInstance . getField ( "source" ) ) ) . filter ( PdxInstance . class :: isInstance ) . map ( PdxInstance . class :: cast ) . orElseThrow ( ( ) -> { String message = String . format ( "Expected an instance of PDX but was an instance of type [%s];" + " Was PDX read-serialized set to true" , nullSafeClassName ( resolvedSource . get ( ) ) ) ; return new IllegalArgumentException ( message ) ; } ) ; }
Constructs a new {@link PdxInstance} from the given, required source {@link Object}.
Constructs a new { @link PdxInstance } from the given required source { @link Object } .