text:
package it.unibz.inf.ontop.iq.optimizer;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import it.unibz.inf.ontop.OptimizationTestingTools;
import it.unibz.inf.ontop.dbschema.RelationDefinition;
import it.unibz.inf.ontop.iq.IQ;
import it.unibz.inf.ontop.iq.IQTree;
import it.unibz.inf.ontop.iq.NaryIQTree;
import it.unibz.inf.ontop.iq.UnaryIQTree;
import it.unibz.inf.ontop.iq.impl.QueryNodeRenamer;
import it.unibz.inf.ontop.iq.node.*;
import it.unibz.inf.ontop.iq.transform.impl.HomogeneousIQTreeVisitingTransformer;
import it.unibz.inf.ontop.model.atom.DistinctVariableOnlyDataAtom;
import it.unibz.inf.ontop.model.template.Template;
import it.unibz.inf.ontop.model.term.ImmutableTerm;
import it.unibz.inf.ontop.substitution.ImmutableSubstitution;
import it.unibz.inf.ontop.substitution.InjectiveVar2VarSubstitution;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static it.unibz.inf.ontop.OptimizationTestingTools.*;
import static org.junit.Assert.assertEquals;

public class AggregationSplitterTest {

    private static final Logger LOGGER = LoggerFactory.getLogger(AggregationSplitterTest.class);
    public final static RelationDefinition T1_AR3, T2_AR3, T3_AR3;
    private static final ImmutableList<Template.Component> TEMPLATE_1, TEMPLATE_2, TEMPLATE_3, TEMPLATE_4, TEMPLATE_5;

    static {
        OptimizationTestingTools.OfflineMetadataProviderBuilder3 builder = createMetadataProviderBuilder();
        T1_AR3 = builder.createRelationWithIntAttributes(1, 3, true);
        T2_AR3 = builder.createRelationWithIntAttributes(2, 3, true);
        T3_AR3 = builder.createRelationWithIntAttributes(3, 3, true);

        TEMPLATE_1 = Template.builder()
                .addSeparator("https://ex.org/template1/")
                .addColumn()
                .build();

        TEMPLATE_2 = Template.builder()
                .addSeparator("https://ex.org/template2/")
                .addColumn()
                .build();

        TEMPLATE_3 = Template.builder()
                .addSeparator("https://ex.org/template")
                .addColumn()
                .addSeparator("/")
                .addColumn()
                .build();

        TEMPLATE_4 = Template.builder()
                .addSeparator("https://ex.org/template1")
                .addColumn()
                .addSeparator("/")
                .addColumn()
                .build();

        TEMPLATE_5 = Template.builder()
                .addSeparator("https://ex.org/template1/")
                .addColumn()
                .addSeparator("2")
                .build();
    }

    @Test
    public void testLiftAggregation1() {
        DistinctVariableOnlyDataAtom projectionAtom = ATOM_FACTORY.getDistinctVariableOnlyDataAtom(ANS1_AR2_PREDICATE, X, Y);

        ExtensionalDataNode dataNode1 = IQ_FACTORY.createExtensionalDataNode(T1_AR3, ImmutableMap.of(0, A));
        ExtensionalDataNode dataNode2 = IQ_FACTORY.createExtensionalDataNode(T2_AR3, ImmutableMap.of(0, A));

        UnionNode unionNode = IQ_FACTORY.createUnionNode(ImmutableSet.of(X, A));

        ImmutableSubstitution<ImmutableTerm> xSubstitution1 = SUBSTITUTION_FACTORY.getSubstitution(X, ONE);

        ConstructionNode constructionNode1 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution1);

        UnaryIQTree child1 = IQ_FACTORY.createUnaryIQTree(
                constructionNode1,
                dataNode1);

        ImmutableSubstitution<ImmutableTerm> xSubstitution2 = SUBSTITUTION_FACTORY.getSubstitution(X, TWO);

