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

org.jsimpledb.parse.util.ParseCastFunction Maven / Gradle / Ivy

The newest version!

/*
 * Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
 */

package org.jsimpledb.parse.util;

import org.jsimpledb.parse.expr.EvalException;
import org.jsimpledb.util.CastFunction;

/**
 * Parsing specific subclass of {@link CastFunction} that throws {@link EvalException}s instead of {@link ClassCastException}s.
 */
public class ParseCastFunction extends CastFunction {

    public ParseCastFunction(Class type) {
        super(type);
    }

    @Override
    protected RuntimeException handleFailure(Object obj, ClassCastException e) {
        return new EvalException("can't cast object of type " + obj.getClass().getName() + " to " + this.type.getName());
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy