Generate the instance builder class body for a builder.

@param newInstanceMethodBuilder builder for the
{@link InstanceBuilder#newInstance(JsonReader, JsonDeserializationContext, JsonDeserializerParameters, Map, Map)}
method
487414
private void buildNewInstanceMethodForBuilder( MethodSpec.Builder newInstanceMethodBuilder ) {
        newInstanceMethodBuilder.addStatement( "return new $T(builderDeserializer.deserializeInline(reader, ctx, params, null, null, null, bufferedProperties).build(), bufferedProperties)",
                parameterizedName( Instance.class, beanInfo.getType() ) );
    }
1218384
public static AnnotationTypeFieldBuilder getInstance(
            Context context, ClassDoc classDoc,
            AnnotationTypeFieldWriter writer) {
        return new AnnotationTypeFieldBuilder(context, classDoc,
                    writer, VisibleMemberMap.ANNOTATION_TYPE_FIELDS);
    }
75158
@SuppressWarnings("unchecked")
    public static <T> T newInstance(Class<T> c) {
        return (T) InvokerHelper.invokeConstructorOf(c, null);
    }
561669
private void buildConstructor( TypeSpec.Builder typeBuilder ) {
        MethodSpec.Builder constructorBuilder = MethodSpec.constructorBuilder().addModifiers( Modifier.PUBLIC );

        if ( !beanInfo.getParameterizedTypes().isEmpty() ) {
            Class mapperClass;
            String mapperNameFormat;
            if ( isSerializer() ) {
                mapperClass = Serializer.class;
                mapperNameFormat = TYPE_PARAMETER_SERIALIZER_FIELD_NAME;
            } else {
                mapperClass = Deserializer.class;
                mapperNameFormat = TYPE_PARAMETER_DESERIALIZER_FIELD_NAME;
            }

            for ( int i = 0; i < beanInfo.getParameterizedTypes().size(); i++ ) {
                JClassType argType = beanInfo.getParameterizedTypes().get( i );
                String mapperName = String.format( mapperNameFormat, i );
                TypeName mapperType = parameterizedName( mapperClass, argType );

                FieldSpec field = FieldSpec.builder( mapperType, mapperName, Modifier.PRIVATE, Modifier.FINAL ).build();
                typeBuilder.addField( field );

                ParameterSpec parameter = ParameterSpec.builder( mapperType, mapperName ).build();
                constructorBuilder.addParameter( parameter );
                constructorBuilder.addStatement( "this.$N = $N", field, parameter );
            }
        }

        typeBuilder.addMethod( constructorBuilder.build() );
    }
10331
protected static void buildClassCast(StringBuilder builder, Class cls) {
        builder.append('(');
        buildClass(builder, cls);
        builder.append(')');
    }
1030543
@Nonnull
	public static <T1, T2> LBiObjDblConsumer<T1, T2> biObjDblConsumerFrom(Consumer<LBiObjDblConsumerBuilder<T1, T2>> buildingFunction) {
		LBiObjDblConsumerBuilder builder = new LBiObjDblConsumerBuilder();
		buildingFunction.accept(builder);
		return builder.build();
	}
73556
private static Object newInstance(String className,
                                      ClassLoader classLoader,
                                      Properties properties)
    {
        try {
            Class<?> spiClass;
            if (classLoader == null) {
                spiClass = Class.forName(className);
            } else {
                spiClass = classLoader.loadClass(className);
            }
            if (properties != null) {
                Constructor constr = null;
                try {
                    constr = spiClass.getConstructor(Properties.class);
                } catch (Exception ex) {
                }
                if (constr != null) {
                    return constr.newInstance(properties);
                }
            }
            return spiClass.newInstance();
        } catch (ClassNotFoundException x) {
            throw new ELException(
                "Provider " + className + " not found", x);
        } catch (Exception x) {
            throw new ELException(
                "Provider " + className + " could not be instantiated: " + x,
                x);
        }
    }
842400
private MapperInstance getInstance( JType mappedType, JClassType classType, boolean isSerializers ) throws UnableToCompleteException {
        int nbParam = 0;
        if ( null != mappedType.isGenericType() && (!isSerializers || !typeOracle.isEnumSupertype( mappedType )) ) {
            nbParam = mappedType.isGenericType().getTypeParameters().length;
        }

        // we first look at static method
        for ( JMethod method : classType.getMethods() ) {
            // method must be public static, return the instance type and take no parameters
            if ( method.isStatic() && null != method.getReturnType().isClassOrInterface()
                    && classType.isAssignableTo( method.getReturnType().isClassOrInterface() )
                    && method.getParameters().length == nbParam && method.isPublic() ) {
                MapperType[] parameters = getParameters( mappedType, method, isSerializers );
                if ( null == parameters ) {
                    continue;
                }

                return new MapperInstance( classType, method, parameters );
            }
        }

        // then we search the default constructor
        for ( JConstructor constructor : classType.getConstructors() ) {
            if ( constructor.isPublic() && constructor.getParameters().length == nbParam ) {
                MapperType[] parameters = getParameters( mappedType, constructor, isSerializers );
                if ( null == parameters ) {
                    continue;
                }

                return new MapperInstance( classType, constructor, parameters );
            }
        }

        logger.log( Type.ERROR, "Cannot instantiate the custom serializer/deserializer " + classType.getQualifiedSourceName() + ". "
                + "Check the page https://github.com/nmorel/gwt-jackson/wiki/Custom-serializers-and-deserializers for more details." );
        throw new UnableToCompleteException();
    }
1150106
public Builder newBuilder() {
        return new Builder()
                .name(name)
                .addColumn(columns)
                .addFk(fks)
                .pkFields(pkFields)
                .addIndexes(indexes);
    }
803531
public static ConstructorBuilder getInstance(Context context,
            ClassDoc classDoc, ConstructorWriter writer) {
        return new ConstructorBuilder(context, classDoc, writer);
    }
323546
public static DocumentBuilder newDocumentBuilder(final DocumentBuilderFactory factory)
   {
      try
      {
         final DocumentBuilder builder = factory.newDocumentBuilder();
         return builder;
      }
      catch (Exception e)
      {
         throw MESSAGES.unableToCreateInstanceOf(e, DocumentBuilder.class.getName());
      }
   }
302542
private MethodSpec buildNewDeserializerMethod( JClassType mappedTypeClass ) throws UnableToCompleteException {
        JDeserializerType type;
        try {
            type = getJsonDeserializerFromType( mappedTypeClass );
        } catch ( UnsupportedTypeException e ) {
            logger.log( Type.ERROR, "Cannot generate mapper due to previous errors : " + e.getMessage() );
            throw new UnableToCompleteException();
        }

        return MethodSpec.methodBuilder( "newDeserializer" )
                .addModifiers( Modifier.PROTECTED )
                .addAnnotation( Override.class )
                .returns( parameterizedName( JsonDeserializer.class, mappedTypeClass ) )
                .addStatement( "return $L", type.getInstance() )
                .build();
    }
1118375
public void createInstance(
      final String my_instance_id, final String my_config_id, final String my_client_project) {
    // [START instance_admin_client_create_instance]
    final String instanceId = my_instance_id;
    final String configId = my_config_id;
    final String clientProject = my_client_project;

    OperationFuture<Instance, CreateInstanceMetadata> op =
        instanceAdminClient.createInstance(
            InstanceInfo.newBuilder(InstanceId.of(clientProject, instanceId))
                .setInstanceConfigId(InstanceConfigId.of(clientProject, configId))
                .setDisplayName(instanceId)
                .setNodeCount(1)
                .build());
    try {
      op.get();
    } catch (ExecutionException e) {
      throw (SpannerException) e.getCause();
    } catch (InterruptedException e) {
      throw SpannerExceptionFactory.propagateInterrupt(e);
    }
    // [END instance_admin_client_create_instance]
  }
1259706
public static Object buildNewObjectInstance(ClassDescriptor cld)
    {
        Object result = null;

        // If either the factory class and/or factory method is null,
        // just follow the normal code path and create via constructor
        if ((cld.getFactoryClass() == null) || (cld.getFactoryMethod() == null))
        {
            try
            {
                // 1. create an empty Object (persistent classes need a public default constructor)
                Constructor con = cld.getZeroArgumentConstructor();
                if(con == null)
                {
                    throw new ClassNotPersistenceCapableException(
                    "A zero argument constructor was not provided! Class was '" + cld.getClassNameOfObject() + "'");
                }
                result = ConstructorHelper.instantiate(con);
            }
            catch (InstantiationException e)
            {
                throw new ClassNotPersistenceCapableException(
                        "Can't instantiate class '" + cld.getClassNameOfObject()+"'");
            }
        }
        else
        {
            try
            {
                // 1. create an empty Object by calling the no-parms factory method
                Method method = cld.getFactoryMethod();

                if (Modifier.isStatic(method.getModifiers()))
                {
                    // method is static so call it directly
                    result = method.invoke(null, null);
                }
                else
                {
                    // method is not static, so create an object of the factory first
                    // note that this requires a public no-parameter (default) constructor
                    Object factoryInstance = cld.getFactoryClass().newInstance();

                    result = method.invoke(factoryInstance, null);
                }
            }
            catch (Exception ex)
            {
                throw new PersistenceBrokerException("Unable to build object instance of class '"
                        + cld.getClassNameOfObject() + "' from factory:" + cld.getFactoryClass()
                        + "." + cld.getFactoryMethod(), ex);
            }
        }
        return result;
    }
20557
public static Object newInstanceFromName(Object enclosingObject, String className, ClassLoader classLoader) {
		try {
			Class<?> clazz = Class.forName(className, false, classLoader);
			for (Constructor<?> c : clazz.getConstructors()) {
				Class<?>[] parameterTypes = c.getParameterTypes();
				if (parameterTypes.length == 0) {
					return c.newInstance();
				} else if (parameterTypes.length == 1 && enclosingObject != null && parameterTypes[0].equals(enclosingObject.getClass())) {
					return c.newInstance(enclosingObject);
				}
			}
			return clazz.newInstance();
		} catch (Exception e) {
			String m = "Couldn't create instance from name " + className + " (" + e.getMessage() + ")";
			LOG.error(m, e);
			throw new RuntimeException(m);
		}
	}
885402
public static<T> ServiceInstanceBuilder<T>builder() throws Exception
    {
        String                  address = null;
        Collection<InetAddress> ips = ServiceInstanceBuilder.getAllLocalIPs();
        if ( ips.size() > 0 )
        {
            address = ips.iterator().next().getHostAddress();   // default to the first address
        }

        String                  id = UUID.randomUUID().toString();

        return new ServiceInstanceBuilder<T>().address(address).id(id).registrationTimeUTC(System.currentTimeMillis());
    }
238831
public synchronized ClientBuilder newBuilder(String clientName, JaxRsClientConfig jaxRsConfig, Collection<JaxRsFeatureGroup> featureGroupsIn) {
        started = true;

        final List<JaxRsFeatureGroup> featureGroups = ImmutableList.<JaxRsFeatureGroup>builder()
                .add(PrivateFeatureGroup.WILDCARD)
                .addAll(featureGroupsIn)
                .build();

        final ClientBuilder builder = factory(ctx).newBuilder(clientName, jaxRsConfig, featureGroups);

        builder.property(CLIENT_NAME_PROPERTY, clientName);
        builder.property(FEATURE_GROUP_PROPERTY, featureGroups);

        final List<Feature> features = featureGroups.stream()
            .flatMap(g -> featureMap.get(g).stream())
            .collect(Collectors.toList());

        final List<Class<? extends Feature>> classFeatures = featureGroups.stream()
            .flatMap(g -> classFeatureMap.get(g).stream())
            .collect(Collectors.toList());

        LOG.debug("Building client '{}' with feature groups {}, features {} {}, and config '{}'", clientName, featureGroups, features, classFeatures, jaxRsConfig);
        features.forEach(builder::register);
        classFeatures.forEach(builder::register);

        return builder;
    }