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

io.github.vipcxj.jasync.spec.UnwrapUnsupportedException Maven / Gradle / Ivy

Go to download

JAsync implements Async-Await fashion for Java just like es and c#. This library provide the spec of all public api.

There is a newer version: 1.0.17
Show newest version
package io.github.vipcxj.jasync.spec;

public class UnwrapUnsupportedException extends JAsyncException {

    private static final long serialVersionUID = 2618582481073106611L;
    private final Class targetType;
    private final Class[] supportedTypes;

    public UnwrapUnsupportedException(Class targetType, Class... supportedTypes) {
        this.targetType = targetType;
        this.supportedTypes = supportedTypes;
    }

    @Override
    public String getMessage() {
        StringBuilder sb = new StringBuilder("Unable to be unwrapped to the " + targetType + ". The supported types are ");
        if (supportedTypes == null || supportedTypes.length == 0) {
            return sb.append("none.").toString();
        } else {
            int i = 0;
            for (Class supportedType : supportedTypes) {
                sb.append(supportedType);
                if (++i == supportedTypes.length) {
                    sb.append(".");
                } else {
                    sb.append(", ");
                }
            }
            return sb.toString();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy