/** * Utility method used to create or find an instance of this type * * @param instanceBaseType The base type of the instances of this type * @param finder The method to find the instrance if it already exists * @param producer The factory method to produce the instance if it doesn't exist * @return A new or already existing instance */ V putInstance(Schema.BaseType instanceBaseType, Supplier<V> finder, BiFunction<VertexElement, T, V> producer, boolean isInferred) { preCheckForInstanceCreation(); V instance = finder.get(); if(instance == null) { instance = addInstance(instanceBaseType, producer, isInferred, false); } else { if(isInferred && !instance.isInferred()){ throw GraknTxOperationException.nonInferredThingExists(instance); } } return instance; }