🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

which precondition should I add?

User: "gaoxiaolei"
New Altair Community Member
Updated by Jocelyn
Hi, everyone.

I developed a operator. This operator can only deal with exampleset has two attributes. I do not konw which precondition should I add to this operator. Could you help me?

Thanks.
gaoxiaolei

Find more posts tagged with

Sort by:
1 - 3 of 31
    User: "StaryVena"
    New Altair Community Member
    Hi,
    if I understand what you want, it should looks like this:

    inputPort.addPrecondition(new SimplePrecondition(inputPort, new MetaData(
    ExampleSet.class)));
    It doesn't matter how many attributes ExampleSet have.
    User: "gaoxiaolei"
    New Altair Community Member
    OP
    StaryVena wrote:

    Hi,
    if I understand what you want, it should looks like this:

    inputPort.addPrecondition(new SimplePrecondition(inputPort, new MetaData(
    ExampleSet.class)));
    It doesn't matter how many attributes ExampleSet have.
    Hi, thanks. But my opeator can only cope with exampleset which has only two attributes.
    I want this: if a exampleset with more than two attributes, and it connect to my opeator, there should be a error appeard.
    User: "Marco_Boeck"
    New Altair Community Member
    Hi,

    there are a couple of ways to achieve this, for example you can use the already mentioned SimplePrecondition class:

    inputPort.addPrecondition(new SimplePrecondition(inputPort, new MetaData(ExampleSet.class), true) {

    @Override
    /** Override this method to make additional checks. The default implementation does nothing. */
    public void makeAdditionalChecks(MetaData received) {
    if (((ExampleSetMetaData)received).getAllAttributes().size() != 2) {
    inputPort.addError(new SimpleMetaDataError(Severity.ERROR, inputPort, "I18N.key"));
    }
    }
    });

    Regards,
    Marco