        ConstructionNode constructionNode2 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(),
                xSubstitution2);

        UnaryIQTree child2 = IQ_FACTORY.createUnaryIQTree(
                constructionNode2,
                dataNode2);

        NaryIQTree unionTree = IQ_FACTORY.createNaryIQTree(
                unionNode,
                ImmutableList.of(
                        child1,
                        child2));

        AggregationNode aggregationNode = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)
        ));

        IQ initialQuery = IQ_FACTORY.createIQ(
                projectionAtom,
                IQ_FACTORY.createUnaryIQTree(aggregationNode, unionTree));

        UnionNode newUnionNode = IQ_FACTORY.createUnionNode(projectionAtom.getVariables());

        AggregationNode newAggregationNode1 = IQ_FACTORY.createAggregationNode(ImmutableSet.of(), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)));

        IQTree newChild1 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), xSubstitution1),
                applyInDepthRenaming(
                        IQ_FACTORY.createUnaryIQTree(newAggregationNode1, dataNode1),
                        SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(ImmutableMap.of(A, AF0))));

        AggregationNode newAggregationNode2 = IQ_FACTORY.createAggregationNode(ImmutableSet.of(), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)));

        IQTree newChild2 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), xSubstitution2),
                applyInDepthRenaming(
                        IQ_FACTORY.createUnaryIQTree(newAggregationNode2, dataNode2),
                        SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                                ImmutableMap.of(A, AF1))));

        NaryIQTree newUnionTree = IQ_FACTORY.createNaryIQTree(
                newUnionNode,
                ImmutableList.of(newChild1, newChild2));

        IQ expectedQuery = IQ_FACTORY.createIQ(projectionAtom, newUnionTree);

        optimizeAndCompare(initialQuery, expectedQuery);
    }

    private IQTree applyInDepthRenaming(IQTree tree, InjectiveVar2VarSubstitution renaming) {
        QueryNodeRenamer nodeTransformer = new QueryNodeRenamer(IQ_FACTORY, renaming, ATOM_FACTORY);
        HomogeneousIQTreeVisitingTransformer iqTransformer = new HomogeneousIQTreeVisitingTransformer(nodeTransformer, IQ_FACTORY);
        return iqTransformer.transform(tree);
    }

    @Test
    public void testLiftAggregation2() {
        DistinctVariableOnlyDataAtom projectionAtom = ATOM_FACTORY.getDistinctVariableOnlyDataAtom(ANS1_AR2_PREDICATE, X, Y);

        ExtensionalDataNode dataNode1 = IQ_FACTORY.createExtensionalDataNode(T1_AR3, ImmutableMap.of(0, A, 1, B));
        ExtensionalDataNode dataNode2 = IQ_FACTORY.createExtensionalDataNode(T2_AR3, ImmutableMap.of(0, A, 1, C));

        UnionNode unionNode = IQ_FACTORY.createUnionNode(ImmutableSet.of(X, A));

        ImmutableSubstitution<ImmutableTerm> xSubstitution1 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_1, ImmutableList.of(B)).getTerm(0));
        ImmutableSubstitution<ImmutableTerm> xSubstitution2 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_2, ImmutableList.of(C)).getTerm(0));

        ConstructionNode constructionNode1 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution1);

        UnaryIQTree child1 = IQ_FACTORY.createUnaryIQTree(
                constructionNode1,
                dataNode1);

        ConstructionNode constructionNode2 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution2);

        UnaryIQTree child2 = IQ_FACTORY.createUnaryIQTree(
                constructionNode2,
                dataNode2);

        NaryIQTree unionTree = IQ_FACTORY.createNaryIQTree(
                unionNode,
                ImmutableList.of(
                        child1,
                        child2));

        AggregationNode aggregationNode = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)
        ));

        IQ initialQuery = IQ_FACTORY.createIQ(
                projectionAtom,
                IQ_FACTORY.createUnaryIQTree(aggregationNode, unionTree));

        UnionNode newUnionNode = IQ_FACTORY.createUnionNode(projectionAtom.getVariables());

        UnaryIQTree newChild1 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), xSubstitution1),
                applyInDepthRenaming(
                    IQ_FACTORY.createUnaryIQTree(
                            IQ_FACTORY.createAggregationNode(ImmutableSet.of(B), SUBSTITUTION_FACTORY.getSubstitution(
                                        Y, TERM_FACTORY.getDBCount(A, false))),
                        dataNode1),
                        SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                        ImmutableMap.of(A, AF0))));

        UnaryIQTree newChild2 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), xSubstitution2),
                applyInDepthRenaming(
                        IQ_FACTORY.createUnaryIQTree(
                            IQ_FACTORY.createAggregationNode(ImmutableSet.of(C), SUBSTITUTION_FACTORY.getSubstitution(
                                Y, TERM_FACTORY.getDBCount(A, false))),
                        dataNode2), SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                        ImmutableMap.of(A, AF1))));

        NaryIQTree newUnionTree = IQ_FACTORY.createNaryIQTree(
                newUnionNode,
                ImmutableList.of(
                        newChild1,
                        newChild2));

        IQ expectedQuery = IQ_FACTORY.createIQ(projectionAtom, newUnionTree);

        optimizeAndCompare(initialQuery, expectedQuery);
    }

    @Test
    public void testLiftAggregation3() {
        DistinctVariableOnlyDataAtom projectionAtom = ATOM_FACTORY.getDistinctVariableOnlyDataAtom(ANS1_AR2_PREDICATE, X, Y);

        ExtensionalDataNode dataNode1 = IQ_FACTORY.createExtensionalDataNode(T1_AR3, ImmutableMap.of(0, A, 1, B));
        ExtensionalDataNode dataNode2 = IQ_FACTORY.createExtensionalDataNode(T2_AR3, ImmutableMap.of(0, A, 1, C));
        ExtensionalDataNode dataNode3 = IQ_FACTORY.createExtensionalDataNode(T3_AR3, ImmutableMap.of(0, A, 1, D, 2, E));

        UnionNode unionNode = IQ_FACTORY.createUnionNode(ImmutableSet.of(X, A));

        ImmutableSubstitution<ImmutableTerm> xSubstitution1 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_1, ImmutableList.of(B)).getTerm(0));
        ImmutableSubstitution<ImmutableTerm> xSubstitution2 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_2, ImmutableList.of(C)).getTerm(0));
        ImmutableSubstitution<ImmutableTerm> xSubstitution3 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_4, ImmutableList.of(D, E)).getTerm(0));

        ConstructionNode constructionNode1 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution1);

        UnaryIQTree child1 = IQ_FACTORY.createUnaryIQTree(
                constructionNode1,
                dataNode1);

        ConstructionNode constructionNode2 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution2);

        UnaryIQTree child2 = IQ_FACTORY.createUnaryIQTree(
                constructionNode2,
                dataNode2);

        ConstructionNode constructionNode3 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution3);

        UnaryIQTree child3 = IQ_FACTORY.createUnaryIQTree(
                constructionNode3,
                dataNode3);

        NaryIQTree unionTree = IQ_FACTORY.createNaryIQTree(
                unionNode,
                ImmutableList.of(
                        child1,
                        child2,
                        child3));

        AggregationNode aggregationNode = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)
        ));

        IQ initialQuery = IQ_FACTORY.createIQ(
                projectionAtom,
                IQ_FACTORY.createUnaryIQTree(aggregationNode, unionTree));

        UnionNode newUnionNode = IQ_FACTORY.createUnionNode(projectionAtom.getVariables());

        IQTree newChild1 = applyInDepthRenaming(IQ_FACTORY.createUnaryIQTree(
                aggregationNode,
                IQ_FACTORY.createNaryIQTree(
                        unionNode,
                        ImmutableList.of(
                                child1,
                                child3))), SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                ImmutableMap.of(A, AF0)));

        UnaryIQTree newChild2 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), xSubstitution2),
                applyInDepthRenaming(
                IQ_FACTORY.createUnaryIQTree(
                        IQ_FACTORY.createAggregationNode(ImmutableSet.of(C), SUBSTITUTION_FACTORY.getSubstitution(
                                Y, TERM_FACTORY.getDBCount(A, false))),
                        dataNode2), SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                        ImmutableMap.of(A, AF1))));

        NaryIQTree newUnionTree = IQ_FACTORY.createNaryIQTree(
                newUnionNode,
                ImmutableList.of(
                        newChild1,
                        newChild2));

        IQ expectedQuery = IQ_FACTORY.createIQ(projectionAtom, newUnionTree);

        optimizeAndCompare(initialQuery, expectedQuery);
    }

    @Test
    public void testLiftAggregation4() {
        DistinctVariableOnlyDataAtom projectionAtom = ATOM_FACTORY.getDistinctVariableOnlyDataAtom(ANS1_AR2_PREDICATE, X, Y);

        ExtensionalDataNode dataNode1 = IQ_FACTORY.createExtensionalDataNode(T1_AR3, ImmutableMap.of(0, A, 1, B));
        ExtensionalDataNode dataNode2 = IQ_FACTORY.createExtensionalDataNode(T2_AR3, ImmutableMap.of(0, A, 1, C));
        ExtensionalDataNode dataNode3 = IQ_FACTORY.createExtensionalDataNode(T3_AR3, ImmutableMap.of(0, A, 1, D));

        UnionNode unionNode = IQ_FACTORY.createUnionNode(ImmutableSet.of(X, A));

        ImmutableSubstitution<ImmutableTerm> xSubstitution1 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_1, ImmutableList.of(B)).getTerm(0));
        ImmutableSubstitution<ImmutableTerm> xSubstitution2 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_2, ImmutableList.of(C)).getTerm(0));
        ImmutableSubstitution<ImmutableTerm> xSubstitution3 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_5, ImmutableList.of(D)).getTerm(0));

        ConstructionNode constructionNode1 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution1);

        UnaryIQTree child1 = IQ_FACTORY.createUnaryIQTree(
                constructionNode1,
                dataNode1);

        ConstructionNode constructionNode2 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution2);

        UnaryIQTree child2 = IQ_FACTORY.createUnaryIQTree(
                constructionNode2,
                dataNode2);

        ConstructionNode constructionNode3 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution3);

        UnaryIQTree child3 = IQ_FACTORY.createUnaryIQTree(
                constructionNode3,
                dataNode3);

        NaryIQTree unionTree = IQ_FACTORY.createNaryIQTree(
                unionNode,
                ImmutableList.of(
                        child1,
                        child2,
                        child3));

        AggregationNode aggregationNode = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)
        ));

        IQ initialQuery = IQ_FACTORY.createIQ(
                projectionAtom,
                IQ_FACTORY.createUnaryIQTree(aggregationNode, unionTree));

        UnionNode newTopUnionNode = IQ_FACTORY.createUnionNode(projectionAtom.getVariables());

        IQTree newChild1 = applyInDepthRenaming( IQ_FACTORY.createUnaryIQTree(
                        aggregationNode,
                        IQ_FACTORY.createNaryIQTree(
                                unionNode,
                                ImmutableList.of(
                                        child1,
                                        child3))), SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                        ImmutableMap.of(A, AF0)));

        UnaryIQTree newChild2 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newTopUnionNode.getVariables(), xSubstitution2),
                applyInDepthRenaming(
                IQ_FACTORY.createUnaryIQTree(
                        IQ_FACTORY.createAggregationNode(ImmutableSet.of(C), SUBSTITUTION_FACTORY.getSubstitution(
                                Y, TERM_FACTORY.getDBCount(A, false))),
                        dataNode2), SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                        ImmutableMap.of(A, AF1))));

        NaryIQTree newUnionTree = IQ_FACTORY.createNaryIQTree(
                newTopUnionNode,
                ImmutableList.of(
                        newChild1,
                        newChild2));

        IQ expectedQuery = IQ_FACTORY.createIQ(projectionAtom, newUnionTree);

        optimizeAndCompare(initialQuery, expectedQuery);
    }

    @Test
    public void testLiftAggregation5() {
        DistinctVariableOnlyDataAtom projectionAtom = ATOM_FACTORY.getDistinctVariableOnlyDataAtom(ANS1_AR2_PREDICATE, X, Y);

        ExtensionalDataNode dataNode1 = IQ_FACTORY.createExtensionalDataNode(T1_AR3, ImmutableMap.of(0, A));
        ExtensionalDataNode dataNode2 = IQ_FACTORY.createExtensionalDataNode(T2_AR3, ImmutableMap.of(0, A));

        UnionNode unionNode = IQ_FACTORY.createUnionNode(ImmutableSet.of(X, A));

        ImmutableSubstitution<ImmutableTerm> xSubstitution1 = SUBSTITUTION_FACTORY.getSubstitution(X, ONE);

        ConstructionNode constructionNode1 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution1);

        UnaryIQTree child1 = IQ_FACTORY.createUnaryIQTree(
                constructionNode1,
                dataNode1);

        ImmutableSubstitution<ImmutableTerm> xSubstitution2 = SUBSTITUTION_FACTORY.getSubstitution(X, TWO);

        ConstructionNode constructionNode2 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(),
                xSubstitution2);

        UnaryIQTree child2 = IQ_FACTORY.createUnaryIQTree(
                constructionNode2,
                dataNode2);

        NaryIQTree unionTree = IQ_FACTORY.createNaryIQTree(
                unionNode,
                ImmutableList.of(
                        child1,
                        child2,
                        // Duplicate
                        child1));

        AggregationNode aggregationNode = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)
        ));

        IQ initialQuery = IQ_FACTORY.createIQ(
                projectionAtom,
                IQ_FACTORY.createUnaryIQTree(aggregationNode, unionTree));

        UnionNode newUnionNode = IQ_FACTORY.createUnionNode(projectionAtom.getVariables());

        AggregationNode newAggregationNode1 = IQ_FACTORY.createAggregationNode(ImmutableSet.of(), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)));

        IQTree newChild1 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), xSubstitution1),
                applyInDepthRenaming(IQ_FACTORY.createUnaryIQTree(newAggregationNode1,
                                IQ_FACTORY.createNaryIQTree(
                                        IQ_FACTORY.createUnionNode(ImmutableSet.of(A)),
                                        ImmutableList.of(dataNode1, dataNode1))),
                        SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                                ImmutableMap.of(A, AF0))));

        AggregationNode newAggregationNode2 = IQ_FACTORY.createAggregationNode(ImmutableSet.of(), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)));

        IQTree newChild2 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), xSubstitution2),
                applyInDepthRenaming(
                IQ_FACTORY.createUnaryIQTree(newAggregationNode2, dataNode2),
                        SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                                ImmutableMap.of(A, AF1))));

        NaryIQTree newUnionTree = IQ_FACTORY.createNaryIQTree(
                newUnionNode,
                ImmutableList.of(newChild1, newChild2));

        IQ expectedQuery = IQ_FACTORY.createIQ(projectionAtom, newUnionTree);

        optimizeAndCompare(initialQuery, expectedQuery);
    }

    @Test
    public void testLiftAggregation6() {
        DistinctVariableOnlyDataAtom projectionAtom = ATOM_FACTORY.getDistinctVariableOnlyDataAtom(ANS1_AR2_PREDICATE, X, Y);

        ExtensionalDataNode dataNode1 = IQ_FACTORY.createExtensionalDataNode(T1_AR3, ImmutableMap.of(0, A));
        ExtensionalDataNode dataNode2 = IQ_FACTORY.createExtensionalDataNode(T2_AR3, ImmutableMap.of(0, A));

        UnionNode unionNode = IQ_FACTORY.createUnionNode(ImmutableSet.of(X, A));

        ImmutableSubstitution<ImmutableTerm> xSubstitution1 = SUBSTITUTION_FACTORY.getSubstitution(X, NULL);

        ConstructionNode constructionNode1 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution1);

        UnaryIQTree child1 = IQ_FACTORY.createUnaryIQTree(
                constructionNode1,
                dataNode1);

        ImmutableSubstitution<ImmutableTerm> xSubstitution2 = SUBSTITUTION_FACTORY.getSubstitution(X, TWO);

        ConstructionNode constructionNode2 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(),
                xSubstitution2);

        UnaryIQTree child2 = IQ_FACTORY.createUnaryIQTree(
                constructionNode2,
                dataNode2);

        NaryIQTree unionTree = IQ_FACTORY.createNaryIQTree(
                unionNode,
                ImmutableList.of(
                        child1,
                        child2,
                        // Duplicate
                        child1));

        AggregationNode aggregationNode = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)
        ));

        IQ initialQuery = IQ_FACTORY.createIQ(
                projectionAtom,
                IQ_FACTORY.createUnaryIQTree(aggregationNode, unionTree));

        UnionNode newUnionNode = IQ_FACTORY.createUnionNode(projectionAtom.getVariables());

        AggregationNode newAggregationNode1 = IQ_FACTORY.createAggregationNode(ImmutableSet.of(), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)));

        IQTree newChild1 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), xSubstitution1),
                applyInDepthRenaming(
                IQ_FACTORY.createUnaryIQTree(newAggregationNode1,
                                IQ_FACTORY.createNaryIQTree(
                                        IQ_FACTORY.createUnionNode(ImmutableSet.of(A)),
                                        ImmutableList.of(dataNode1, dataNode1))),
                        SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                                ImmutableMap.of(A, AF0))));

        AggregationNode newAggregationNode2 = IQ_FACTORY.createAggregationNode(ImmutableSet.of(), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)));

        IQTree newChild2 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), xSubstitution2),
                applyInDepthRenaming(IQ_FACTORY.createUnaryIQTree(newAggregationNode2, dataNode2),
                        SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                                ImmutableMap.of(A, AF1))));

        NaryIQTree newUnionTree = IQ_FACTORY.createNaryIQTree(
                newUnionNode,
                ImmutableList.of(newChild1, newChild2));

        IQ expectedQuery = IQ_FACTORY.createIQ(projectionAtom, newUnionTree);

        optimizeAndCompare(initialQuery, expectedQuery);
    }

    @Test
    public void testLiftAggregation7() {
        DistinctVariableOnlyDataAtom projectionAtom = ATOM_FACTORY.getDistinctVariableOnlyDataAtom(ANS1_AR3_PREDICATE, X, Y, Z);

        ExtensionalDataNode dataNode1 = IQ_FACTORY.createExtensionalDataNode(T1_AR3, ImmutableMap.of(0, A));
        ExtensionalDataNode dataNode2 = IQ_FACTORY.createExtensionalDataNode(T2_AR3, ImmutableMap.of(0, A));

        UnionNode unionNode = IQ_FACTORY.createUnionNode(ImmutableSet.of(Z, A));

        ImmutableSubstitution<ImmutableTerm> zSubstitution1 = SUBSTITUTION_FACTORY.getSubstitution(Z, ONE);

        ConstructionNode constructionNode1 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), zSubstitution1);

        UnaryIQTree child1 = IQ_FACTORY.createUnaryIQTree(
                constructionNode1,
                dataNode1);

        ImmutableSubstitution<ImmutableTerm> zSubstitution2 = SUBSTITUTION_FACTORY.getSubstitution(Z, TWO);

        ConstructionNode constructionNode2 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(),
                zSubstitution2);

        UnaryIQTree child2 = IQ_FACTORY.createUnaryIQTree(
                constructionNode2,
                dataNode2);

        NaryIQTree unionTree = IQ_FACTORY.createNaryIQTree(
                unionNode,
                ImmutableList.of(
                        child1,
                        child2));

        ConstructionNode commonConstructionNode = IQ_FACTORY.createConstructionNode(ImmutableSet.of(X,Z, A),
                SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getDBBinaryNumericFunctionalTerm("+",
                        TYPE_FACTORY.getDBTypeFactory().getDBLargeIntegerType(), Z, A)));

        AggregationNode aggregationNode = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X,Z), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)
        ));

        IQ initialQuery = IQ_FACTORY.createIQ(
                projectionAtom,
                IQ_FACTORY.createUnaryIQTree(aggregationNode,
                        IQ_FACTORY.createUnaryIQTree(
                                commonConstructionNode,
                                unionTree)));

        UnionNode newUnionNode = IQ_FACTORY.createUnionNode(projectionAtom.getVariables());

        AggregationNode newAggregationNode1 = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)));

        IQTree newChild1 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), zSubstitution1),
                applyInDepthRenaming(
                IQ_FACTORY.createUnaryIQTree(
                        newAggregationNode1,
                                IQ_FACTORY.createUnaryIQTree(
                                        IQ_FACTORY.createConstructionNode(ImmutableSet.of(X,A),
                                                SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getDBBinaryNumericFunctionalTerm("+",
                                                        TYPE_FACTORY.getDBTypeFactory().getDBLargeIntegerType(), ONE, A))),
                                                dataNode1)),
                        SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                                ImmutableMap.of(A, AF0))));

        AggregationNode newAggregationNode2 = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)));

        IQTree newChild2 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), zSubstitution2),
                applyInDepthRenaming(
                IQ_FACTORY.createUnaryIQTree(
                        newAggregationNode2,
                        IQ_FACTORY.createUnaryIQTree(
                                IQ_FACTORY.createConstructionNode(ImmutableSet.of(X,A),
                                        SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getDBBinaryNumericFunctionalTerm("+",
                                                TYPE_FACTORY.getDBTypeFactory().getDBLargeIntegerType(), TWO, A))),
                                dataNode2)),
                        SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                                ImmutableMap.of(A, AF1))));

        NaryIQTree newUnionTree = IQ_FACTORY.createNaryIQTree(
                newUnionNode,
                ImmutableList.of(newChild1, newChild2));

        IQ expectedQuery = IQ_FACTORY.createIQ(projectionAtom, newUnionTree);

        optimizeAndCompare(initialQuery, expectedQuery);
    }

    @Test
    public void testLiftAggregation8() {
        DistinctVariableOnlyDataAtom projectionAtom = ATOM_FACTORY.getDistinctVariableOnlyDataAtom(ANS1_AR3_PREDICATE, X, Y, Z);

        ExtensionalDataNode dataNode1 = IQ_FACTORY.createExtensionalDataNode(T1_AR3, ImmutableMap.of(0, A, 1, B));
        ExtensionalDataNode dataNode2 = IQ_FACTORY.createExtensionalDataNode(T2_AR3, ImmutableMap.of(0, A, 1, B));

        UnionNode unionNode = IQ_FACTORY.createUnionNode(ImmutableSet.of(Z, A, B));

        ImmutableSubstitution<ImmutableTerm> zSubstitution1 = SUBSTITUTION_FACTORY.getSubstitution(Z, ONE);

        ConstructionNode constructionNode1 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), zSubstitution1);

        UnaryIQTree child1 = IQ_FACTORY.createUnaryIQTree(
                constructionNode1,
                dataNode1);

        ImmutableSubstitution<ImmutableTerm> zSubstitution2 = SUBSTITUTION_FACTORY.getSubstitution(Z, TWO);

        ConstructionNode constructionNode2 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(),
                zSubstitution2);

        UnaryIQTree child2 = IQ_FACTORY.createUnaryIQTree(
                constructionNode2,
                dataNode2);

        NaryIQTree unionTree = IQ_FACTORY.createNaryIQTree(
                unionNode,
                ImmutableList.of(
                        child1,
                        child2));

        ConstructionNode commonConstructionNode = IQ_FACTORY.createConstructionNode(ImmutableSet.of(X,Z, A),
                SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getDBBinaryNumericFunctionalTerm("+",
                        TYPE_FACTORY.getDBTypeFactory().getDBLargeIntegerType(), Z, B)));

        AggregationNode aggregationNode = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X,Z), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)
        ));

        IQ initialQuery = IQ_FACTORY.createIQ(
                projectionAtom,
                IQ_FACTORY.createUnaryIQTree(aggregationNode,
                        IQ_FACTORY.createUnaryIQTree(
                                commonConstructionNode,
                                unionTree)));

        UnionNode newUnionNode = IQ_FACTORY.createUnionNode(projectionAtom.getVariables());

        AggregationNode newAggregationNode1 = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)));

        IQTree newChild1 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), zSubstitution1),
                applyInDepthRenaming(
                IQ_FACTORY.createUnaryIQTree(
                                newAggregationNode1,
                                IQ_FACTORY.createUnaryIQTree(
                                        IQ_FACTORY.createConstructionNode(ImmutableSet.of(X,A),
                                                SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getDBBinaryNumericFunctionalTerm("+",
                                                        TYPE_FACTORY.getDBTypeFactory().getDBLargeIntegerType(), ONE, B))),
                                        dataNode1)),
                        SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                                ImmutableMap.of(A, AF0))));

        AggregationNode newAggregationNode2 = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)));

        IQTree newChild2 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), zSubstitution2),
                applyInDepthRenaming(
                IQ_FACTORY.createUnaryIQTree(
                                newAggregationNode2,
                                IQ_FACTORY.createUnaryIQTree(
                                        IQ_FACTORY.createConstructionNode(ImmutableSet.of(X,A),
                                                SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getDBBinaryNumericFunctionalTerm("+",
                                                        TYPE_FACTORY.getDBTypeFactory().getDBLargeIntegerType(), TWO, B))),
                                        dataNode2)),
                        SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                                ImmutableMap.of(A, AF1))));

        NaryIQTree newUnionTree = IQ_FACTORY.createNaryIQTree(
                newUnionNode,
                ImmutableList.of(newChild1, newChild2));

        IQ expectedQuery = IQ_FACTORY.createIQ(projectionAtom, newUnionTree);

        optimizeAndCompare(initialQuery, expectedQuery);
    }

    @Test
    public void testLiftAggregationDistinct1() {
        DistinctVariableOnlyDataAtom projectionAtom = ATOM_FACTORY.getDistinctVariableOnlyDataAtom(ANS1_AR2_PREDICATE, X, Y);

        ExtensionalDataNode dataNode1 = IQ_FACTORY.createExtensionalDataNode(T1_AR3, ImmutableMap.of(0, A, 1, B));
        ExtensionalDataNode dataNode2 = IQ_FACTORY.createExtensionalDataNode(T2_AR3, ImmutableMap.of(0, A, 1, C));
        ExtensionalDataNode dataNode3 = IQ_FACTORY.createExtensionalDataNode(T3_AR3, ImmutableMap.of(0, A, 1, D));

        UnionNode unionNode = IQ_FACTORY.createUnionNode(ImmutableSet.of(X, A));

        ImmutableSubstitution<ImmutableTerm> xSubstitution1 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_1, ImmutableList.of(B)).getTerm(0));
        ImmutableSubstitution<ImmutableTerm> xSubstitution2 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_2, ImmutableList.of(C)).getTerm(0));
        ImmutableSubstitution<ImmutableTerm> xSubstitution3 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_5, ImmutableList.of(D)).getTerm(0));

        ConstructionNode constructionNode1 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution1);

        UnaryIQTree child1 = IQ_FACTORY.createUnaryIQTree(
                constructionNode1,
                dataNode1);

        ConstructionNode constructionNode2 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution2);

        UnaryIQTree child2 = IQ_FACTORY.createUnaryIQTree(
                constructionNode2,
                dataNode2);

        ConstructionNode constructionNode3 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution3);

        UnaryIQTree child3 = IQ_FACTORY.createUnaryIQTree(
                constructionNode3,
                dataNode3);

        NaryIQTree unionTree = IQ_FACTORY.createNaryIQTree(
                unionNode,
                ImmutableList.of(
                        child1,
                        child2,
                        child3));

        DistinctNode distinctNode = IQ_FACTORY.createDistinctNode();

        AggregationNode aggregationNode = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)
        ));

        IQ initialQuery = IQ_FACTORY.createIQ(
                projectionAtom,
                IQ_FACTORY.createUnaryIQTree(aggregationNode,
                        IQ_FACTORY.createUnaryIQTree(
                                distinctNode, unionTree)));

        UnionNode newTopUnionNode = IQ_FACTORY.createUnionNode(projectionAtom.getVariables());

        IQTree newChild1 = applyInDepthRenaming(IQ_FACTORY.createUnaryIQTree(
                aggregationNode,
                IQ_FACTORY.createUnaryIQTree(
                        distinctNode,
                        IQ_FACTORY.createNaryIQTree(
                                unionNode,
                                ImmutableList.of(
                                        child1,
                                        child3)))),
                SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                ImmutableMap.of(A, AF0)));

        UnaryIQTree newChild2 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newTopUnionNode.getVariables(), xSubstitution2),
                applyInDepthRenaming(
                IQ_FACTORY.createUnaryIQTree(
                        IQ_FACTORY.createAggregationNode(ImmutableSet.of(C), SUBSTITUTION_FACTORY.getSubstitution(
                                Y, TERM_FACTORY.getDBCount(A, false))),
                        IQ_FACTORY.createUnaryIQTree(
                                distinctNode,
                                dataNode2)),
                SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                        ImmutableMap.of(A, AF1))));

        NaryIQTree newUnionTree = IQ_FACTORY.createNaryIQTree(
                newTopUnionNode,
                ImmutableList.of(
                        newChild1,
                        newChild2));

        IQ expectedQuery = IQ_FACTORY.createIQ(projectionAtom, newUnionTree);

        optimizeAndCompare(initialQuery, expectedQuery);
    }

    @Test
    public void testLiftAggregationDistinct2() {
        DistinctVariableOnlyDataAtom projectionAtom = ATOM_FACTORY.getDistinctVariableOnlyDataAtom(ANS1_AR3_PREDICATE, X, Y, Z);

        ExtensionalDataNode dataNode1 = IQ_FACTORY.createExtensionalDataNode(T1_AR3, ImmutableMap.of(0, A, 1, B));
        ExtensionalDataNode dataNode2 = IQ_FACTORY.createExtensionalDataNode(T2_AR3, ImmutableMap.of(0, A, 1, B));

        UnionNode unionNode = IQ_FACTORY.createUnionNode(ImmutableSet.of(Z, A, B));

        ImmutableSubstitution<ImmutableTerm> zSubstitution1 = SUBSTITUTION_FACTORY.getSubstitution(Z, ONE);

        ConstructionNode constructionNode1 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), zSubstitution1);

        UnaryIQTree child1 = IQ_FACTORY.createUnaryIQTree(
                constructionNode1,
                dataNode1);

        ImmutableSubstitution<ImmutableTerm> zSubstitution2 = SUBSTITUTION_FACTORY.getSubstitution(Z, TWO);

        ConstructionNode constructionNode2 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(),
                zSubstitution2);

        UnaryIQTree child2 = IQ_FACTORY.createUnaryIQTree(
                constructionNode2,
                dataNode2);

        NaryIQTree unionTree = IQ_FACTORY.createNaryIQTree(
                unionNode,
                ImmutableList.of(
                        child1,
                        child2));

        ConstructionNode commonConstructionNode = IQ_FACTORY.createConstructionNode(ImmutableSet.of(X,Z, A),
                SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getDBBinaryNumericFunctionalTerm("+",
                        TYPE_FACTORY.getDBTypeFactory().getDBLargeIntegerType(), Z, B)));

        DistinctNode distinctNode = IQ_FACTORY.createDistinctNode();

        AggregationNode aggregationNode = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X,Z), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)
        ));

        IQ initialQuery = IQ_FACTORY.createIQ(
                projectionAtom,
                IQ_FACTORY.createUnaryIQTree(aggregationNode,
                        IQ_FACTORY.createUnaryIQTree(
                                distinctNode,
                                IQ_FACTORY.createUnaryIQTree(
                                        commonConstructionNode,
                                        unionTree))));

        UnionNode newUnionNode = IQ_FACTORY.createUnionNode(projectionAtom.getVariables());

        AggregationNode newAggregationNode1 = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)));

        IQTree newChild1 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), zSubstitution1),
                applyInDepthRenaming(
                IQ_FACTORY.createUnaryIQTree(
                                newAggregationNode1,
                                IQ_FACTORY.createUnaryIQTree(
                                                distinctNode,
                                                IQ_FACTORY.createUnaryIQTree(
                                                        IQ_FACTORY.createConstructionNode(ImmutableSet.of(X,A),
                                                                SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getDBBinaryNumericFunctionalTerm("+",
                                                                        TYPE_FACTORY.getDBTypeFactory().getDBLargeIntegerType(), ONE, B))),
                                                        dataNode1))),
                        SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                                ImmutableMap.of(A, AF0))));

        AggregationNode newAggregationNode2 = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)));

        IQTree newChild2 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), zSubstitution2),
                applyInDepthRenaming(
                IQ_FACTORY.createUnaryIQTree(
                                newAggregationNode2,
                                IQ_FACTORY.createUnaryIQTree(
                                        distinctNode,
                                    IQ_FACTORY.createUnaryIQTree(
                                            IQ_FACTORY.createConstructionNode(ImmutableSet.of(X,A),
                                                    SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getDBBinaryNumericFunctionalTerm("+",
                                                            TYPE_FACTORY.getDBTypeFactory().getDBLargeIntegerType(), TWO, B))),
                                            dataNode2))),
                        SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(ImmutableMap.of(A, AF1))));

        NaryIQTree newUnionTree = IQ_FACTORY.createNaryIQTree(
                newUnionNode,
                ImmutableList.of(newChild1, newChild2));

        IQ expectedQuery = IQ_FACTORY.createIQ(projectionAtom, newUnionTree);

        optimizeAndCompare(initialQuery, expectedQuery);
    }

    @Test
    public void testLiftAggregationDistinct3() {
        DistinctVariableOnlyDataAtom projectionAtom = ATOM_FACTORY.getDistinctVariableOnlyDataAtom(ANS1_AR3_PREDICATE, X, Y, Z);

        ExtensionalDataNode dataNode1 = IQ_FACTORY.createExtensionalDataNode(T1_AR3, ImmutableMap.of(0, A, 1, B));
        ExtensionalDataNode dataNode2 = IQ_FACTORY.createExtensionalDataNode(T2_AR3, ImmutableMap.of(0, A, 1, B));

        UnionNode unionNode = IQ_FACTORY.createUnionNode(ImmutableSet.of(Z, A, B));

        ImmutableSubstitution<ImmutableTerm> zSubstitution1 = SUBSTITUTION_FACTORY.getSubstitution(Z, ONE);

        ConstructionNode constructionNode1 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), zSubstitution1);

        UnaryIQTree child1 = IQ_FACTORY.createUnaryIQTree(
                constructionNode1,
                dataNode1);

        ImmutableSubstitution<ImmutableTerm> zSubstitution2 = SUBSTITUTION_FACTORY.getSubstitution(Z, TWO);

        ConstructionNode constructionNode2 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(),
                zSubstitution2);

        UnaryIQTree child2 = IQ_FACTORY.createUnaryIQTree(
                constructionNode2,
                dataNode2);

        NaryIQTree unionTree = IQ_FACTORY.createNaryIQTree(
                unionNode,
                ImmutableList.of(
                        child1,
                        child2));

        ConstructionNode commonConstructionNode = IQ_FACTORY.createConstructionNode(ImmutableSet.of(X,Z, A),
                SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getDBBinaryNumericFunctionalTerm("+",
                        TYPE_FACTORY.getDBTypeFactory().getDBLargeIntegerType(), Z, B)));

        DistinctNode distinctNode = IQ_FACTORY.createDistinctNode();

        AggregationNode aggregationNode = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X,Z), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)
        ));

        IQ initialQuery = IQ_FACTORY.createIQ(
                projectionAtom,
                IQ_FACTORY.createUnaryIQTree(aggregationNode,
                        IQ_FACTORY.createUnaryIQTree(
                                commonConstructionNode,
                                IQ_FACTORY.createUnaryIQTree(
                                        distinctNode,
                                        unionTree))));

        UnionNode newUnionNode = IQ_FACTORY.createUnionNode(projectionAtom.getVariables());

        AggregationNode newAggregationNode1 = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)));

        IQTree newChild1 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), zSubstitution1),
                applyInDepthRenaming(IQ_FACTORY.createUnaryIQTree(
                                newAggregationNode1,
                                IQ_FACTORY.createUnaryIQTree(
                                        IQ_FACTORY.createConstructionNode(ImmutableSet.of(X,A),
                                                SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getDBBinaryNumericFunctionalTerm("+",
                                                        TYPE_FACTORY.getDBTypeFactory().getDBLargeIntegerType(), ONE, B))),
                                        IQ_FACTORY.createUnaryIQTree(
                                                distinctNode,
                                                dataNode1))),
                        SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                                ImmutableMap.of(A, AF0))));

        AggregationNode newAggregationNode2 = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)));

        IQTree newChild2 = IQ_FACTORY.createUnaryIQTree(
                IQ_FACTORY.createConstructionNode(newUnionNode.getVariables(), zSubstitution2),
                applyInDepthRenaming(
                IQ_FACTORY.createUnaryIQTree(
                                newAggregationNode2,
                                IQ_FACTORY.createUnaryIQTree(
                                        IQ_FACTORY.createConstructionNode(ImmutableSet.of(X,A),
                                                SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getDBBinaryNumericFunctionalTerm("+",
                                                        TYPE_FACTORY.getDBTypeFactory().getDBLargeIntegerType(), TWO, B))),
                                        IQ_FACTORY.createUnaryIQTree(
                                                distinctNode,
                                                dataNode2))),
                        SUBSTITUTION_FACTORY.getInjectiveVar2VarSubstitution(
                                ImmutableMap.of(A, AF1))));

        NaryIQTree newUnionTree = IQ_FACTORY.createNaryIQTree(
                newUnionNode,
                ImmutableList.of(newChild1, newChild2));

        IQ expectedQuery = IQ_FACTORY.createIQ(projectionAtom, newUnionTree);

        optimizeAndCompare(initialQuery, expectedQuery);
    }

    @Test
    public void testNoLiftAggregation1() {
        DistinctVariableOnlyDataAtom projectionAtom = ATOM_FACTORY.getDistinctVariableOnlyDataAtom(ANS1_AR2_PREDICATE, X, Y);

        ExtensionalDataNode dataNode1 = IQ_FACTORY.createExtensionalDataNode(T1_AR3, ImmutableMap.of(0, A, 1, B));
        ExtensionalDataNode dataNode2 = IQ_FACTORY.createExtensionalDataNode(T2_AR3, ImmutableMap.of(0, A, 1, C, 2, D));

        UnionNode unionNode = IQ_FACTORY.createUnionNode(ImmutableSet.of(X, A));

        ImmutableSubstitution<ImmutableTerm> xSubstitution1 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_1, ImmutableList.of(B)).getTerm(0));
        ImmutableSubstitution<ImmutableTerm> xSubstitution2 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_3, ImmutableList.of(C, D)).getTerm(0));

        ConstructionNode constructionNode1 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution1);

        UnaryIQTree child1 = IQ_FACTORY.createUnaryIQTree(
                constructionNode1,
                dataNode1);

        ConstructionNode constructionNode2 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution2);

        UnaryIQTree child2 = IQ_FACTORY.createUnaryIQTree(
                constructionNode2,
                dataNode2);

        NaryIQTree unionTree = IQ_FACTORY.createNaryIQTree(
                unionNode,
                ImmutableList.of(
                        child1,
                        child2));

        AggregationNode aggregationNode = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)
        ));

        IQ initialQuery = IQ_FACTORY.createIQ(
                projectionAtom,
                IQ_FACTORY.createUnaryIQTree(aggregationNode, unionTree));

        optimizeAndCompare(initialQuery, initialQuery);
    }

    @Test
    public void testNoLiftAggregation2() {
        DistinctVariableOnlyDataAtom projectionAtom = ATOM_FACTORY.getDistinctVariableOnlyDataAtom(ANS1_AR2_PREDICATE, X, Y);

        ExtensionalDataNode dataNode1 = IQ_FACTORY.createExtensionalDataNode(T1_AR3, ImmutableMap.of(0, A, 1, B));
        ExtensionalDataNode dataNode2 = IQ_FACTORY.createExtensionalDataNode(T2_AR3, ImmutableMap.of(0, A, 1, E));
        ExtensionalDataNode dataNode3 = IQ_FACTORY.createExtensionalDataNode(T3_AR3, ImmutableMap.of(0, A, 1, C, 2, D));

        UnionNode unionNode = IQ_FACTORY.createUnionNode(ImmutableSet.of(X, A));

        ImmutableSubstitution<ImmutableTerm> xSubstitution1 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_1, ImmutableList.of(B)).getTerm(0));
        ImmutableSubstitution<ImmutableTerm> xSubstitution2 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_2, ImmutableList.of(E)).getTerm(0));
        ImmutableSubstitution<ImmutableTerm> xSubstitution3 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_3, ImmutableList.of(C, D)).getTerm(0));

        ConstructionNode constructionNode1 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution1);

        UnaryIQTree child1 = IQ_FACTORY.createUnaryIQTree(
                constructionNode1,
                dataNode1);

        ConstructionNode constructionNode2 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution2);

        UnaryIQTree child2 = IQ_FACTORY.createUnaryIQTree(
                constructionNode2,
                dataNode2);

        ConstructionNode constructionNode3 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution3);

        UnaryIQTree child3 = IQ_FACTORY.createUnaryIQTree(
                constructionNode3,
                dataNode3);

        NaryIQTree unionTree = IQ_FACTORY.createNaryIQTree(
                unionNode,
                ImmutableList.of(
                        child1,
                        child2,
                        child3));

        AggregationNode aggregationNode = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)
        ));

        IQ initialQuery = IQ_FACTORY.createIQ(
                projectionAtom,
                IQ_FACTORY.createUnaryIQTree(aggregationNode, unionTree));

        optimizeAndCompare(initialQuery, initialQuery);
    }

    @Test
    public void testNoLiftAggregation3() {
        DistinctVariableOnlyDataAtom projectionAtom = ATOM_FACTORY.getDistinctVariableOnlyDataAtom(ANS1_AR2_PREDICATE, X, Y);

        ExtensionalDataNode dataNode1 = IQ_FACTORY.createExtensionalDataNode(T1_AR3, ImmutableMap.of(0, A, 1, B));
        ExtensionalDataNode dataNode2 = IQ_FACTORY.createExtensionalDataNode(T2_AR3, ImmutableMap.of(0, A, 1, E));
        ExtensionalDataNode dataNode3 = IQ_FACTORY.createExtensionalDataNode(T3_AR3, ImmutableMap.of(0, A, 1, X));

        UnionNode unionNode = IQ_FACTORY.createUnionNode(ImmutableSet.of(X, A));

        ImmutableSubstitution<ImmutableTerm> xSubstitution1 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_1, ImmutableList.of(B)).getTerm(0));
        ImmutableSubstitution<ImmutableTerm> xSubstitution2 = SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getIRIFunctionalTerm(TEMPLATE_2, ImmutableList.of(E)).getTerm(0));

        ConstructionNode constructionNode1 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution1);

        UnaryIQTree child1 = IQ_FACTORY.createUnaryIQTree(
                constructionNode1,
                dataNode1);

        ConstructionNode constructionNode2 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution2);

        UnaryIQTree child2 = IQ_FACTORY.createUnaryIQTree(
                constructionNode2,
                dataNode2);

        NaryIQTree unionTree = IQ_FACTORY.createNaryIQTree(
                unionNode,
                ImmutableList.of(
                        child1,
                        child2,
                        dataNode3));

        AggregationNode aggregationNode = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)
        ));

        IQ initialQuery = IQ_FACTORY.createIQ(
                projectionAtom,
                IQ_FACTORY.createUnaryIQTree(aggregationNode, unionTree));

        optimizeAndCompare(initialQuery, initialQuery);
    }

    @Test
    public void testNoLiftAggregation4() {
        DistinctVariableOnlyDataAtom projectionAtom = ATOM_FACTORY.getDistinctVariableOnlyDataAtom(ANS1_AR2_PREDICATE, X, Y);

        ExtensionalDataNode dataNode1 = IQ_FACTORY.createExtensionalDataNode(T1_AR3, ImmutableMap.of(0, A));
        ExtensionalDataNode dataNode2 = IQ_FACTORY.createExtensionalDataNode(T2_AR3, ImmutableMap.of(0, A));

        UnionNode unionNode = IQ_FACTORY.createUnionNode(ImmutableSet.of(B, A));

        ImmutableSubstitution<ImmutableTerm> xSubstitution1 = SUBSTITUTION_FACTORY.getSubstitution(B, ONE);

        ConstructionNode constructionNode1 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(), xSubstitution1);

        UnaryIQTree child1 = IQ_FACTORY.createUnaryIQTree(
                constructionNode1,
                dataNode1);

        ImmutableSubstitution<ImmutableTerm> xSubstitution2 = SUBSTITUTION_FACTORY.getSubstitution(B, TWO);

        ConstructionNode constructionNode2 = IQ_FACTORY.createConstructionNode(unionNode.getVariables(),
                xSubstitution2);

        UnaryIQTree child2 = IQ_FACTORY.createUnaryIQTree(
                constructionNode2,
                dataNode2);

        NaryIQTree unionTree = IQ_FACTORY.createNaryIQTree(
                unionNode,
                ImmutableList.of(
                        child1,
                        child2));

        ConstructionNode commonConstructionNode = IQ_FACTORY.createConstructionNode(ImmutableSet.of(X,A),
                SUBSTITUTION_FACTORY.getSubstitution(X, TERM_FACTORY.getDBBinaryNumericFunctionalTerm("+",
                        TYPE_FACTORY.getDBTypeFactory().getDBLargeIntegerType(), B, B)));

        AggregationNode aggregationNode = IQ_FACTORY.createAggregationNode(ImmutableSet.of(X), SUBSTITUTION_FACTORY.getSubstitution(
                Y, TERM_FACTORY.getDBCount(A, false)
        ));

        IQ initialQuery = IQ_FACTORY.createIQ(
                projectionAtom,
                IQ_FACTORY.createUnaryIQTree(aggregationNode,
                        IQ_FACTORY.createUnaryIQTree(
                                commonConstructionNode,
                                unionTree)));

        optimizeAndCompare(initialQuery, initialQuery);
    }

    private void optimizeAndCompare(IQ initialQuery, IQ expectedQuery) {
        IQ optimizedQuery = GENERAL_STRUCTURAL_AND_SEMANTIC_IQ_OPTIMIZER.optimize(initialQuery);
        LOGGER.debug("Initial query: {}", initialQuery);
        assertEquals(expectedQuery, optimizedQuery);
        LOGGER.debug("Optimized query: {}", optimizedQuery);
    }
}


