Create a new instance of Geometry type adapter factory, this is passed into the Gson
Builder.

@return a new GSON TypeAdapterFactory
@since 4.4.0
168733
public static TypeAdapterFactory create() {

    if (geometryTypeFactory == null) {
      geometryTypeFactory = RuntimeTypeAdapterFactory.of(Geometry.class, "type", true)
        .registerSubtype(GeometryCollection.class, "GeometryCollection")
        .registerSubtype(Point.class, "Point")
        .registerSubtype(MultiPoint.class, "MultiPoint")
        .registerSubtype(LineString.class, "LineString")
        .registerSubtype(MultiLineString.class, "MultiLineString")
        .registerSubtype(Polygon.class, "Polygon")
         .registerSubtype(MultiPolygon.class, "MultiPolygon");
    }
    return geometryTypeFactory;
  }
940352
public GeometryFactory getGeometryFactory() {
		if (null == geometryFactory) {
			if (0 == srid) {
				throw new IllegalArgumentException("srid needs to be set on MapModel to obtain GeometryFactory");
			}
			geometryFactory = new GeometryFactory(srid, -1); // @todo precision is not yet implemented
		}
		return geometryFactory;
	}
771864
public JsonConverterBuilder registerJsonTypeAdapter(JsonTypeAdapter adapter) {
        Validate.argumentIsNotNull(adapter);
        adapter.getValueTypes().forEach( c -> registerJsonTypeAdapterForType((Class)c, adapter));
        return this;
    }
1088742
static Gson createGson() {
    if (gson == null) {
      gson = new GsonBuilder()
          .registerTypeAdapter(CMAField.class, new FieldTypeAdapter())
          .registerTypeAdapter(CMAEntry.class, new EntrySerializer())
          .registerTypeAdapter(CMASnapshot.class, new SnapshotDeserializer())
          .registerTypeAdapter(CMALocale.class, new LocaleSerializer())
          .create();
    }

    return gson;
  }
494733
public static <M extends Multimap<?, ?>> MultimapJsonSerializer<M, ?, ?> newInstance( KeySerializer<?> keySerializer,
                                                                                          JsonSerializer<?> valueSerializer ) {
        return new MultimapJsonSerializer( keySerializer, valueSerializer );
    }
301454
public static DocumentBuilderFactory newInstance(String factoryClassName,
            ClassLoader classLoader) {
        if (factoryClassName == null) {
            throw new FactoryConfigurationError("factoryClassName == null");
        }
        if (classLoader == null) {
            classLoader = Thread.currentThread().getContextClassLoader();
        }
        try {
            Class<?> type = classLoader != null
                    ? classLoader.loadClass(factoryClassName)
                    : Class.forName(factoryClassName);
            return (DocumentBuilderFactory) type.newInstance();
        } catch (ClassNotFoundException e) {
            throw new FactoryConfigurationError(e);
        } catch (InstantiationException e) {
            throw new FactoryConfigurationError(e);
        } catch (IllegalAccessException e) {
            throw new FactoryConfigurationError(e);
        }
    }
214096
private GrpcChannelFactory getChannelFactory() {
        if (this.channelFactory == null) {
            final GrpcChannelFactory factory = this.applicationContext.getBean(GrpcChannelFactory.class);
            this.channelFactory = factory;
            return factory;
        }
        return this.channelFactory;
    }
522791
protected GSONWorkUnit createGSONWorkUnit(
            final DocWorkUnit workUnit,
            final List<Map<String, String>> indexByGroupMaps,
            final List<Map<String, String>> featureMaps)
    {
        return new GSONWorkUnit();
    }
1006831
@Override
  @SuppressWarnings("unused")
  public String toJson() {

    Gson gson = new GsonBuilder()
      .registerTypeAdapterFactory(GeometryAdapterFactory.create())
      .registerTypeAdapter(BoundingBox.class, new BoundingBoxTypeAdapter())
      .registerTypeAdapterFactory(GeocodingAdapterFactory.create())
      .create();

    // Empty properties -> should not appear in json string
    CarmenFeature feature = this;
    if (properties() != null && properties().size() == 0) {
      feature = toBuilder().properties(null).build();
    }

    return gson.toJson(feature, CarmenFeature.class);
  }
99339
public String toJson() {
    GsonBuilder gson = new GsonBuilder();
    gson.registerTypeAdapterFactory(DirectionsAdapterFactory.create());
    gson.registerTypeAdapter(Point.class, new PointAsCoordinatesTypeAdapter());
    return gson.create().toJson(this);
  }
313241
public static Geometry polygonize(Geometry geometry) {
        if(geometry == null){
            return null;
        }
        Polygonizer polygonizer = new Polygonizer();
        polygonizer.add(geometry);
        Collection pols = polygonizer.getPolygons();
        if(pols.isEmpty()){
            return null;
        }
        return FACTORY.createMultiPolygon(GeometryFactory.toPolygonArray(pols));
    }
1118503
public static <T> LinkedListJsonDeserializer<T> newInstance( JsonDeserializer<T> deserializer ) {
        return new LinkedListJsonDeserializer<T>( deserializer );
    }
514368
@SuppressWarnings("unchecked")
    static <T, A extends BindingCollectionAdapter<T>> A createClass(Class<? extends BindingCollectionAdapter> adapterClass, ItemBinding<T> itemBinding) {
        try {
            return (A) adapterClass.getConstructor(ItemBinding.class).newInstance(itemBinding);
        } catch (Exception e1) {
            throw new RuntimeException(e1);
        }
    }
35215
static public ContentHandleFactory newFactory() {
    return new ContentHandleFactory() {
      @Override
      public Class<?>[] getHandledClasses() {
        return new Class<?>[]{ JsonParser.class };
      }
      @Override
      public boolean isHandled(Class<?> type) {
        return JsonParser.class.isAssignableFrom(type);
      }
      @Override
      public <C> ContentHandle<C> newHandle(Class<C> type) {
        @SuppressWarnings("unchecked")
        ContentHandle<C> handle = isHandled(type) ?
                                  (ContentHandle<C>) new JacksonParserHandle() : null;
        return handle;
      }
    };
  }
98188
public BeanType<ValidationMappingDescriptor> getOrCreateBean()
   {
      List<Node> nodeList = model.get("bean");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new BeanTypeImpl<ValidationMappingDescriptor>(this, "bean", model, nodeList.get(0));
      }
      return createBean();
   }
494243
public Object create(Object locator) throws CreateException {
		if (locator == null)
			throw new NullPointerException("Locator cannot be null");

		// Iterate from the latest factories
		for (int index = _factories.size() - 1; index >= 0; index--) {
			IFactory factory = _factories.get(index);
			if (factory.canCreate(locator) != null)
				return factory.create(locator);
		}

		throw new CreateException(null, locator);
	}
743076
@SuppressWarnings("unchecked")
   private static LogAdapterFactory createAdapterFactory()
   {
      List<LogAdapterFactory> factories = Iterators.asList(ServiceLoader.load(LogAdapterFactory.class));
      if (factories.isEmpty())
      {
         /*
          * Always fall back to the JDK, even if our service loading mechanism is hosed for some reason.
          */
         factories = Arrays.asList((LogAdapterFactory) new JDKLogAdapterFactory());
      }

      /*
       * Sort factories by priority.
       */
      Collections.sort(factories, new WeightedComparator());

      /*
       * Use the factory with the highest priority.
       */
      return factories.get(0);

   }