/* (non-Javadoc)
@see cyclops2.monads.transformers.values.ValueTransformer#generate()
765436
@Override
    public AnyM<W, ? extends ReactiveSeq<T>> generate(T alt) {

        return super.generate(alt);
    }
221770
@Override
    public void generate(final Module module, final Element element) {
        // this is not necessary, it is done to avoid the namespace definition
        // in every item.
        Element root = element;
        while (root.getParent() != null && root.getParent() instanceof Element) {
            root = (Element) element.getParent();
        }
        root.addNamespaceDeclaration(GeoRSSModule.SIMPLE_NS);

        final GeoRSSModule geoRSSModule = (GeoRSSModule) module;

        final AbstractGeometry geometry = geoRSSModule.getGeometry();
        if (geometry instanceof Point) {
            final Position pos = ((Point) geometry).getPosition();

            final Element pointElement = new Element("point", GeoRSSModule.SIMPLE_NS);
            pointElement.addContent(pos.getLatitude() + " " + pos.getLongitude());
            element.addContent(pointElement);
        } else if (geometry instanceof LineString) {
            final PositionList posList = ((LineString) geometry).getPositionList();

            final Element lineElement = new Element("line", GeoRSSModule.SIMPLE_NS);

            lineElement.addContent(posListToString(posList));
            element.addContent(lineElement);
        } else if (geometry instanceof Polygon) {
            final AbstractRing ring = ((Polygon) geometry).getExterior();
            if (ring instanceof LinearRing) {
                final PositionList posList = ((LinearRing) ring).getPositionList();
                final Element polygonElement = new Element("polygon", GeoRSSModule.SIMPLE_NS);

                polygonElement.addContent(posListToString(posList));
                element.addContent(polygonElement);
            } else {
                LOG.error("GeoRSS simple format can't handle rings of type: " + ring.getClass().getName());
            }
            if (((Polygon) geometry).getInterior() != null && !((Polygon) geometry).getInterior().isEmpty()) {
                LOG.error("GeoRSS simple format can't handle interior rings (ignored)");
            }
        } else if (geometry instanceof Envelope) {
            final Envelope envelope = (Envelope) geometry;
            final Element boxElement = new Element("box", GeoRSSModule.SIMPLE_NS);
            boxElement.addContent(envelope.getMinLatitude() + " " + envelope.getMinLongitude() + " " + envelope.getMaxLatitude() + " "
                    + envelope.getMaxLongitude());
            element.addContent(boxElement);
        } else {
            LOG.error("GeoRSS simple format can't handle geometries of type: " + geometry.getClass().getName());
        }
    }
1359978
void generate(T input) throws SourceFileGenerationException {
    ClassName generatedTypeName = nameGeneratedType(input);
    try {
      Optional<TypeSpec.Builder> type = write(generatedTypeName, input);
      if (!type.isPresent()) {
        return;
      }
      buildJavaFile(generatedTypeName, type.get()).writeTo(filer);
    } catch (Exception e) {
      // if the code above threw a SFGE, use that
      Throwables.propagateIfPossible(e, SourceFileGenerationException.class);
      // otherwise, throw a new one
      throw new SourceFileGenerationException(
          Optional.<ClassName>absent(), e, getElementForErrorReporting(input));
    }
  }
908205
protected void _generate(SarlAgent agent, IExtraLanguageGeneratorContext context) {
		final JvmDeclaredType jvmType = getJvmModelAssociations().getInferredType(agent);
		final PyAppendable appendable = createAppendable(jvmType, context);
		final List<JvmTypeReference> superTypes;
		if (agent.getExtends() != null) {
			superTypes = Collections.singletonList(agent.getExtends());
		} else {
			superTypes = Collections.singletonList(getTypeReferences().getTypeForName(Agent.class, agent));
		}
		final String qualifiedName = this.qualifiedNameProvider.getFullyQualifiedName(agent).toString();
		if (generateTypeDeclaration(
				qualifiedName,
				agent.getName(), agent.isAbstract(), superTypes,
				getTypeBuilder().getDocumentation(agent),
				true,
			agent.getMembers(), appendable, context, (it, context2) -> {
				generateGuardEvaluators(qualifiedName, it, context2);
			})) {
			final QualifiedName name = getQualifiedNameProvider().getFullyQualifiedName(agent);
			writeFile(name, appendable, context);
		}
	}
402148
public MultipleObjectsBundle generate() {
    // we actually need some clusters.
    if(generators.isEmpty()) {
      throw new AbortException("No clusters specified.");
    }
    // Assert that cluster dimensions agree.
    final int dim = generators.get(0).getDim();
    for(GeneratorInterface c : generators) {
      if(c.getDim() != dim) {
        throw new AbortException("Cluster dimensions do not agree.");
      }
    }
    // Prepare result bundle
    MultipleObjectsBundle bundle = new MultipleObjectsBundle();
    VectorFieldTypeInformation<DoubleVector> type = new VectorFieldTypeInformation<>(DoubleVector.FACTORY, dim);
    bundle.appendColumn(type, new ArrayList<>());
    bundle.appendColumn(TypeUtil.CLASSLABEL, new ArrayList<>());
    bundle.appendColumn(Model.TYPE, new ArrayList<Model>());

    // generate clusters
    ClassLabel[] labels = new ClassLabel[generators.size()];
    Model[] models = new Model[generators.size()];
    initLabelsAndModels(generators, labels, models, relabelClusters);
    final AssignPoint assignment;
    if(!testAgainstModel) {
      assignment = new AssignPoint();
    }
    else if(relabelClusters == null) {
      assignment = new TestModel();
    }
    else if(!relabelDistance) {
      assignment = new AssignLabelsByDensity(labels);
    }
    else {
      assignment = new AssignLabelsByDistance(labels);
    }
    for(int i = 0; i < labels.length; i++) {
      final GeneratorInterface curclus = generators.get(i);
      assignment.newCluster(i, curclus);
      // Only dynamic generators allow rejection / model testing:
      GeneratorInterfaceDynamic cursclus = (curclus instanceof GeneratorInterfaceDynamic) ? (GeneratorInterfaceDynamic) curclus : null;
      int kept = 0;
      while(kept < curclus.getSize()) {
        // generate the "missing" number of points
        List<double[]> newp = curclus.generate(curclus.getSize() - kept);
        for(double[] p : newp) {
          int bestc = assignment.getAssignment(i, p);
          if(bestc < 0) {
            cursclus.incrementDiscarded();
            continue;
          }
          bundle.appendSimple(DoubleVector.wrap(p), labels[bestc], models[bestc]);
          ++kept;
        }
      }
    }
    return bundle;
  }
529191
protected XExpression _generate(XCastedExpression castOperator, IAppendable it, IExtraLanguageGeneratorContext context) {
		return generate(castOperator.getTarget(), context.getExpectedExpressionType(), it, context);
	}
599126
public IRenderingElement generate(IBond currentBond, RendererModel model) {
        IRing ring = RingSetManipulator.getHeaviestRing(ringSet, currentBond);
        if (ring != null) {
            return generateRingElements(currentBond, ring, model);
        } else {
            return generateBond(currentBond, model);
        }
    }
1368914
protected XExpression _generate(XReturnExpression returnStatement, IAppendable it, IExtraLanguageGeneratorContext context) {
		it.append("return "); //$NON-NLS-1$
		generate(returnStatement.getExpression(), it, context);
		return returnStatement;
	}
819289
@Override
    public void generate(final Module module, final Element element) {
        // this is not necessary, it is done to avoid the namespace definition
        // in every item.
        Element root = element;
        while (root.getParent() != null && root.getParent() instanceof Element) {
            root = (Element) element.getParent();
        }
        root.addNamespaceDeclaration(GeoRSSModule.W3CGEO_NS);

        Element pointElement = element;
        if (!isShort) {
            pointElement = new Element("Point", GeoRSSModule.W3CGEO_NS);
            element.addContent(pointElement);
        }

        final GeoRSSModule geoRSSModule = (GeoRSSModule) module;
        final AbstractGeometry geometry = geoRSSModule.getGeometry();

        if (geometry instanceof Point) {
            final Position pos = ((Point) geometry).getPosition();

            final Element latElement = new Element("lat", GeoRSSModule.W3CGEO_NS);
            latElement.addContent(String.valueOf(pos.getLatitude()));
            pointElement.addContent(latElement);
            final Element lngElement = new Element("long", GeoRSSModule.W3CGEO_NS);
            lngElement.addContent(String.valueOf(pos.getLongitude()));
            pointElement.addContent(lngElement);
        } else {
            System.err.println("W3C Geo format can't handle geometries of type: " + geometry.getClass().getName());
        }
    }
669511
@Override
    public Integer generateKey(FacesContext facesContext)
    {
        ExternalContext externalContext = facesContext.getExternalContext();
        Object sessionObj = externalContext.getSession(true);
        Integer sequence = null;
        // synchronized to increase sequence if multiple requests
        // are handled at the same time for the session
        synchronized (sessionObj) 
        {
            Map<String, Object> map = externalContext.getSessionMap();
            sequence = (Integer) map.get(RendererUtils.SEQUENCE_PARAM);
            if (sequence == null || sequence.intValue() == Integer.MAX_VALUE)
            {
                sequence = Integer.valueOf(1);
            }
            else
            {
                sequence = Integer.valueOf(sequence.intValue() + 1);
            }
            map.put(RendererUtils.SEQUENCE_PARAM, sequence);
        }
        return sequence;
    }
867409
public void generate() {
        if (!this.upToDate) {

// Phase One: Sort the symbols by weight into a linked list.

            Symbol head = this.symbols[0];
            Symbol next;
            Symbol previous = head;
            Symbol symbol;

            this.table = null;
            head.next = null;
            for (int i = 1; i < this.domain; i += 1) {
                symbol = symbols[i];

// If this symbol weights less than the head, then it becomes the new head.

                if (symbol.weight < head.weight) {
                    symbol.next = head;
                    head = symbol;
                } else {

// We will start the search from the previous symbol instead of the head unless
// the current symbol weights less than the previous symbol.

                    if (symbol.weight < previous.weight) {
                        previous = head;
                    }

// Find a connected pair (previous and next) where the symbol weighs the same
// or more than previous but less than the next. Link the symbol between them.

                    while (true) {
                        next = previous.next;
                        if (next == null || symbol.weight < next.weight) {
                            break;
                        }
                        previous = next;
                    }
                    symbol.next = next;
                    previous.next = symbol;
                    previous = symbol;
                }
            }

// Phase Two: Make new symbols from the two lightest symbols until only one
// symbol remains. The final symbol becomes the root of the table binary tree.

            int avail = this.domain;
            Symbol first;
            Symbol second;
            previous = head;
            while (true) {
                first = head;
                second = first.next;
                head = second.next;
                symbol = this.symbols[avail];
                avail += 1;
                symbol.weight = first.weight + second.weight;
                symbol.zero = first;
                symbol.one = second;
                symbol.back = null;
                first.back = symbol;
                second.back = symbol;
                if (head == null) {
                    break;
                }

// Insert the new symbol back into the sorted list.

                if (symbol.weight < head.weight) {
                    symbol.next = head;
                    head = symbol;
                    previous = head;
                } else {
                    while (true) {
                        next = previous.next;
                        if (next == null || symbol.weight < next.weight) {
                            break;
                        }
                        previous = next;
                    }
                    symbol.next = next;
                    previous.next = symbol;
                    previous = symbol;
                }

            }

// The last remaining symbol is the root of the table.

            this.table = symbol;
            this.upToDate = true;
        }
    }
577047
@Override
    public void generate(final Module module, final Element element) {
        // this is not necessary, it is done to avoid the namespace definition
        // in every item.
        Element root = element;
        while (root.getParent() != null && root.getParent() instanceof Element) {
            root = (Element) element.getParent();
        }
        root.addNamespaceDeclaration(GeoRSSModule.SIMPLE_NS);
        root.addNamespaceDeclaration(GeoRSSModule.GML_NS);

        final Element whereElement = new Element("where", GeoRSSModule.SIMPLE_NS);
        element.addContent(whereElement);

        final GeoRSSModule geoRSSModule = (GeoRSSModule) module;
        final AbstractGeometry geometry = geoRSSModule.getGeometry();

        if (geometry instanceof Point) {
            final Position pos = ((Point) geometry).getPosition();

            final Element pointElement = new Element("Point", GeoRSSModule.GML_NS);
            whereElement.addContent(pointElement);

            final Element posElement = new Element("pos", GeoRSSModule.GML_NS);
            posElement.addContent(String.valueOf(pos.getLatitude()) + " " + String.valueOf(pos.getLongitude()));
            pointElement.addContent(posElement);
        }

        else if (geometry instanceof LineString) {
            final PositionList posList = ((LineString) geometry).getPositionList();

            final Element lineElement = new Element("LineString", GeoRSSModule.GML_NS);
            lineElement.addContent(createPosListElement(posList));
            whereElement.addContent(lineElement);
        } else if (geometry instanceof Polygon) {
            final Element polygonElement = new Element("Polygon", GeoRSSModule.GML_NS);
            {
                final AbstractRing ring = ((Polygon) geometry).getExterior();
                if (ring instanceof LinearRing) {
                    final Element exteriorElement = new Element("exterior", GeoRSSModule.GML_NS);
                    polygonElement.addContent(exteriorElement);
                    final Element ringElement = new Element("LinearRing", GeoRSSModule.GML_NS);
                    exteriorElement.addContent(ringElement);
                    ringElement.addContent(createPosListElement(((LinearRing) ring).getPositionList()));

                } else {
                    System.err.println("GeoRSS GML format can't handle rings of type: " + ring.getClass().getName());
                }
            }
            final List<AbstractRing> interiorList = ((Polygon) geometry).getInterior();
            final Iterator<AbstractRing> it = interiorList.iterator();
            while (it.hasNext()) {
                final AbstractRing ring = it.next();
                if (ring instanceof LinearRing) {
                    final Element interiorElement = new Element("interior", GeoRSSModule.GML_NS);
                    polygonElement.addContent(interiorElement);
                    final Element ringElement = new Element("LinearRing", GeoRSSModule.GML_NS);
                    interiorElement.addContent(ringElement);
                    ringElement.addContent(createPosListElement(((LinearRing) ring).getPositionList()));

                } else {
                    System.err.println("GeoRSS GML format can't handle rings of type: " + ring.getClass().getName());
                }
            }
            whereElement.addContent(polygonElement);
        } else if (geometry instanceof Envelope) {
            final Envelope envelope = (Envelope) geometry;
            final Element envelopeElement = new Element("Envelope", GeoRSSModule.GML_NS);
            whereElement.addContent(envelopeElement);

            final Element lowerElement = new Element("lowerCorner", GeoRSSModule.GML_NS);
            lowerElement.addContent(String.valueOf(envelope.getMinLatitude()) + " " + String.valueOf(envelope.getMinLongitude()));
            envelopeElement.addContent(lowerElement);

            final Element upperElement = new Element("upperCorner", GeoRSSModule.GML_NS);
            upperElement.addContent(String.valueOf(envelope.getMaxLatitude()) + " " + String.valueOf(envelope.getMaxLongitude()));
            envelopeElement.addContent(upperElement);

        } else {
            System.err.println("GeoRSS GML format can't handle geometries of type: " + geometry.getClass().getName());
        }
    }
45311
public void generate(TypeElement component) {
    ClassName vueFactoryClassName = componentFactoryName(component);

    Builder vueFactoryBuilder = createFactoryBuilderClass(component, vueFactoryClassName);

    createGetName(vueFactoryBuilder, component);
    createProperties(vueFactoryClassName, vueFactoryBuilder);
    List<CodeBlock> staticInitParameters = createInitMethod(component, vueFactoryBuilder);
    createStaticGetMethod(component,
        vueFactoryClassName,
        vueFactoryBuilder,
        staticInitParameters);

    vueFactoryBuilder.addMethod(MethodSpec
        .constructorBuilder()
        .addModifiers(Modifier.PROTECTED)
        .addAnnotation(Inject.class)
        .build());

    // Build the ComponentOptions class
    GeneratorsUtil.toJavaFile(filer, vueFactoryBuilder, vueFactoryClassName, component);
  }
851585
protected void _generate(SarlEvent event, IExtraLanguageGeneratorContext context) {
		final JvmDeclaredType jvmType = getJvmModelAssociations().getInferredType(event);
		final PyAppendable appendable = createAppendable(jvmType, context);
		final List<JvmTypeReference> superTypes;
		if (event.getExtends() != null) {
			superTypes = Collections.singletonList(event.getExtends());
		} else {
			superTypes = Collections.singletonList(getTypeReferences().getTypeForName(Event.class, event));
		}
		if (generateTypeDeclaration(
				this.qualifiedNameProvider.getFullyQualifiedName(event).toString(),
				event.getName(), event.isAbstract(), superTypes,
				getTypeBuilder().getDocumentation(event),
				true,
				event.getMembers(), appendable, context, null)) {
			final QualifiedName name = getQualifiedNameProvider().getFullyQualifiedName(event);
			writeFile(name, appendable, context);
		}
	}
1244418
public void generate() throws CodeGenerationException
    {
        for (AnnotationTypeDeclaration atd : _atds)
        {
            Collection<Declaration> decls = getAnnotationProcessorEnvironment().getDeclarationsAnnotatedWith(atd);
            for (Declaration decl : decls)
            {
                generate(decl);
            }
        }
    }
582191
static Generator byMinuteGenerator(
            int[] minutes, final DateValue dtStart) {
        minutes = Util.uniquify(minutes);
        if (minutes.length == 0) {
            minutes = new int[]{
                    dtStart instanceof TimeValue ? ((TimeValue) dtStart).minute() : 0
            };
        }
        final int[] uminutes = minutes;

        if (uminutes.length == 1) {
            final int minute = uminutes[0];

            return new SingleValueGenerator() {
                int year;
                int month;
                int day;
                int hour;

                @Override
                boolean generate(DTBuilder builder) {
                    if ((year != builder.year) || (month != builder.month)
                            || (day != builder.day) || (hour != builder.hour)) {
                        year = builder.year;
                        month = builder.month;
                        day = builder.day;
                        hour = builder.hour;
                        builder.minute = minute;
                        return true;
                    }
                    return false;
                }

                @Override
                int getValue() {
                    return minute;
                }

                @Override
                public String toString() {
                    return "byMinuteGenerator:" + minute;
                }
            };
        }

        return new Generator() {
            int i;
            int year = dtStart.year();
            int month = dtStart.month();
            int day = dtStart.day();
            int hour = dtStart instanceof TimeValue
                    ? ((TimeValue) dtStart).hour() : 0;

            {
                int minute = dtStart instanceof TimeValue
                        ? ((TimeValue) dtStart).minute() : 0;
                while (i < uminutes.length && uminutes[i] < minute) {
                    ++i;
                }
            }

            @Override
            boolean generate(DTBuilder builder) {
                if ((year != builder.year) || (month != builder.month)
                        || (day != builder.day) || (hour != builder.hour)) {
                    i = 0;
                    year = builder.year;
                    month = builder.month;
                    day = builder.day;
                    hour = builder.hour;
                }
                if (i >= uminutes.length) {
                    return false;
                }
                builder.minute = uminutes[i++];
                return true;
            }

            @Override
            public String toString() {
                return "byMinuteGenerator:" + Arrays.toString(uminutes);
            }
        };
    }
11380
function generateTransformer(name, transformerFns, templateDir, pluginOptions) {

    var Transformer = function () {};
    var transformer = new Transformer();

    // add function mixins to the transformer
    _.extend(transformer, transformerFns, baseTransformer, annotationHelper, utensils, pluginOptions);

    // add reference to the template function
    transformer.setTemplate(templateDir, name, pluginOptions.clientType);

    // each transformer can reference each other
    transformer.transformers = cache;

    // return the transformer
    return transformer;
}