text:
/*
 * This file is generated by jOOQ.
 */
package ch.rasc.twofa.db;

import java.util.Arrays;
import java.util.List;

import org.jooq.Catalog;
import org.jooq.Table;
import org.jooq.impl.SchemaImpl;

import ch.rasc.twofa.db.tables.AppUser;

/**
 * This class is generated by jOOQ.
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class DefaultSchema extends SchemaImpl {

  private static final long serialVersionUID = 167556424;

  /**
   * The reference instance of DEFAULT_SCHEMA
   */
  public static final DefaultSchema DEFAULT_SCHEMA = new DefaultSchema();

  /**
   * No further instances allowed
   */
  private DefaultSchema() {
    super("", null);
  }

  @Override
  public Catalog getCatalog() {
    return DefaultCatalog.DEFAULT_CATALOG;
  }

  @Override
  public final List<Table<?>> getTables() {
    return Arrays.<Table<?>>asList(AppUser.APP_USER);
  }
}

redpajama_set_name: RedPajamaGithub


text:
package blackberry.io.file;

import net.rim.device.api.io.file.FileIOException;

import blackberry.core.FunctionSignature;
import blackberry.core.ScriptableFunctionBase;
import blackberry.io.FileConnectionWrapper;

/**
 * JavaScript function class - renames a specified file
 */
