All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jaskell.parsec.common.Eq Maven / Gradle / Ivy

Go to download

This is a utils library for java 8 project. It include parsec combinators and sql generators library.

There is a newer version: 2.9.2
Show newest version
package jaskell.parsec.common;

import jaskell.parsec.ParsecException;

import java.io.EOFException;
import java.util.Objects;

/**
 * Created by Mars Liu on 2016-01-03.
 * Eq 即 equal , 判断得到的信息项是否与预期相等.
 */
public class Eq implements Parsec {
    private final E item;
    @Override
    public  E parse(State s) throws EOFException, ParsecException {
        E re = s.next();
        if (Objects.equals(re, item)){
            return re;
        } else {
            String message = String.format("Expect %s is equal to %s", re, item);
            throw s.trap(message);
        }
    }

    public Eq(E item){
        this.item = item;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy