Utility method used to create an instance of this type

@param instanceBaseType The base type of the instances of this type
@param producer         The factory method to produce the instance
@return A new instance
548267
V addInstance(Schema.BaseType instanceBaseType, BiFunction<VertexElement, T, V> producer, boolean isInferred) {
        preCheckForInstanceCreation();

        if (isAbstract()) throw TransactionException.addingInstancesToAbstractType(this);

        VertexElement instanceVertex = vertex().tx().addVertexElement(instanceBaseType);

        vertex().tx().ruleCache().ackTypeInstance(this);
        if (!Schema.MetaSchema.isMetaLabel(label())) {
            vertex().tx().cache().addedInstance(id());
            if (isInferred) instanceVertex.property(Schema.VertexProperty.IS_INFERRED, true);
        }

        V instance = producer.apply(instanceVertex, getThis());
        assert instance != null : "producer should never return null";
        return instance;
    }
1177456
@SuppressWarnings("WeakerAccess")
  public CreateInstanceRequest setType(@Nonnull Instance.Type type) {
    Preconditions.checkNotNull(type);
    Preconditions.checkArgument(type != Instance.Type.UNRECOGNIZED, "Type is unrecognized");
    builder.getInstanceBuilder().setType(type.toProto());
    return this;
  }
510805
public static <I> Builder<I> builder(Class<I> serviceType) {
    return new Builder<I>(serviceType);
  }
638053
public static <T> RuntimeTypeAdapterFactory<T> of(Class<T> baseType) {
    return new RuntimeTypeAdapterFactory<T>(baseType, "type", false);
  }
1123813
@Override
    protected final T create(Object... args) {
        if (this.creating.get()) {
            throw new IllegalStateException(
                    "Singleton creator has been called again while creation is in progress, this is indicative of a creation loop in a single thread");
        }

        this.creating.set(true);
        try {
            final T instance = this.createSingleton(args);
            this.instance = instance;
            this.created.set(true);
            return instance;
        } finally {
            this.creating.set(false);
        }
    }
826468
public T newInstance(Map<String, Object> fields)
	{
		try
		{
			FactoryDefinition<T> bestDef = factories[0];
			int bestScore = bestDef.getScore(fields);

			for(int i=1, n=factories.length; i<n; i++)
			{
				int score = factories[i].getScore(fields);
				if(score > bestScore)
				{
					bestDef = factories[i];
					bestScore = score;
				}
			}

			return bestDef.create(fields);
		}
		catch(RuntimeException e)
		{
			throw new RuntimeException("Could not create " + type + "; " + e.getMessage(), e);
		}
	}
1026166
public static <T extends Annotation> Builder<T> builder(Class<T> annotationType) {
    return new Builder<T>(annotationType);
  }
656300
protected Object createMyInstance() throws IOException {
        // would like to uninherit from AbstractFactoryBean (but it's final!)
        if (!isSingleton()) {
            throw new RuntimeException("ReloadablePropertiesFactoryBean only works as singleton");
        }

        // set listener
        reloadableProperties = new ReloadablePropertiesImpl();
        if (preListeners != null) {
            reloadableProperties.setListeners(preListeners);
        }

        // reload
        reload(true);

        // add for monitor
        ReloadConfigurationMonitor.addReconfigurableBean((ReconfigurableBean) reloadableProperties);

        return reloadableProperties;
    }
803531
public static ConstructorBuilder getInstance(Context context,
            ClassDoc classDoc, ConstructorWriter writer) {
        return new ConstructorBuilder(context, classDoc, writer);
    }
1224763
public static DatabaseProtocolFrontendEngine newInstance(final DatabaseType databaseType) {
        for (DatabaseProtocolFrontendEngine each : NewInstanceServiceLoader.newServiceInstances(DatabaseProtocolFrontendEngine.class)) {
            if (DatabaseType.valueFrom(each.getDatabaseType()) == databaseType) {
                return each;
            }
        }
        throw new UnsupportedOperationException(String.format("Cannot support database type '%s'", databaseType));
    }