public final class RenameFunction extends ScriptableFunctionBase {

    public static final String NAME = "rename";

    /**
     * Rename a given file
     *
     * @param args
     *            args[0]: a compelte URL path to a file that is to be renamed.
     *
     *            IOException will be thrown if src file does not yet exist, or the src path is to an directory
     */

    public Object execute( Object thiz, Object[] args ) throws Exception {
        FileConnectionWrapper fConnWrap = null;
        try {
            fConnWrap = new FileConnectionWrapper( args[ 0 ].toString() );

            if( !fConnWrap.exists() ) {
                throw new FileIOException( FileIOException.FILENAME_NOT_FOUND );
            }

            if( fConnWrap.isDirectory() ) {
                throw new FileIOException( FileIOException.NOT_A_FILE );
            }

            fConnWrap.getFileConnection().rename( args[ 1 ].toString() );
        } finally {
            if( fConnWrap != null ) {
                fConnWrap.close();
            }
        }
        return UNDEFINED;
    }

    /**
     * @see blackberry.core.ScriptableFunctionBase#getFunctionSignatures
     */
    protected FunctionSignature[] getFunctionSignatures() {
        FunctionSignature fs = new FunctionSignature( 2 );
        fs.addParam( String.class, true );
        fs.addParam( String.class, true );
        return new FunctionSignature[] { fs };
    }
}


text:
<?php

namespace Doctrine\ORM\Tools;

use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
use Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Events;

/**
 * ResolveTargetEntityListener
 *
 * Mechanism to overwrite interfaces or classes specified as association
 * targets.
 *
 * @author Benjamin Eberlei <kontakt@beberlei.de>
 * @since 2.2
 */
class ResolveTargetEntityListener implements EventSubscriber
{
    /**
     * @var array[] indexed by original entity name
     */
    private $resolveTargetEntities = array();

    /**
     * {@inheritDoc}
     */
    public function getSubscribedEvents()
    {
        return array(
            Events::loadClassMetadata,
            Events::onClassMetadataNotFound
        );
    }

    /**
     * Adds a target-entity class name to resolve to a new class name.
     *
     * @param string $originalEntity
     * @param string $newEntity
     * @param array  $mapping
     *
     * @return void
     */
    public function addResolveTargetEntity($originalEntity, $newEntity, array $mapping)
    {
        $mapping['targetEntity']                                   = ltrim($newEntity, "\\");
        $this->resolveTargetEntities[ltrim($originalEntity, "\\")] = $mapping;
    }

    /**
     * @param OnClassMetadataNotFoundEventArgs $args
     *
     * @internal this is an event callback, and should not be called directly
     *
     * @return void
     */
    public function onClassMetadataNotFound(OnClassMetadataNotFoundEventArgs $args)
    {
        if (array_key_exists($args->getClassName(), $this->resolveTargetEntities)) {
            $args->setFoundMetadata(
                $args
                    ->getObjectManager()
                    ->getClassMetadata($this->resolveTargetEntities[$args->getClassname()]['targetEntity'])
            );
        }
    }