930311
public static SchemaFactory newInstance(String schemaLanguage, String factoryClassName,
            ClassLoader classLoader) {
        if (schemaLanguage == null) {
            throw new NullPointerException("schemaLanguage == null");
        } else if (factoryClassName == null) {
            throw new NullPointerException("factoryClassName == null");
        }
        if (classLoader == null) {
            classLoader = Thread.currentThread().getContextClassLoader();
        }
        try {
            Class<?> type = classLoader != null
                    ? classLoader.loadClass(factoryClassName)
                    : Class.forName(factoryClassName);
            SchemaFactory result = (SchemaFactory) type.newInstance();
            if (result == null || !result.isSchemaLanguageSupported(schemaLanguage)) {
                throw new IllegalArgumentException(schemaLanguage);
            }
            return result;
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException(e);
        } catch (InstantiationException e) {
            throw new IllegalArgumentException(e);
        } catch (IllegalAccessException e) {
            throw new IllegalArgumentException(e);
        }
    }
604665
public <T> T createInstance(Class<T> type) {
        try {
            return type.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new IllegalArgumentException("Cannot create instance of class " + type.getName(), e);
        }
    }
482762
public static AnnotationTypeBuilder getInstance(Context context,
            AnnotationTypeDoc annotationTypeDoc,
            AnnotationTypeWriter writer)
            throws Exception {
        return new AnnotationTypeBuilder(context, annotationTypeDoc, writer);
    }
1312294
public static KafkaProducer<String, byte[]> createKafkaProducer(ProducerType type,
            String bootstrapServers) {
        return createKafkaProducer(type, bootstrapServers, null);
    }
537806
@SuppressWarnings("unchecked")
    private void createInstanceUsingMOF(ManagedObjectFactory<?> ejbManagedObjectFactory) throws InvocationTargetException {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "createInstanceUsingMOF");

        try {
            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "calling ManagedObjectFactory.createManagedObject(InvocationContext)");

            @SuppressWarnings("rawtypes")
            InvocationContextImpl invCtx = getInvocationContext();
            ivManagedObject = ejbManagedObjectFactory.createManagedObject(invCtx);

            ivEjbManagedObjectContext = ivManagedObject.getContext();
            setEnterpriseBean(ivManagedObject.getObject());
        } catch (ManagedObjectException e) {
            //the callstack is epecting a InvocationTargetException so unwrap the ManagedObjectException and rewrap as InvocationTargetException
            Throwable cause = e.getCause();
            if (cause != null && cause instanceof Exception) {
                if (cause instanceof InvocationTargetException) {
                    throw (InvocationTargetException) cause;
                } else {
                    throw new InvocationTargetException(cause);
                }
            } else {
                throw new EJBException(home.beanMetaData.enterpriseBeanClassName, e);
            }
        } catch (Exception e) {
            // Reflection exceptions are unexpected.
            FFDCFilter.processException(e, CLASS_NAME + ".createInstanceUsingMOF", "321", this);
            throw new EJBException(home.beanMetaData.enterpriseBeanClassName, e);
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "createInstanceUsingMOF");
    }
129946
public FacesConfigFactoryType<FacesConfigType<T>> getOrCreateFactory()
   {
      List<Node> nodeList = childNode.get("factory");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new FacesConfigFactoryTypeImpl<FacesConfigType<T>>(this, "factory", childNode, nodeList.get(0));
      }
      return createFactory();
   }
718402
@Override
   public <C extends ConnectionFactoryConfigurationBuilder<?>> C connectionFactory(Class<C> klass) {
      if (connectionFactory != null) {
         throw new IllegalStateException("A ConnectionFactory has already been configured for this store");
      }
      try {
         Constructor<C> constructor = klass.getDeclaredConstructor(AbstractJdbcStoreConfigurationBuilder.class);
         C builder = constructor.newInstance(this);
         this.connectionFactory = (ConnectionFactoryConfigurationBuilder<ConnectionFactoryConfiguration>) builder;
         return builder;
      } catch (Exception e) {
         throw new CacheConfigurationException("Could not instantiate loader configuration builder '" + klass.getName() + "'", e);
      }
   }