    /**
     * Processes event and resolves new target entity names.
     *
     * @param LoadClassMetadataEventArgs $args
     *
     * @return void
     *
     * @internal this is an event callback, and should not be called directly
     */
    public function loadClassMetadata(LoadClassMetadataEventArgs $args)
    {
        /* @var $cm \Doctrine\ORM\Mapping\ClassMetadata */
        $cm = $args->getClassMetadata();

        foreach ($cm->associationMappings as $mapping) {
            if (isset($this->resolveTargetEntities[$mapping['targetEntity']])) {
                $this->remapAssociation($cm, $mapping);
            }
        }

        foreach ($this->resolveTargetEntities as $interface => $data) {
            if ($data['targetEntity'] == $cm->getName()) {
                $args->getEntityManager()->getMetadataFactory()->setMetadataFor($interface, $cm);
            }
        }
    }

    /**
     * @param \Doctrine\ORM\Mapping\ClassMetadataInfo $classMetadata
     * @param array                                   $mapping
     *
     * @return void
     */
    private function remapAssociation($classMetadata, $mapping)
    {
        $newMapping = $this->resolveTargetEntities[$mapping['targetEntity']];
        $newMapping = array_replace_recursive($mapping, $newMapping);
        $newMapping['fieldName'] = $mapping['fieldName'];

        unset($classMetadata->associationMappings[$mapping['fieldName']]);

        switch ($mapping['type']) {
            case ClassMetadata::MANY_TO_MANY:
                $classMetadata->mapManyToMany($newMapping);
                break;
            case ClassMetadata::MANY_TO_ONE:
                $classMetadata->mapManyToOne($newMapping);
                break;
            case ClassMetadata::ONE_TO_MANY:
                $classMetadata->mapOneToMany($newMapping);
                break;
            case ClassMetadata::ONE_TO_ONE:
                $classMetadata->mapOneToOne($newMapping);
                break;
        }
    }
}


text:
This plugin executes a specified function. This allows the experimenter to run arbitrary code at any point during the experiment.

The function cannot take any arguments. If arguments are needed, then an anonymous function should be used to wrap the function call (see examples below).

## Parameters

Parameters with a default value of *undefined* must be specified. Other parameters can be left unspecified if the default value is acceptable.

Parameter | Type | Default Value | Description
----------|------|---------------|------------
func | function | *undefined* | The function to call.
async | boolean | `false` | Set to true if `func` is an asynchoronous function. If this is true, then the first argument passed to `func` will be a callback that you should call when the async operation is complete. You can pass data to the callback. See example below.

## Data Generated

In addition to the [default data collected by all plugins](overview#data-collected-by-plugins), this plugin collects the following data for each trial.

Name | Type | Value
-----|------|------
value | any | The return value of the called function.

## Examples

#### Calling a simple function

```javascript

var myfunc = function() {
	return 'you called?';
}

var trial = {
	type: 'call-function',
	func: myfunc
}
```

#### Using an anonymous function to pass variables

```javascript

var myfunc = function(data){
	// data contains all the experiment data so far,
	// so this function could implement code to write
	// the data to a database.
}

var trial = {
	type: 'call-function',
	func: function(){ myfunc(jsPsych.data.get())}
}
```

#### Async function call

```javascript
var trial = {
	type: 'call-function',
	async: true,
	func: function(done){
		// can perform async operations here like
		// creating an XMLHttpRequest to communicate
		// with a server
		var xhttp = new XMLHttpRequest();
		xhttp.onreadystatechange = function() {
			if (this.readyState == 4 && this.status == 200) {
				var response_data = xhttp.responseText;
				// line below is what causes jsPsych to
				// continue to next trial. response_data
				// will be stored in jsPsych data object.
				done(response_data);
			}
		};
		xhttp.open("GET", "path_to_server_script.php", true);
		xhttp.send();
	}
}
```


text:
"use strict";

const [ QR_VERSION_MIN, QR_VERSION_MAX ] = [ 1, 40 ];
const DEFAULT_ERROR_CORRECTION_LEVEL = 'L'; // 'L', 'M', 'Q', 'H'
const [ DEFAULT_CELL_SIZE, DEFAULT_MARGIN_SIZE] = [ 4, 8 ];

function generateQR(text, cellSize=1, margin=0) {
  for (let i = QR_VERSION_MIN; i <= QR_VERSION_MAX; ++i) {
    let qr = qrcode(i, DEFAULT_ERROR_CORRECTION_LEVEL);
    qr.addData(text);
    try {
      qr.make();
    } catch (e) {
      continue;
    }
    return qr.createImgTag(cellSize, margin);
  }
  throw "QR code not available";
}

browser.tabs.query({active: true, currentWindow: true}).then(tabs => {

  browser.storage.local.get('cellSize').then(result => {
    let tag = generateQR(tabs[0].url,
                         parseInt(result.cellSize) || DEFAULT_CELL_SIZE,
                         DEFAULT_MARGIN_SIZE);
    let doc = new DOMParser().parseFromString(tag, 'text/html');
    let img_el = doc.getElementsByTagName('img')[0];
    document.getElementById('qrcode_img').src = img_el.src;
  });

});


text:
/** Automatically generated file. DO NOT MODIFY */
package com.bgstation0.android.sample.wifimanager_;

public final class BuildConfig {
    public final static boolean DEBUG = true;
}


text:
// <copyright file="IExecutor.cs" company="Nikolay Kostov (Nikolay.IT)">
// Copyright (c) Nikolay Kostov (Nikolay.IT). All Rights Reserved.
// Licensed under the Apache License. See LICENSE in the project root for license information.
// </copyright>

namespace RestrictedProcess
{
    using System.Collections.Generic;

    public interface IExecutor
    {
        ProcessExecutionResult Execute(string fileName, string inputData, int timeLimit, int memoryLimit, IEnumerable<string> executionArguments = null);
    }
}


text:
package in.twizmwaz.cardinal.module.modules.broadcasts;

import in.twizmwaz.cardinal.match.Match;
import in.twizmwaz.cardinal.module.ModuleBuilder;
import in.twizmwaz.cardinal.module.ModuleCollection;
import in.twizmwaz.cardinal.module.modules.broadcasts.BroadcastModule.BroadcastType;
import in.twizmwaz.cardinal.util.NumUtils;
import in.twizmwaz.cardinal.util.StringUtils;
import org.bukkit.ChatColor;
import org.jdom2.Element;

public class BroadcastModuleBuilder implements ModuleBuilder {
    @SuppressWarnings("unchecked")
    @Override
    public ModuleCollection load(Match match) {
        ModuleCollection results = new ModuleCollection();
        for (Element broadcast : match.getDocument().getRootElement().getChildren("broadcasts")) {
            for (Element element : broadcast.getChildren("tip")) {
                String message;
                int timeAfter;
                int every = -1;
                int count = 1;
                message = ChatColor.translateAlternateColorCodes('`', element.getText());
                timeAfter = StringUtils.timeStringToSeconds(element.getAttributeValue("after"));
                if (element.getAttributeValue("every") != null) {
                    every = StringUtils.timeStringToSeconds(element.getAttributeValue("every"));
                }
                if (element.getAttributeValue("count") != null) {
                    count = NumUtils.parseInt(element.getAttributeValue("count"));
                } else if (every >= 1) {
                    count = (int) Double.POSITIVE_INFINITY;
                }
                results.add(new BroadcastModule(message, BroadcastType.TIP, timeAfter, every, count));
            }
            for (Element element : broadcast.getChildren("alert")) {
                String message;
                int timeAfter;
                int every = -1;
                int count = 1;
                message = ChatColor.translateAlternateColorCodes('`', element.getText());
                timeAfter = StringUtils.timeStringToSeconds(element.getAttributeValue("after"));
                if (element.getAttributeValue("every") != null) {
                    every = StringUtils.timeStringToSeconds(element.getAttributeValue("every"));
                }
                if (element.getAttributeValue("count") != null) {
                    count = NumUtils.parseInt(element.getAttributeValue("count"));
                } else if (every >= 1) {
                    count = (int) Double.POSITIVE_INFINITY;
                }
                results.add(new BroadcastModule(message, BroadcastType.ALERT, timeAfter, every, count));
            }
        }
        return results;
    }
}


text:
package cn.fmachine.util;

import cn.fmachine.entity.HouseUser;
import org.hibernate.Query;
import org.hibernate.Session;
import org.junit.Test;

import java.util.List;

public class H4SessionFactoryTest {
    @Test
    public void sessionTest() {
        Session session = H4SessionFactory.getSession();
        Query q = session.createQuery("From HouseUser");
        List<HouseUser> list = q.list();
        for (HouseUser user : list) {
            System.out.println(user.getRealname());
        }

    }
}


text: yujie self blog


text:
puppet-corosync
======

Puppet module for managing corosync configurations.

#### Table of Contents
1. [Overview - What is the corosync module?](#overview)
2. [Usage](#usage)

Overview
--------

This module is a simple configurator for corosync/pacemaker services.

Usage
-----

Parameters:

* **authkey**: the authentication key
* **bindnetaddr**: the IP to bind the servies to
* **broadcast**: set this to true if you want to use broadcast instead of multicast
* **cluster_name**: The cluster name
* **mcastaddr**: the multicast address, if using multicast
* **mcastport**: the multicast port of the cluster
* **nodes**: The cluster members
* **pacemaker_version**: Set this to the value of the pacemaker protocol. Default is 0.
* **secauth**: enable or disable secure authentication (default false)
* **unicast**: Set this to true if you want to use unicast communications

**Sample usage**

```corosync
class {'corosync':
    bindnetaddr => $ipaddress,
    mcastaddr   => '226.94.1.1',
    mcastport   => 5405,
    secauth     => false,
    authkey     => 'puppet:///modules/mymodule/authkey',
    pacemaker   => 0
}
```

Contributors
------------

* https://github.com/desalvo/puppet-corosync/graphs/contributors

Release Notes
-------------

**0.1.2**

* Fix templates

**0.1.1**

* New parameters
* **cluster_name**
* **unicast**
* **nodes**
* **pacemaker_version**

**0.1.0**

* Initial version


text:
package org.apache.hc.core5.function;

public interface Supplier<T> {
    T get();

}


text:
import { Component, Input, Injector, OnInit } from '@angular/core';

import { AppService } from '../app.service';
import { PageContext } from '../shared/models/page-context.model';
import { ContentService } from '../shared/services/content.service';

@Component({
  selector: 'three',
  templateUrl: './three.component.html',
  styles: []
})
export class ThreeComponent implements OnInit {
    componentContext: any;
    pageManager: any;

    constructor(private injector: Injector, private contentService: ContentService, private app: AppService) {
        /***
         *  Using service locator pattern - https://angular.io/docs/ts/latest/guide/dependency-injection.html#!#explicit-injector
         *      -> injector.get('<provider name>', <default value>)
         */
        this.pageManager = app.pageManager;
        this.componentContext = this.injector.get('context', {});
    }

    selectPage(id: string) {
        let newPage: PageContext = this.contentService.getPage(id);
        this.pageManager.selectPage(newPage);
    }

    ngOnInit() {
        console.log('three init');
    }

}


text:
Simulate a bank account supporting opening/closing, withdrawals, and deposits
of money. Watch out for concurrent transactions!

A bank account can be accessed in multiple ways. Clients can make
deposits and withdrawals using the internet, mobile phones, etc. Shops
can charge against the account.

Create an account that can be accessed from multiple threads/processes
(terminology depends on your programming language).

It should be possible to close an account; operations against a closed
account must fail.

## Instructions

Run the test file, and fix each of the errors in turn. When you get the
first test to pass, go to the first pending or skipped test, and make
that pass as well. When all of the tests are passing, feel free to
submit.

Remember that passing code is just the first step. The goal is to work
towards a solution that is as readable and expressive as you can make
it.

Have fun!

## Exception messages

Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
a message.

To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
`raise Exception`, you should write:

```python
raise Exception("Meaningful message indicating the source of the error")
```

## Running the tests

To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)):

- Python 2.7: `py.test bank_account_test.py`
- Python 3.4+: `pytest bank_account_test.py`

Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version):
`python -m pytest bank_account_test.py`

### Common `pytest` options

- `-v` : enable verbose output
- `-x` : stop running tests on first failure
- `--ff` : run failures from previous test before running other test cases

For other options, see `python -m pytest -h`

## Submitting Exercises

Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/bank-account` directory.

You can find your Exercism workspace by running `exercism debug` and looking for the line that starts with `Workspace`.

For more detailed information about running tests, code style and linting,
please see [Running the Tests](http://exercism.io/tracks/python/tests).

## Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.


text:
<!DOCTYPE html>

		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<link href="css/bootstrap.min.css" rel="stylesheet">
		<link href="css/homestyle.css" rel="stylesheet">

		<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">

		<title>Delhi Dekho!!!</title>

delhitourism

 Home

Things To Do

Accomodation

Transport

Contact

Delhi Transportation

The local transportation is the lifeline of the capital city of Delhi. More than half of the population in Delhi is dependent on local transport for commuting purposes. The means & modes of transport in New Delhi are many, ranging from the Metro Trains, Local Trains, Buses, Taxies and cabs.

Delhi Metro

The pride of the capital 'Delhi Metro' is a rapid transit system serving Delhi, Gurgaon and Noida in the National Capital Territory of Delhi. It is known for its world class standards with regard to safety, reliability, punctuality, and comfort. It has a combination of elevated, at-grade and underground lines and uses both broad gauge and standard gauge rolling stock.

City Bus

One of the cheapest modes of transport in Delhi consists of the environment friendly CNG buses. Delhi Transport Corporation has the World's largest fleet of public transoprt running on environment friendly clean CNG fuel.

Radio Taxi

With a vision to provide a safe, clean, comfortable, efficient, cost-effective yet sophisticated, and personalized public transport system, radio taxis were recently introduced in Delhi to improve the commuting experience. If you would like to Rent a Cab or Hire a Cab in Delhi, you can easily avail professional, comfortable, air-conditioned Radio taxi services from various Radio Cab companies.

Auto Rickshaw

Autos are a great way of seeing a city. They are less expensive than taxis and unlike buses, they take you to the doorstep of your destination.With a vision to provide a safe, clean, comfortable, efficient, cost-effective yet sophisticated, and personalized public transport system.

Contact Us

 Partners

Privacy Policy

About Us

Attractions

Book My Show

Air India

Kingfisher Airlines

SpiceJet

Share Your Experience

						<div class="col-md-2 col-md-offset-4"

						<div class="col-md-2"

Copyright © 2016 Joydeep Bhattacharya. All Rights Reserved


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>Uses of Interface main.java.positionalIndex.indexingCreatingSystem.DocumentTokenizer</title>
<meta name="date" content="2015-02-21">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes

Uses of Interface
main.java.positionalIndex.indexingCreatingSystem.DocumentTokenizer

Packages that use DocumentTokenizer

Package
Description

main.java.positionalIndex.indexingCreatingSystem

Uses of DocumentTokenizer in main.java.positionalIndex.indexingCreatingSystem

Classes in main.java.positionalIndex.indexingCreatingSystem that implement DocumentTokenizer

Modifier and Type
Class and Description

class
SimpleTokenStream

Reads tokens one at a time from an input stream.

Methods in main.java.positionalIndex.indexingCreatingSystem that return DocumentTokenizer

Modifier and Type
Method and Description

static DocumentTokenizer
DocumentTokenizerFactory.createTokenizer(java.nio.file.Path file)

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes


text:
<!--
FrozenIsBool False
-->

#Packager

##Doc
----

>
> The Packager is an Object that helps to get a module in the SYS framework
>
>

----

<small>
View the Packager notebook on [NbViewer](http://nbviewer.ipython.org/url/shareyoursystem.ouvaton.org/Packager.ipynb)
</small>


text:
<?php

namespace TrustedForms;

require_once 'autoload.php';

/**
 * Test class for ValidationChainItem.
 * Generated by PHPUnit on 2011-03-19 at 10:58:37.
 */
class FormValidatorTest extends \PHPUnit_Framework_TestCase
{
    public function testFlag()
    {
        $form = new FormValidator;
        $form->setFlag('mark');
        $form->setFlag('flag','value');
        $this->assertTrue($form->isFlag('mark'));
        $this->assertFalse($form->isFlag('none'));
        $this->assertTrue($form->isFlag('flag'));
        $this->assertEquals('value', $form->getFlag('flag'));
    }

    public function testSetFlags()
    {
        $form = new FormValidator;
        $form->setFlags(array('f1'=>'a','f2'=>'b'));
        $this->assertTrue($form->isFlag('f1'));
        $this->assertEquals('a', $form->getFlag('f1'));
        $this->assertTrue($form->isFlag('f2'));
        $this->assertEquals('b', $form->getFlag('f2'));
    }

    public function testArrayValidator()
    {
        $form = new FormValidator;
        $form['key'] = new VariableValidator();
        $err = new FormErrorReporter('msg');
        $err->addFlag('flg');
        $form['key']->addReporter($err);
        $form['key']->addToChain(new \TrustedForms\ValueChecks\isNumeric());
        $this->assertFalse($form->checkArray(array('key'=>'value')));
        $this->assertTrue($form->isFlag('flg'));
    }

    public function testInstantiation()
    {
        $this->assertInstanceOf('TrustedForms\FormValidator', \TrustedForms\FormValidator::instance());
    }

    /**
     * @expectedException TrustedForms\Exceptions\CircularValidator
     */
    public function testCircleReference()
    {
        $form = new FormValidator();
        $form['value'] = VariableValidator::instance()->addToChain(new \TrustedForms\ValueChecks\isEqualToField(array('value2')));
        $form['value2'] = VariableValidator::instance()->addToChain(new \TrustedForms\ValueChecks\isEqualToField(array('value')));
        $form->checkArray(array('value'=>1,'value2'=>2));
    }
}


text:
using System;
using System.Reflection;

namespace MediatR.Examples.StructureMap.WebAPI.Areas.HelpPage.ModelDescriptions
{
    public interface IModelDocumentationProvider
    {
        string GetDocumentation(MemberInfo member);

        string GetDocumentation(Type type);
    }
}


text:
import os
import tempfile
import unittest
import logging
from pyidf import ValidationLevel
import pyidf
from pyidf.idf import IDF
from pyidf.thermal_zones_and_surfaces import ShadingSiteDetailed

log = logging.getLogger(__name__)

class TestShadingSiteDetailed(unittest.TestCase):

    def setUp(self):
        self.fd, self.path = tempfile.mkstemp()

    def tearDown(self):
        os.remove(self.path)

    def test_create_shadingsitedetailed(self):

        pyidf.validation_level = ValidationLevel.error

        obj = ShadingSiteDetailed()
        # alpha
        var_name = "Name"
        obj.name = var_name
        # object-list
        var_transmittance_schedule_name = "object-list|Transmittance Schedule Name"
        obj.transmittance_schedule_name = var_transmittance_schedule_name
        # real
        var_number_of_vertices = 3.0
        obj.number_of_vertices = var_number_of_vertices
        paras = []
        var_vertex_1_xcoordinate = 4.4
        paras.append(var_vertex_1_xcoordinate)
        var_vertex_1_ycoordinate = 5.5
        paras.append(var_vertex_1_ycoordinate)
        var_vertex_1_zcoordinate = 6.6
        paras.append(var_vertex_1_zcoordinate)
        obj.add_extensible(*paras)

        idf = IDF()
        idf.add(obj)
        idf.save(self.path, check=False)

        with open(self.path, mode='r') as f:
            for line in f:
                log.debug(line.strip())

        idf2 = IDF(self.path)
        self.assertEqual(idf2.shadingsitedetaileds[0].name, var_name)
        self.assertEqual(idf2.shadingsitedetaileds[0].transmittance_schedule_name, var_transmittance_schedule_name)
        self.assertAlmostEqual(idf2.shadingsitedetaileds[0].number_of_vertices, var_number_of_vertices)
        index = obj.extensible_field_index("Vertex 1 X-coordinate")
        self.assertAlmostEqual(idf2.shadingsitedetaileds[0].extensibles[0][index], var_vertex_1_xcoordinate)
        index = obj.extensible_field_index("Vertex 1 Y-coordinate")
        self.assertAlmostEqual(idf2.shadingsitedetaileds[0].extensibles[0][index], var_vertex_1_ycoordinate)
        index = obj.extensible_field_index("Vertex 1 Z-coordinate")
        self.assertAlmostEqual(idf2.shadingsitedetaileds[0].extensibles[0][index], var_vertex_1_zcoordinate)


text:
from django.contrib import admin
from django.contrib.flatpages.models import FlatPage
from django.contrib.sites.models import Site
from django.contrib.flatpages.admin import FlatPageAdmin as OldFlatPageAdmin
from django.contrib.sites.admin import SiteAdmin as OldSiteAdmin
from django.conf import settings

from flatpage_meta.models import MetaTagType, FlatPageMetaTag, SiteMetaTag

class MetaTagTypeAdmin(admin.ModelAdmin):
    list_display = ('name', 'description', 'format_string', 'allow_multiple')

class FlatPageMetaTagInline(admin.TabularInline):
    model = FlatPageMetaTag

class ReplacementFlatPageAdmin(OldFlatPageAdmin):
    def formfield_for_dbfield(self, db_field, **kwargs):
        if "tinymce" in settings.INSTALLED_APPS:
            from django import forms
            from tinymce.widgets import TinyMCE
            if db_field.name == 'content':
                return forms.CharField(widget=TinyMCE(
                    attrs={'cols': 80, 'rows': 30},
                    mce_attrs={},
                ))
        return super(ReplacementFlatPageAdmin, self).formfield_for_dbfield(db_field, **kwargs)

    inlines = [FlatPageMetaTagInline]

class SiteMetaTagInline(admin.TabularInline):
    model = SiteMetaTag

class ReplacementSiteAdmin(OldSiteAdmin):
    inlines = [SiteMetaTagInline]

admin.site.register(MetaTagType, MetaTagTypeAdmin)

admin.site.unregister(FlatPage)
admin.site.register(FlatPage, ReplacementFlatPageAdmin)
admin.site.unregister(Site)
admin.site.register(Site, ReplacementSiteAdmin)


text:
package ec2

import "github.com/timob/javabind"

type ServicesEc2ModelSpotInstanceStateFaultInterface interface {
	JavaLangObjectInterface

	// public void setCode(java.lang.String)
	SetCode(a string)

	// public java.lang.String getCode()
	GetCode() string

	// public com.amazonaws.services.ec2.model.SpotInstanceStateFault withCode(java.lang.String)
	WithCode(a string) *ServicesEc2ModelSpotInstanceStateFault

	// public void setMessage(java.lang.String)
	SetMessage(a string)

	// public java.lang.String getMessage()
	GetMessage() string

	// public com.amazonaws.services.ec2.model.SpotInstanceStateFault withMessage(java.lang.String)
	WithMessage(a string) *ServicesEc2ModelSpotInstanceStateFault

	// public com.amazonaws.services.ec2.model.SpotInstanceStateFault clone()
	Clone() *ServicesEc2ModelSpotInstanceStateFault
}

type ServicesEc2ModelSpotInstanceStateFault struct {
	JavaLangObject
}

// public com.amazonaws.services.ec2.model.SpotInstanceStateFault()
func NewServicesEc2ModelSpotInstanceStateFault() (*ServicesEc2ModelSpotInstanceStateFault) {

	obj, err := javabind.GetEnv().NewObject("com/amazonaws/services/ec2/model/SpotInstanceStateFault")
	if err != nil {
		panic(err)
	}
	x := &ServicesEc2ModelSpotInstanceStateFault{}
	x.Callable = &javabind.Callable{obj}
	return x
}

// public void setCode(java.lang.String)
func (jbobject *ServicesEc2ModelSpotInstanceStateFault) SetCode(a string)  {
	conv_a := javabind.NewGoToJavaString()
	if err := conv_a.Convert(a); err != nil {
		panic(err)
	}
	_, err := jbobject.CallMethod(javabind.GetEnv(), "setCode", javabind.Void, conv_a.Value().Cast("java/lang/String"))
	if err != nil {
		panic(err)
	}
	conv_a.CleanUp()

}

// public java.lang.String getCode()
func (jbobject *ServicesEc2ModelSpotInstanceStateFault) GetCode() string {
	jret, err := jbobject.CallMethod(javabind.GetEnv(), "getCode", "java/lang/String")
	if err != nil {
		panic(err)
	}
	retconv := javabind.NewJavaToGoString()
	dst := new(string)
	retconv.Dest(dst)
	if err := retconv.Convert(javabind.ObjectRef(jret)); err != nil {
		panic(err)
	}
	retconv.CleanUp()
	return *dst
}

// public com.amazonaws.services.ec2.model.SpotInstanceStateFault withCode(java.lang.String)
func (jbobject *ServicesEc2ModelSpotInstanceStateFault) WithCode(a string) *ServicesEc2ModelSpotInstanceStateFault {
	conv_a := javabind.NewGoToJavaString()
	if err := conv_a.Convert(a); err != nil {
		panic(err)
	}
	jret, err := jbobject.CallMethod(javabind.GetEnv(), "withCode", "com/amazonaws/services/ec2/model/SpotInstanceStateFault", conv_a.Value().Cast("java/lang/String"))
	if err != nil {
		panic(err)
	}
	conv_a.CleanUp()
	retconv := javabind.NewJavaToGoCallable()
	dst := &javabind.Callable{}
	retconv.Dest(dst)
	if err := retconv.Convert(javabind.ObjectRef(jret)); err != nil {
		panic(err)
	}
	retconv.CleanUp()
	unique_x := &ServicesEc2ModelSpotInstanceStateFault{}
	unique_x.Callable = dst
	return unique_x
}

// public void setMessage(java.lang.String)
func (jbobject *ServicesEc2ModelSpotInstanceStateFault) SetMessage(a string)  {
	conv_a := javabind.NewGoToJavaString()
	if err := conv_a.Convert(a); err != nil {
		panic(err)
	}
	_, err := jbobject.CallMethod(javabind.GetEnv(), "setMessage", javabind.Void, conv_a.Value().Cast("java/lang/String"))
	if err != nil {
		panic(err)
	}
	conv_a.CleanUp()

}

// public java.lang.String getMessage()
func (jbobject *ServicesEc2ModelSpotInstanceStateFault) GetMessage() string {
	jret, err := jbobject.CallMethod(javabind.GetEnv(), "getMessage", "java/lang/String")
	if err != nil {
		panic(err)
	}
	retconv := javabind.NewJavaToGoString()
	dst := new(string)
	retconv.Dest(dst)
	if err := retconv.Convert(javabind.ObjectRef(jret)); err != nil {
		panic(err)
	}
	retconv.CleanUp()
	return *dst
}

// public com.amazonaws.services.ec2.model.SpotInstanceStateFault withMessage(java.lang.String)
func (jbobject *ServicesEc2ModelSpotInstanceStateFault) WithMessage(a string) *ServicesEc2ModelSpotInstanceStateFault {
	conv_a := javabind.NewGoToJavaString()
	if err := conv_a.Convert(a); err != nil {
		panic(err)
	}
	jret, err := jbobject.CallMethod(javabind.GetEnv(), "withMessage", "com/amazonaws/services/ec2/model/SpotInstanceStateFault", conv_a.Value().Cast("java/lang/String"))
	if err != nil {
		panic(err)
	}
	conv_a.CleanUp()
	retconv := javabind.NewJavaToGoCallable()
	dst := &javabind.Callable{}
	retconv.Dest(dst)
	if err := retconv.Convert(javabind.ObjectRef(jret)); err != nil {
		panic(err)
	}
	retconv.CleanUp()
	unique_x := &ServicesEc2ModelSpotInstanceStateFault{}
	unique_x.Callable = dst
	return unique_x
}

// public java.lang.String toString()
func (jbobject *ServicesEc2ModelSpotInstanceStateFault) ToString() string {
	jret, err := jbobject.CallMethod(javabind.GetEnv(), "toString", "java/lang/String")
	if err != nil {
		panic(err)
	}
	retconv := javabind.NewJavaToGoString()
	dst := new(string)
	retconv.Dest(dst)
	if err := retconv.Convert(javabind.ObjectRef(jret)); err != nil {
		panic(err)
	}
	retconv.CleanUp()
	return *dst
}

// public boolean equals(java.lang.Object)
func (jbobject *ServicesEc2ModelSpotInstanceStateFault) Equals(a interface{}) bool {
	conv_a := javabind.NewGoToJavaCallable()
	if err := conv_a.Convert(a); err != nil {
		panic(err)
	}
	jret, err := jbobject.CallMethod(javabind.GetEnv(), "equals", javabind.Boolean, conv_a.Value().Cast("java/lang/Object"))
	if err != nil {
		panic(err)
	}
	conv_a.CleanUp()
	return jret.(bool)
}

// public int hashCode()
func (jbobject *ServicesEc2ModelSpotInstanceStateFault) HashCode() int {
	jret, err := jbobject.CallMethod(javabind.GetEnv(), "hashCode", javabind.Int)
	if err != nil {
		panic(err)
	}
	return jret.(int)
}

// public com.amazonaws.services.ec2.model.SpotInstanceStateFault clone()
func (jbobject *ServicesEc2ModelSpotInstanceStateFault) Clone() *ServicesEc2ModelSpotInstanceStateFault {
	jret, err := jbobject.CallMethod(javabind.GetEnv(), "clone", "com/amazonaws/services/ec2/model/SpotInstanceStateFault")
	if err != nil {
		panic(err)
	}
	retconv := javabind.NewJavaToGoCallable()
	dst := &javabind.Callable{}
	retconv.Dest(dst)
	if err := retconv.Convert(javabind.ObjectRef(jret)); err != nil {
		panic(err)
	}
	retconv.CleanUp()
	unique_x := &ServicesEc2ModelSpotInstanceStateFault{}
	unique_x.Callable = dst
	return unique_x
}

// public java.lang.Object clone() throws java.lang.CloneNotSupportedException
func (jbobject *ServicesEc2ModelSpotInstanceStateFault) Clone2() (*JavaLangObject, error) {
	jret, err := jbobject.CallMethod(javabind.GetEnv(), "clone", "java/lang/Object")
	if err != nil {
		var zero *JavaLangObject
		return zero, err
	}
	retconv := javabind.NewJavaToGoCallable()
	dst := &javabind.Callable{}
	retconv.Dest(dst)
	if err := retconv.Convert(javabind.ObjectRef(jret)); err != nil {
		panic(err)
	}
	retconv.CleanUp()
	unique_x := &JavaLangObject{}
	unique_x.Callable = dst
	return unique_x, nil
}


text:
using System;
using System.Collections.Generic;

namespace Buildron.Domain.EasterEggs
{
	/// <summary>
	/// Defines an easter egg provider interface.
	/// </summary>
	public interface IEasterEggProvider
	{
		/// <summary>
		/// Verify if the provider can execute the easter egg.
		/// </summary>
		/// <param name="easterEggName">The name of easter egg to execute</param>
		bool CanExecute(string easterEggName);

		/// <summary>
		/// Execute the easter egg.
		/// </summary>
		/// <param name="easterEggName">The name of easter egg to execute</param>
		/// <returns>If an easter egg was executed.</returns>
		bool Execute(string easterEggName);
	}
}